Skip to content
  • David Rientjes's avatar
    mm, thp: always specify disabled vmas as nh in smaps · 90ee1928
    David Rientjes authored
    18600332 ("mm: make PR_SET_THP_DISABLE immediately active") introduced
    a regression in that userspace cannot always determine the set of vmas
    where thp is disabled.
    
    Userspace relies on the "nh" flag being emitted as part of /proc/pid/smaps
    to determine if a vma has been disabled from being 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 enabled for thp and
    ends up puzzling the user on why its memory is not backed by thp.
    
    This also clears the "hg" flag to make the behavior of MADV_HUGEPAGE and
    PR_SET_THP_DISABLE definitive.
    
    Link: http://lkml.kernel.org/r/alpine.DEB.2.21.1809251449060.96762@chino.kir.corp.google.com
    Fixes: 18600332
    
     ("mm: make PR_SET_THP_DISABLE immediately active")
    Signed-off-by: default avatarDavid Rientjes <rientjes@google.com>
    Cc: Michal Hocko <mhocko@kernel.org>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: Alexey Dobriyan <adobriyan@gmail.com>
    Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
    Cc: <stable@vger.kernel.org>	[4.13+]
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
    90ee1928