linux-stable/fs/proc
Michal Hocko c76adee347 mm, thp, proc: report THP eligibility for each vma
[ Upstream commit 7635d9cbe8 ]

Userspace falls short when trying to find out whether a specific memory
range is eligible for THP.  There are usecases that would like to know
that
http://lkml.kernel.org/r/alpine.DEB.2.21.1809251248450.50347@chino.kir.corp.google.com
: This is used to identify heap mappings that should be able to fault thp
: but do not, and they normally point to a low-on-memory or fragmentation
: issue.

The only way to deduce this now is to query for hg resp.  nh flags and
confronting the state with the global setting.  Except that there is also
PR_SET_THP_DISABLE that might change the picture.  So the final logic is
not trivial.  Moreover the eligibility of the vma depends on the type of
VMA as well.  In the past we have supported only anononymous memory VMAs
but things have changed and shmem based vmas are supported as well these
days and the query logic gets even more complicated because the
eligibility depends on the mount option and another global configuration
knob.

Simplify the current state and report the THP eligibility in
/proc/<pid>/smaps for each existing vma.  Reuse
transparent_hugepage_enabled for this purpose.  The original
implementation of this function assumes that the caller knows that the vma
itself is supported for THP so make the core checks into
__transparent_hugepage_enabled and use it for existing callers.
__show_smap just use the new transparent_hugepage_enabled which also
checks the vma support status (please note that this one has to be out of
line due to include dependency issues).

[mhocko@kernel.org: fix oops with NULL ->f_mapping]
  Link: http://lkml.kernel.org/r/20181224185106.GC16738@dhcp22.suse.cz
Link: http://lkml.kernel.org/r/20181211143641.3503-3-mhocko@kernel.org
Signed-off-by: Michal Hocko <mhocko@suse.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Mike Rapoport <rppt@linux.ibm.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>
2019-12-17 20:35:45 +01:00
..
array.c fs/proc/array.c: allow reporting eip/esp for all coredumping threads 2019-07-03 13:14:44 +02:00
base.c /proc/<pid>/cmdline: add back the setproctitle() special case 2019-08-04 09:30:56 +02:00
cmdline.c proc: introduce proc_create_single{,_data} 2018-05-16 07:23:35 +02:00
consoles.c proc: introduce proc_create_seq{,_data} 2018-05-16 07:23:35 +02:00
cpuinfo.c x86 / CPU: Always show current CPU frequency in /proc/cpuinfo 2017-11-15 19:46:50 +01:00
devices.c proc: introduce proc_create_seq{,_data} 2018-05-16 07:23:35 +02:00
fd.c proc: use "unsigned int" in proc_fill_cache() 2018-06-07 17:34:38 -07:00
fd.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
generic.c proc: fix /proc/net/* after setns(2) 2019-03-13 14:02:32 -07:00
inode.c proc: fixup PDE allocation bloat 2018-08-22 10:52:45 -07:00
internal.h proc: fix /proc/net/* after setns(2) 2019-03-13 14:02:32 -07:00
interrupts.c proc: introduce proc_create_seq{,_data} 2018-05-16 07:23:35 +02:00
Kconfig proc/kcore: add vmcoreinfo note to /proc/kcore 2018-08-22 10:52:46 -07:00
kcore.c x86/gart: Exclude GART aperture from kcore 2019-04-20 09:15:59 +02:00
kmsg.c vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
loadavg.c proc: introduce proc_create_single{,_data} 2018-05-16 07:23:35 +02:00
Makefile proc: : uninline name_to_int() 2017-11-17 16:10:00 -08:00
meminfo.c /proc/meminfo: add percpu populated pages count 2018-08-22 10:52:45 -07:00
namespaces.c procfs: switch instantiate_t to d_splice_alias() 2018-05-26 14:20:50 -04:00
nommu.c proc: introduce proc_create_seq{,_data} 2018-05-16 07:23:35 +02:00
page.c fs/proc/page.c: don't access uninitialized memmaps in fs/proc/page.c 2019-10-29 09:19:56 +01:00
proc_net.c proc: fix /proc/net/* after setns(2) 2019-03-13 14:02:32 -07:00
proc_sysctl.c fs/proc/proc_sysctl.c: fix the default values of i_uid/i_gid on /proc/sys inodes. 2019-07-26 09:14:24 +02:00
proc_tty.c tty: replace ->proc_fops with ->proc_show 2018-05-16 07:24:30 +02:00
root.c proc: Make inline name size calculation automatic 2018-06-15 00:48:57 -04:00
self.c proc: introduce a proc_pid_ns helper 2018-05-16 07:23:35 +02:00
softirqs.c proc: introduce proc_create_single{,_data} 2018-05-16 07:23:35 +02:00
stat.c proc: use "unsigned int" in /proc/stat hook 2018-08-22 10:52:46 -07:00
task_mmu.c mm, thp, proc: report THP eligibility for each vma 2019-12-17 20:35:45 +01:00
task_nommu.c proc: use down_read_killable mmap_sem for /proc/pid/maps 2019-07-31 07:27:09 +02:00
thread_self.c proc: introduce a proc_pid_ns helper 2018-05-16 07:23:35 +02:00
uptime.c fs/proc/uptime.c: use ktime_get_boottime_ts64 2018-08-22 10:52:45 -07:00
util.c proc: use do-while in name_to_int() 2017-11-17 16:10:00 -08:00
version.c proc: introduce proc_create_single{,_data} 2018-05-16 07:23:35 +02:00
vmcore.c proc/vmcore: Fix i386 build error of missing copy_oldmem_page_encrypted() 2019-11-24 08:20:45 +01:00