From patchwork Tue Oct 2 10:05:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 10623331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A2A9315E8 for ; Tue, 2 Oct 2018 10:05:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4853D287E6 for ; Tue, 2 Oct 2018 10:05:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BABE287E7; Tue, 2 Oct 2018 10:05:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1C48287DC for ; Tue, 2 Oct 2018 10:05:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 588E76B0003; Tue, 2 Oct 2018 06:05:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 539086B0005; Tue, 2 Oct 2018 06:05:34 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4292A6B0006; Tue, 2 Oct 2018 06:05:34 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id DBC3B6B0003 for ; Tue, 2 Oct 2018 06:05:33 -0400 (EDT) Received: by mail-ed1-f69.google.com with SMTP id g36-v6so983824edb.3 for ; Tue, 02 Oct 2018 03:05:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:date:from:to :cc:subject:message-id:mime-version:content-disposition:user-agent; bh=Kd5VQl5atiJoy7W+LjloazezLLBiVfDrdslupMZ82co=; b=rqkAx5UqqEe0iIHCNecPxJkwmp9EvF3QGhSeK/Vd9ghNrIDq+Hky7kNcsoz37tO9V/ 9kTCb38AJb8Y1pccHClA3mP8PJOHj7B3UI6G0CyidvW9NLEk2JiuO+QZ4DiXVbfptn9V wsKUeN1arXGcU2sXSrhdgFuEhXrSGORoFd/9vE01/4mU9/1yy0vZy5dDt3vktHutkc0P zVxTDPHL6bGyLJ6Nh5pn+mL8qoQ+n+YeGrKzXOxoQj/qiFxRcag1mQyy8a1IBKnVjhNf 6rAfd4C9n2+jqDiHOQV4GGG1Jldc9ZV387/BImPQ1wrZeBZMs3zvkkwk5h6c0BmBS8q7 lx7g== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of jack@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=jack@suse.cz X-Gm-Message-State: ABuFfoiW+tJ5Nz1AucauARPtbjYKTGyEvnFoC8SsUC1El7aiG5GJM9FD 1BtAsB7A+Z30NPgx5/PtbhPnohXL0VVMTb3huHyAN/LpZMEWEXNPoeU7/oQyMbz5IEVK9DmPDzz WTkbmqcrQWe9TeEwVH5DSAiOFn4VCb2h7nn0rOA4CxaVgGCIIYdxF36svVS3JTc2sIw== X-Received: by 2002:a50:b0c1:: with SMTP id j59-v6mr22094503edd.267.1538474733394; Tue, 02 Oct 2018 03:05:33 -0700 (PDT) X-Google-Smtp-Source: ACcGV60OO5Z1JB8b6PcWb2034l5JTdfdKMWbpCjc0jcAm70q1tZKxIH4tDSbPle9eC6ikcqczKd/ X-Received: by 2002:a50:b0c1:: with SMTP id j59-v6mr22094440edd.267.1538474732662; Tue, 02 Oct 2018 03:05:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538474732; cv=none; d=google.com; s=arc-20160816; b=DcUygYYoKHiMSBBROgxZ8c97wGZmDpFGplsg7OGBl8wnAiPsAUZUPvz5htEDEgb2py 7dGYJpO/h580+sRZ35NP4DrO1sS7v9WJrP9GfZFBDvMnQ5SzQbmGaDNCY9nz/6/pnMmK v13RU0LKkRyvmPCsYunI8z3Vo3XiqevFJlPiMM8s1TRWeqBp1GVBeQ8WQptpBoptMKOX RNoCbsPa9wVuSGs10WvQoegN71PHqxzjf+OqgSVE7M8m8nRwxTxG89hkWgjl0yRDTjBW OfMNvaXIufQ9GZLSoAHNNOq/EunWTQeipIigH3nxFk73QE30LjbBPdIdg9zQwHwOb6G0 SPZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date; bh=Kd5VQl5atiJoy7W+LjloazezLLBiVfDrdslupMZ82co=; b=OciSuef0BmnSR9d6LPf/0ZsjLxVLNwv5LhUffU7lq1WRpxHrzWCRmRfyBmd4U4gK8U arByMj3PWCsdQYya7+0WAucXkc+XVkKbxCkmgp3WWrr9I3l9tg1CzLR6n+iky4QPAJUh HWWeCSjbMdToBkTUVYIz4DK7m7rK9D063eW2czhTUqjywcgtVjwYDE7ZDBF1vNyG40Wi Zns9YwheMy4wRDrZh9HGUmBFjbdFE7psA93OG7dD9plLu6tsVfxZLd3OOKtC6n9n/oGG j2XaVot1dpxsqRmDHGmPFD3s9MRrO60SekcvP0031tubYkJYTMDtutZ320zZNvNU3l6+ K+GQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of jack@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=jack@suse.cz Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id l12-v6si577192edj.314.2018.10.02.03.05.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Oct 2018 03:05:32 -0700 (PDT) Received-SPF: pass (google.com: domain of jack@suse.cz designates 195.135.220.15 as permitted sender) client-ip=195.135.220.15; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jack@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=jack@suse.cz X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E952FAEDC; Tue, 2 Oct 2018 10:05:31 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 8522E1E0629; Tue, 2 Oct 2018 12:05:31 +0200 (CEST) Date: Tue, 2 Oct 2018 12:05:31 +0200 From: Jan Kara To: Dan Williams , Dave Jiang Cc: linux-nvdimm@lists.01.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, jthumshirn@suse.de Subject: Problems with VM_MIXEDMAP removal from /proc//smaps Message-ID: <20181002100531.GC4135@quack2.suse.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Hello, commit e1fb4a086495 "dax: remove VM_MIXEDMAP for fsdax and device dax" has removed VM_MIXEDMAP flag from DAX VMAs. Now our testing shows that in the mean time certain customer of ours started poking into /proc//smaps and looks at VMA flags there and if VM_MIXEDMAP is missing among the VMA flags, the application just fails to start complaining that DAX support is missing in the kernel. The question now is how do we go about this? Strictly speaking, this is a userspace visible regression (as much as I think that application poking into VMA flags at this level is just too bold). Is there any precedens in handling similar issues with smaps which really exposes a lot of information that is dependent on kernel implementation details? I have attached a patch that is an obvious "fix" for the issue - just fake VM_MIXEDMAP flag in smaps. But I'm open to other suggestions... Honza From a3bfac5e1582d9c31e67090b306efedf7c392d36 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Tue, 2 Oct 2018 11:58:22 +0200 Subject: [PATCH] proc: Show DAX mappings as having VM_MIXEDMAP flag Until commit e1fb4a08649 "dax: remove VM_MIXEDMAP for fsdax and device dax", userspace could distinguish DAX and non-DAX mappings in /proc//smaps by checking whether the VMA has VM_MIXEDMAP (mm in smaps) flag. And indeed some applications started doing this. Maintain backwards compatibility by faking VM_MIXEDMAP flag in smaps for DAX mappings. Fixes: e1fb4a0864958fac2fb1b23f9f4562a9f90e3e8f Signed-off-by: Jan Kara --- fs/proc/task_mmu.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 5ea1d64cb0b4..9cd8e84610a7 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -654,12 +655,18 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma) #endif /* CONFIG_ARCH_HAS_PKEYS */ }; size_t i; + unsigned long flags = vma->vm_flags; + /* + * We fake VM_MIXEDMAP for DAX mappings here as some apps depend on it. + */ + if (vma_is_dax(vma)) + flags |= VM_MIXEDMAP; seq_puts(m, "VmFlags: "); for (i = 0; i < BITS_PER_LONG; i++) { if (!mnemonics[i][0]) continue; - if (vma->vm_flags & (1UL << i)) { + if (flags & (1UL << i)) { seq_putc(m, mnemonics[i][0]); seq_putc(m, mnemonics[i][1]); seq_putc(m, ' '); -- 2.16.4