mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Michal Hocko <mhocko@suse.com>,
	Dan Williams <dan.j.williams@intel.com>,
	David Rientjes <rientjes@google.com>,
	Paul Oppenheimer <bepvte@gmail.com>,
	William Kucharski <william.kucharski@oracle.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org
Subject: [PATCH AUTOSEL 3.18 19/19] mm, proc: be more verbose about unstable VMA flags in /proc/<pid>/smaps
Date: Tue,  8 Jan 2019 14:35:31 -0500	[thread overview]
Message-ID: <20190108193534.124555-19-sashal@kernel.org> (raw)
In-Reply-To: <20190108193534.124555-1-sashal@kernel.org>

From: Michal Hocko <mhocko@suse.com>

[ Upstream commit 7550c6079846a24f30d15ac75a941c8515dbedfb ]

Patch series "THP eligibility reporting via proc".

This series of three patches aims at making THP eligibility reporting much
more robust and long term sustainable.  The trigger for the change is a
regression report [2] and the long follow up discussion.  In short the
specific application didn't have good API to query whether a particular
mapping can be backed by THP so it has used VMA flags to workaround that.
These flags represent a deep internal state of VMAs and as such they
should be used by userspace with a great deal of caution.

A similar has happened for [3] when users complained that VM_MIXEDMAP is
no longer set on DAX mappings.  Again a lack of a proper API led to an
abuse.

The first patch in the series tries to emphasise that that the semantic of
flags might change and any application consuming those should be really
careful.

The remaining two patches provide a more suitable interface to address [2]
and provide a consistent API to query the THP status both for each VMA and
process wide as well.  [1]

http://lkml.kernel.org/r/20181120103515.25280-1-mhocko@kernel.org [2]
http://lkml.kernel.org/r/http://lkml.kernel.org/r/alpine.DEB.2.21.1809241054050.224429@chino.kir.corp.google.com
[3] http://lkml.kernel.org/r/20181002100531.GC4135@quack2.suse.cz

This patch (of 3):

Even though vma flags exported via /proc/<pid>/smaps are explicitly
documented to be not guaranteed for future compatibility the warning
doesn't go far enough because it doesn't mention semantic changes to those
flags.  And they are important as well because these flags are a deep
implementation internal to the MM code and the semantic might change at
any time.

Let's consider two recent examples:
http://lkml.kernel.org/r/20181002100531.GC4135@quack2.suse.cz
: 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/<pid>/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.

http://lkml.kernel.org/r/alpine.DEB.2.21.1809241054050.224429@chino.kir.corp.google.com
: Commit 1860033237d4 ("mm: make PR_SET_THP_DISABLE immediately active")
: introduced a regression in that userspace cannot always determine the set
: of vmas where thp is ineligible.
: Userspace relies on the "nh" flag being emitted as part of /proc/pid/smaps
: to determine if a vma is eligible to be backed by hugepages.
: Previous to this commit, prctl(PR_SET_THP_DISABLE, 1) would cause thp to
: be disabled and emit "nh" as a flag for the corresponding vmas as part of
: /proc/pid/smaps.  After the commit, thp is disabled by means of an mm
: flag and "nh" is not emitted.
: This causes smaps parsing libraries to assume a vma is eligible for thp
: and ends up puzzling the user on why its memory is not backed by thp.

In both cases userspace was relying on a semantic of a specific VMA flag.
The primary reason why that happened is a lack of a proper interface.
While this has been worked on and it will be fixed properly, it seems that
our wording could see some refinement and be more vocal about semantic
aspect of these flags as well.

Link: http://lkml.kernel.org/r/20181211143641.3503-2-mhocko@kernel.org
Signed-off-by: Michal Hocko <mhocko@suse.com>
Acked-by: Jan Kara <jack@suse.cz>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: David Rientjes <rientjes@google.com>
Acked-by: Mike Rapoport <rppt@linux.ibm.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Paul Oppenheimer <bepvte@gmail.com>
Cc: William Kucharski <william.kucharski@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 Documentation/filesystems/proc.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index 04b23a83ce68..3172a2465ff2 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -439,7 +439,9 @@ manner. The codes are the following:
 
 Note that there is no guarantee that every flag and associated mnemonic will
 be present in all further kernel releases. Things get changed, the flags may
-be vanished or the reverse -- new added.
+be vanished or the reverse -- new added. Interpretation of their meaning
+might change in future as well. So each consumer of these flags has to
+follow each specific kernel version for the exact semantic.
 
 This file is only present if the CONFIG_MMU kernel configuration option is
 enabled.
-- 
2.19.1


      parent reply	other threads:[~2019-01-08 19:36 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-08 19:35 [PATCH AUTOSEL 3.18 01/19] MIPS: SiByte: Enable swiotlb for SWARM, LittleSur and BigSur Sasha Levin
2019-01-08 19:35 ` [PATCH AUTOSEL 3.18 02/19] USB: serial: ftdi_sio: use rounding when calculating baud rate divisors Sasha Levin
2019-01-08 19:35 ` [PATCH AUTOSEL 3.18 03/19] jffs2: Fix use of uninitialized delayed_work, lockdep breakage Sasha Levin
2019-01-08 19:35 ` [PATCH AUTOSEL 3.18 04/19] pstore/ram: Do not treat empty buffers as valid Sasha Levin
2019-01-08 19:35 ` [PATCH AUTOSEL 3.18 05/19] powerpc/pseries/cpuidle: Fix preempt warning Sasha Levin
2019-01-08 19:35 ` [PATCH AUTOSEL 3.18 06/19] media: firewire: Fix app_info parameter type in avc_ca{,_app}_info Sasha Levin
2019-01-08 19:35 ` [PATCH AUTOSEL 3.18 07/19] net: call sk_dst_reset when set SO_DONTROUTE Sasha Levin
2019-01-08 19:35 ` [PATCH AUTOSEL 3.18 08/19] scsi: target: use consistent left-aligned ASCII INQUIRY data Sasha Levin
2019-01-08 19:35 ` [PATCH AUTOSEL 3.18 09/19] clk: imx6q: reset exclusive gates on init Sasha Levin
2019-01-08 19:35 ` [PATCH AUTOSEL 3.18 10/19] kconfig: fix memory leak when EOF is encountered in quotation Sasha Levin
2019-01-08 19:35 ` [PATCH AUTOSEL 3.18 11/19] mmc: atmel-mci: do not assume idle after atmci_request_end Sasha Levin
2019-01-08 19:35 ` [PATCH AUTOSEL 3.18 12/19] perf svghelper: Fix unchecked usage of strncpy() Sasha Levin
2019-01-08 19:35 ` [PATCH AUTOSEL 3.18 13/19] perf parse-events: " Sasha Levin
2019-01-08 19:35 ` [PATCH AUTOSEL 3.18 14/19] dm kcopyd: Fix bug causing workqueue stalls Sasha Levin
2019-01-08 19:35 ` [PATCH AUTOSEL 3.18 15/19] dm snapshot: Fix excessive memory usage and " Sasha Levin
2019-01-08 19:35 ` [PATCH AUTOSEL 3.18 16/19] ALSA: bebob: fix model-id of unit for Apogee Ensemble Sasha Levin
2019-01-08 19:35 ` [PATCH AUTOSEL 3.18 17/19] sysfs: Disable lockdep for driver bind/unbind files Sasha Levin
2019-01-08 19:35 ` [PATCH AUTOSEL 3.18 18/19] ocfs2: fix panic due to unrecovered local alloc Sasha Levin
2019-01-08 19:35 ` Sasha Levin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190108193534.124555-19-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=bepvte@gmail.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhocko@suse.com \
    --cc=rientjes@google.com \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=william.kucharski@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome