Add PMDMappable field to smaps output which informs the user if memory in the VMA can be PMD-mapped by MADV_COLLAPSE. The distinction from THPeligible is needed for two reasons: 1) For THP, MADV_COLLAPSE is not coupled to THP sysfs controls, which THPeligible reports. 2) PMDMappable can also be used in HugeTLB fine-granularity mappings, which are independent from THP. Signed-off-by: Zach O'Keefe <zokeefe@xxxxxxxxxx> --- Documentation/filesystems/proc.rst | 10 ++++++++-- fs/proc/task_mmu.c | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst index 47e95dbc820d..f207903a57a5 100644 --- a/Documentation/filesystems/proc.rst +++ b/Documentation/filesystems/proc.rst @@ -466,6 +466,7 @@ Memory Area, or VMA) there is a series of lines such as the following:: MMUPageSize: 4 kB Locked: 0 kB THPeligible: 0 + PMDMappable: 0 VmFlags: rd ex mr mw me dw The first of these lines shows the same information as is displayed for the @@ -518,9 +519,14 @@ replaced by copy-on-write) part of the underlying shmem object out on swap. does not take into account swapped out page of underlying shmem objects. "Locked" indicates whether the mapping is locked in memory or not. +"PMDMappable" indicates if the memory can be mapped by PMDs - 1 if true, 0 +otherwise. It just shows the current status. Note that this is memory +operable on explicitly by MADV_COLLAPSE. + "THPeligible" indicates whether the mapping is eligible for allocating THP -pages as well as the THP is PMD mappable or not - 1 if true, 0 otherwise. -It just shows the current status. +pages by the kernel, as well as the THP is PMD mappable or not - 1 if true, 0 +otherwise. It just shows the current status. Note this is memory the kernel can +transparently provide as THPs. "VmFlags" field deserves a separate description. This member represents the kernel flags associated with the particular virtual memory area in two letter diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index f8cd58846a28..29f2089456ba 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -867,6 +867,8 @@ static int show_smap(struct seq_file *m, void *v) seq_printf(m, "THPeligible: %d\n", hugepage_vma_check(vma, vma->vm_flags, true, false, true)); + seq_printf(m, "PMDMappable: %d\n", + hugepage_vma_check(vma, vma->vm_flags, true, false, false)); if (arch_pkeys_enabled()) seq_printf(m, "ProtectionKey: %8u\n", vma_pkey(vma)); -- 2.37.0.rc0.161.g10f37bed90-goog