All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] smaps: Report correct page sizes with THP
@ 2026-02-09 20:17 Andi Kleen
  2026-02-12 12:42 ` David Hildenbrand (Arm)
  2026-02-21  0:03 ` jane.chu
  0 siblings, 2 replies; 10+ messages in thread
From: Andi Kleen @ 2026-02-09 20:17 UTC (permalink / raw)
  To: linux-mm; +Cc: linux-fsdevel, akpm, willy, Andi Kleen

Recently I wasted quite some time debugging why THP didn't work, when it
was just smaps always reporting the base page size. It has separate
counts for (non m) THP, but using them is not always obvious. For
standard THP the page sizes can be actually derived from the existing
counts, so do just do that. I left KernelPageSize alone.
The mixed page size case is reported with a new MMUPageSize2 item.
This doesn't do anything about mTHP reporting, but even the basic
smaps is not aware of it so far.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 Documentation/filesystems/proc.rst |  2 +-
 fs/proc/task_mmu.c                 | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst
index 8256e857e2d7..7c776046d15a 100644
--- a/Documentation/filesystems/proc.rst
+++ b/Documentation/filesystems/proc.rst
@@ -483,7 +483,7 @@ entries; the page size used by the MMU when backing a VMA (in most cases,
 the same as KernelPageSize); the amount of the mapping that is currently
 resident in RAM (RSS); the process's proportional share of this mapping
 (PSS); and the number of clean and dirty shared and private pages in the
-mapping.
+mapping. If the mapping has multiple page size there might be a MMUPageSize2.
 
 The "proportional set size" (PSS) of a process is the count of pages it has
 in memory, where each page is divided by the number of processes sharing it.
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 26188a4ad1ab..9123e59dcf4c 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -1377,7 +1377,19 @@ static int show_smap(struct seq_file *m, void *v)
 
 	SEQ_PUT_DEC("Size:           ", vma->vm_end - vma->vm_start);
 	SEQ_PUT_DEC(" kB\nKernelPageSize: ", vma_kernel_pagesize(vma));
-	SEQ_PUT_DEC(" kB\nMMUPageSize:    ", vma_mmu_pagesize(vma));
+
+	/* Only THP? */
+	if (mss.shmem_thp + mss.file_thp + mss.anonymous_thp == mss.resident &&
+	    mss.resident > 0) {
+		SEQ_PUT_DEC(" kB\nMMUPageSize:    ", HPAGE_PMD_SIZE);
+	} else {
+		unsigned ps = vma_mmu_pagesize(vma);
+		/* Will need adjustments when more THP page sizes are added. */
+		SEQ_PUT_DEC(" kB\nMMUPageSize:    ", ps);
+		if (mss.shmem_thp + mss.file_thp + mss.anonymous_thp > 0 &&
+		    ps != HPAGE_PMD_SIZE)
+			SEQ_PUT_DEC(" kB\nMMUPageSize2:   ", HPAGE_PMD_SIZE);
+	}
 	seq_puts(m, " kB\n");
 
 	__show_smap(m, &mss, false);
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread
* Re: [PATCH] smaps: Report correct page sizes with THP
@ 2026-02-11  2:59 kernel test robot
  0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2026-02-11  2:59 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp

:::::: 
:::::: Manual check reason: "__compiletime_assert_NNN"
:::::: 

BCC: lkp@intel.com
CC: llvm@lists.linux.dev
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20260209201731.231667-1-ak@linux.intel.com>
References: <20260209201731.231667-1-ak@linux.intel.com>
TO: Andi Kleen <ak@linux.intel.com>
TO: linux-mm@kvack.org
CC: linux-fsdevel@vger.kernel.org
CC: akpm@linux-foundation.org
CC: willy@infradead.org
CC: Andi Kleen <ak@linux.intel.com>

Hi Andi,

kernel test robot noticed the following build errors:

[auto build test ERROR on brauner-vfs/vfs.all]
[also build test ERROR on linus/master v6.19 next-20260210]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andi-Kleen/smaps-Report-correct-page-sizes-with-THP/20260210-042028
base:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.all
patch link:    https://lore.kernel.org/r/20260209201731.231667-1-ak%40linux.intel.com
patch subject: [PATCH] smaps: Report correct page sizes with THP
:::::: branch date: 31 hours ago
:::::: commit date: 31 hours ago
config: x86_64-randconfig-015-20260210 (https://download.01.org/0day-ci/archive/20260211/202602111045.T7U5qnHV-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260211/202602111045.T7U5qnHV-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202602111045.T7U5qnHV-lkp@intel.com/

All errors (new ones prefixed by >>):

>> fs/proc/task_mmu.c:1372:40: error: call to '__compiletime_assert_1237' declared with 'error' attribute: BUILD_BUG failed
    1372 |                 SEQ_PUT_DEC(" kB\nMMUPageSize:    ", HPAGE_PMD_SIZE);
         |                                                      ^
   include/linux/huge_mm.h:120:34: note: expanded from macro 'HPAGE_PMD_SIZE'
     120 | #define HPAGE_PMD_SIZE  ((1UL) << HPAGE_PMD_SHIFT)
         |                                   ^
   include/linux/huge_mm.h:113:28: note: expanded from macro 'HPAGE_PMD_SHIFT'
     113 | #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
         |                            ^
   include/linux/build_bug.h:59:21: note: expanded from macro 'BUILD_BUG'
      59 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
         |                     ^
   note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:619:2: note: expanded from macro '_compiletime_assert'
     619 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:612:4: note: expanded from macro '__compiletime_assert'
     612 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:288:1: note: expanded from here
     288 | __compiletime_assert_1237
         | ^
   fs/proc/task_mmu.c:1378:13: error: call to '__compiletime_assert_1238' declared with 'error' attribute: BUILD_BUG failed
    1378 |                     ps != HPAGE_PMD_SIZE)
         |                           ^
   include/linux/huge_mm.h:120:34: note: expanded from macro 'HPAGE_PMD_SIZE'
     120 | #define HPAGE_PMD_SIZE  ((1UL) << HPAGE_PMD_SHIFT)
         |                                   ^
   include/linux/huge_mm.h:113:28: note: expanded from macro 'HPAGE_PMD_SHIFT'
     113 | #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
         |                            ^
   include/linux/build_bug.h:59:21: note: expanded from macro 'BUILD_BUG'
      59 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
         |                     ^
   note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:619:2: note: expanded from macro '_compiletime_assert'
     619 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:612:4: note: expanded from macro '__compiletime_assert'
     612 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:2:1: note: expanded from here
       2 | __compiletime_assert_1238
         | ^
   2 errors generated.


vim +1372 fs/proc/task_mmu.c

f1547959d9efd0 Vlastimil Babka   2018-08-21  1356  
8e68d689afe328 Vlastimil Babka   2018-08-21  1357  static int show_smap(struct seq_file *m, void *v)
8e68d689afe328 Vlastimil Babka   2018-08-21  1358  {
8e68d689afe328 Vlastimil Babka   2018-08-21  1359  	struct vm_area_struct *vma = v;
860a2e7fa4a186 Alexey Dobriyan   2023-09-29  1360  	struct mem_size_stats mss = {};
8e68d689afe328 Vlastimil Babka   2018-08-21  1361  
03b4b1149308b0 Chinwen Chang     2020-10-13  1362  	smap_gather_stats(vma, &mss, 0);
4752c369789250 Matt Mackall      2008-02-04  1363  
871305bb202808 Vlastimil Babka   2018-08-21  1364  	show_map_vma(m, vma);
4752c369789250 Matt Mackall      2008-02-04  1365  
d1be35cb6f9697 Andrei Vagin      2018-04-10  1366  	SEQ_PUT_DEC("Size:           ", vma->vm_end - vma->vm_start);
d1be35cb6f9697 Andrei Vagin      2018-04-10  1367  	SEQ_PUT_DEC(" kB\nKernelPageSize: ", vma_kernel_pagesize(vma));
f9a5299667dd92 Andi Kleen        2026-02-09  1368  
f9a5299667dd92 Andi Kleen        2026-02-09  1369  	/* Only THP? */
f9a5299667dd92 Andi Kleen        2026-02-09  1370  	if (mss.shmem_thp + mss.file_thp + mss.anonymous_thp == mss.resident &&
f9a5299667dd92 Andi Kleen        2026-02-09  1371  	    mss.resident > 0) {
f9a5299667dd92 Andi Kleen        2026-02-09 @1372  		SEQ_PUT_DEC(" kB\nMMUPageSize:    ", HPAGE_PMD_SIZE);
f9a5299667dd92 Andi Kleen        2026-02-09  1373  	} else {
f9a5299667dd92 Andi Kleen        2026-02-09  1374  		unsigned ps = vma_mmu_pagesize(vma);
f9a5299667dd92 Andi Kleen        2026-02-09  1375  		/* Will need adjustments when more THP page sizes are added. */
f9a5299667dd92 Andi Kleen        2026-02-09  1376  		SEQ_PUT_DEC(" kB\nMMUPageSize:    ", ps);
f9a5299667dd92 Andi Kleen        2026-02-09  1377  		if (mss.shmem_thp + mss.file_thp + mss.anonymous_thp > 0 &&
f9a5299667dd92 Andi Kleen        2026-02-09  1378  		    ps != HPAGE_PMD_SIZE)
f9a5299667dd92 Andi Kleen        2026-02-09  1379  			SEQ_PUT_DEC(" kB\nMMUPageSize2:   ", HPAGE_PMD_SIZE);
f9a5299667dd92 Andi Kleen        2026-02-09  1380  	}
d1be35cb6f9697 Andrei Vagin      2018-04-10  1381  	seq_puts(m, " kB\n");
d1be35cb6f9697 Andrei Vagin      2018-04-10  1382  
ee2ad71b0756e9 Luigi Semenzato   2019-07-11  1383  	__show_smap(m, &mss, false);
f1547959d9efd0 Vlastimil Babka   2018-08-21  1384  
daa60ae64c6587 Hugh Dickins      2023-08-14  1385  	seq_printf(m, "THPeligible:    %8u\n",
1f1c061089dcd2 David Hildenbrand 2025-08-15  1386  		   !!thp_vma_allowable_orders(vma, vma->vm_flags, TVA_SMAPS,
1f1c061089dcd2 David Hildenbrand 2025-08-15  1387  					      THP_ORDERS_ALL));
7635d9cbe8327e Michal Hocko      2018-12-28  1388  
27cca866e3fce0 Ram Pai           2018-04-13  1389  	if (arch_pkeys_enabled())
27cca866e3fce0 Ram Pai           2018-04-13  1390  		seq_printf(m, "ProtectionKey:  %8u\n", vma_pkey(vma));
834f82e2aa9a8e Cyrill Gorcunov   2012-12-17  1391  	show_smap_vma_flags(m, vma);
258f669e7e88c1 Vlastimil Babka   2018-08-21  1392  
258f669e7e88c1 Vlastimil Babka   2018-08-21  1393  	return 0;
258f669e7e88c1 Vlastimil Babka   2018-08-21  1394  }
258f669e7e88c1 Vlastimil Babka   2018-08-21  1395  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: [PATCH] smaps: Report correct page sizes with THP
@ 2026-02-09 21:31 kernel test robot
  0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2026-02-09 21:31 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp

:::::: 
:::::: Manual check reason: "__compiletime_assert_NNN"
:::::: 

BCC: lkp@intel.com
CC: llvm@lists.linux.dev
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20260209193223.230797-1-ak@linux.intel.com>
References: <20260209193223.230797-1-ak@linux.intel.com>
TO: Andi Kleen <ak@linux.intel.com>
TO: linux-mm@vger.kernel.org
CC: linux-fsdevel@vger.kernel.org
CC: akpm@linux-foundation.org
CC: Andi Kleen <ak@linux.intel.com>

Hi Andi,

kernel test robot noticed the following build errors:

[auto build test ERROR on brauner-vfs/vfs.all]
[also build test ERROR on linus/master v6.19 next-20260209]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andi-Kleen/smaps-Report-correct-page-sizes-with-THP/20260210-033439
base:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.all
patch link:    https://lore.kernel.org/r/20260209193223.230797-1-ak%40linux.intel.com
patch subject: [PATCH] smaps: Report correct page sizes with THP
:::::: branch date: 2 hours ago
:::::: commit date: 2 hours ago
config: x86_64-allnoconfig (https://download.01.org/0day-ci/archive/20260210/202602100541.T3O4ksDH-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260210/202602100541.T3O4ksDH-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202602100541.T3O4ksDH-lkp@intel.com/

All errors (new ones prefixed by >>):

>> fs/proc/task_mmu.c:1378:13: error: call to '__compiletime_assert_426' declared with 'error' attribute: BUILD_BUG failed
    1378 |                     ps != HPAGE_PMD_SIZE)
         |                           ^
   include/linux/huge_mm.h:120:34: note: expanded from macro 'HPAGE_PMD_SIZE'
     120 | #define HPAGE_PMD_SIZE  ((1UL) << HPAGE_PMD_SHIFT)
         |                                   ^
   include/linux/huge_mm.h:113:28: note: expanded from macro 'HPAGE_PMD_SHIFT'
     113 | #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
         |                            ^
   include/linux/build_bug.h:59:21: note: expanded from macro 'BUILD_BUG'
      59 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
         |                     ^
   note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:619:2: note: expanded from macro '_compiletime_assert'
     619 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:612:4: note: expanded from macro '__compiletime_assert'
     612 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:129:1: note: expanded from here
     129 | __compiletime_assert_426
         | ^
   fs/proc/task_mmu.c:1372:40: error: call to '__compiletime_assert_425' declared with 'error' attribute: BUILD_BUG failed
    1372 |                 SEQ_PUT_DEC(" kB\nMMUPageSize:    ", HPAGE_PMD_SIZE);
         |                                                      ^
   include/linux/huge_mm.h:120:34: note: expanded from macro 'HPAGE_PMD_SIZE'
     120 | #define HPAGE_PMD_SIZE  ((1UL) << HPAGE_PMD_SHIFT)
         |                                   ^
   include/linux/huge_mm.h:113:28: note: expanded from macro 'HPAGE_PMD_SHIFT'
     113 | #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
         |                            ^
   include/linux/build_bug.h:59:21: note: expanded from macro 'BUILD_BUG'
      59 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
         |                     ^
   note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:619:2: note: expanded from macro '_compiletime_assert'
     619 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:612:4: note: expanded from macro '__compiletime_assert'
     612 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:126:1: note: expanded from here
     126 | __compiletime_assert_425
         | ^
   2 errors generated.


vim +1378 fs/proc/task_mmu.c

f1547959d9efd0 Vlastimil Babka   2018-08-21  1356  
8e68d689afe328 Vlastimil Babka   2018-08-21  1357  static int show_smap(struct seq_file *m, void *v)
8e68d689afe328 Vlastimil Babka   2018-08-21  1358  {
8e68d689afe328 Vlastimil Babka   2018-08-21  1359  	struct vm_area_struct *vma = v;
860a2e7fa4a186 Alexey Dobriyan   2023-09-29  1360  	struct mem_size_stats mss = {};
8e68d689afe328 Vlastimil Babka   2018-08-21  1361  
03b4b1149308b0 Chinwen Chang     2020-10-13  1362  	smap_gather_stats(vma, &mss, 0);
4752c369789250 Matt Mackall      2008-02-04  1363  
871305bb202808 Vlastimil Babka   2018-08-21  1364  	show_map_vma(m, vma);
4752c369789250 Matt Mackall      2008-02-04  1365  
d1be35cb6f9697 Andrei Vagin      2018-04-10  1366  	SEQ_PUT_DEC("Size:           ", vma->vm_end - vma->vm_start);
d1be35cb6f9697 Andrei Vagin      2018-04-10  1367  	SEQ_PUT_DEC(" kB\nKernelPageSize: ", vma_kernel_pagesize(vma));
37b1c872e41df4 Andi Kleen        2026-02-09  1368  
37b1c872e41df4 Andi Kleen        2026-02-09  1369  	/* Only THP? */
37b1c872e41df4 Andi Kleen        2026-02-09  1370  	if (mss.shmem_thp + mss.file_thp + mss.anonymous_thp == mss.resident &&
37b1c872e41df4 Andi Kleen        2026-02-09  1371  	    mss.resident > 0) {
37b1c872e41df4 Andi Kleen        2026-02-09  1372  		SEQ_PUT_DEC(" kB\nMMUPageSize:    ", HPAGE_PMD_SIZE);
37b1c872e41df4 Andi Kleen        2026-02-09  1373  	} else {
37b1c872e41df4 Andi Kleen        2026-02-09  1374  		unsigned ps = vma_mmu_pagesize(vma);
37b1c872e41df4 Andi Kleen        2026-02-09  1375  		/* Will need adjustments when more THP page sizes are added. */
37b1c872e41df4 Andi Kleen        2026-02-09  1376  		SEQ_PUT_DEC(" kB\nMMUPageSize:    ", ps);
37b1c872e41df4 Andi Kleen        2026-02-09  1377  		if (mss.shmem_thp + mss.file_thp + mss.anonymous_thp > 0 &&
37b1c872e41df4 Andi Kleen        2026-02-09 @1378  		    ps != HPAGE_PMD_SIZE)
37b1c872e41df4 Andi Kleen        2026-02-09  1379  			SEQ_PUT_DEC(" kB\nMMUPageSize2:   ", HPAGE_PMD_SIZE);
37b1c872e41df4 Andi Kleen        2026-02-09  1380  	}
d1be35cb6f9697 Andrei Vagin      2018-04-10  1381  	seq_puts(m, " kB\n");
d1be35cb6f9697 Andrei Vagin      2018-04-10  1382  
ee2ad71b0756e9 Luigi Semenzato   2019-07-11  1383  	__show_smap(m, &mss, false);
f1547959d9efd0 Vlastimil Babka   2018-08-21  1384  
daa60ae64c6587 Hugh Dickins      2023-08-14  1385  	seq_printf(m, "THPeligible:    %8u\n",
1f1c061089dcd2 David Hildenbrand 2025-08-15  1386  		   !!thp_vma_allowable_orders(vma, vma->vm_flags, TVA_SMAPS,
1f1c061089dcd2 David Hildenbrand 2025-08-15  1387  					      THP_ORDERS_ALL));
7635d9cbe8327e Michal Hocko      2018-12-28  1388  
27cca866e3fce0 Ram Pai           2018-04-13  1389  	if (arch_pkeys_enabled())
27cca866e3fce0 Ram Pai           2018-04-13  1390  		seq_printf(m, "ProtectionKey:  %8u\n", vma_pkey(vma));
834f82e2aa9a8e Cyrill Gorcunov   2012-12-17  1391  	show_smap_vma_flags(m, vma);
258f669e7e88c1 Vlastimil Babka   2018-08-21  1392  
258f669e7e88c1 Vlastimil Babka   2018-08-21  1393  	return 0;
258f669e7e88c1 Vlastimil Babka   2018-08-21  1394  }
258f669e7e88c1 Vlastimil Babka   2018-08-21  1395  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [PATCH] smaps: Report correct page sizes with THP
@ 2026-02-09 19:32 Andi Kleen
  2026-02-09 20:04 ` Matthew Wilcox
  0 siblings, 1 reply; 10+ messages in thread
From: Andi Kleen @ 2026-02-09 19:32 UTC (permalink / raw)
  To: linux-mm; +Cc: linux-fsdevel, akpm, Andi Kleen

Recently I wasted quite some time debugging why THP didn't work, when it
was just smaps always reporting the base page size. It has separate
counts for (non m) THP, but using them is not always obvious. For
standard THP the page sizes can be actually derived from the existing
counts, so do just do that. I left KernelPageSize alone.
The mixed page size case is reported with a new MMUPageSize2 item.
This doesn't do anything about mTHP reporting, but even the basic
smaps is not aware of it so far.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 Documentation/filesystems/proc.rst |  2 +-
 fs/proc/task_mmu.c                 | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst
index 8256e857e2d7..7c776046d15a 100644
--- a/Documentation/filesystems/proc.rst
+++ b/Documentation/filesystems/proc.rst
@@ -483,7 +483,7 @@ entries; the page size used by the MMU when backing a VMA (in most cases,
 the same as KernelPageSize); the amount of the mapping that is currently
 resident in RAM (RSS); the process's proportional share of this mapping
 (PSS); and the number of clean and dirty shared and private pages in the
-mapping.
+mapping. If the mapping has multiple page size there might be a MMUPageSize2.
 
 The "proportional set size" (PSS) of a process is the count of pages it has
 in memory, where each page is divided by the number of processes sharing it.
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 26188a4ad1ab..9123e59dcf4c 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -1377,7 +1377,19 @@ static int show_smap(struct seq_file *m, void *v)
 
 	SEQ_PUT_DEC("Size:           ", vma->vm_end - vma->vm_start);
 	SEQ_PUT_DEC(" kB\nKernelPageSize: ", vma_kernel_pagesize(vma));
-	SEQ_PUT_DEC(" kB\nMMUPageSize:    ", vma_mmu_pagesize(vma));
+
+	/* Only THP? */
+	if (mss.shmem_thp + mss.file_thp + mss.anonymous_thp == mss.resident &&
+	    mss.resident > 0) {
+		SEQ_PUT_DEC(" kB\nMMUPageSize:    ", HPAGE_PMD_SIZE);
+	} else {
+		unsigned ps = vma_mmu_pagesize(vma);
+		/* Will need adjustments when more THP page sizes are added. */
+		SEQ_PUT_DEC(" kB\nMMUPageSize:    ", ps);
+		if (mss.shmem_thp + mss.file_thp + mss.anonymous_thp > 0 &&
+		    ps != HPAGE_PMD_SIZE)
+			SEQ_PUT_DEC(" kB\nMMUPageSize2:   ", HPAGE_PMD_SIZE);
+	}
 	seq_puts(m, " kB\n");
 
 	__show_smap(m, &mss, false);
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-02-21  0:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-09 20:17 [PATCH] smaps: Report correct page sizes with THP Andi Kleen
2026-02-12 12:42 ` David Hildenbrand (Arm)
2026-02-12 17:58   ` Andi Kleen
2026-02-12 18:05     ` David Hildenbrand (Arm)
2026-02-21  0:03 ` jane.chu
  -- strict thread matches above, loose matches on Subject: below --
2026-02-11  2:59 kernel test robot
2026-02-09 21:31 kernel test robot
2026-02-09 19:32 Andi Kleen
2026-02-09 20:04 ` Matthew Wilcox
2026-02-09 20:10   ` Andi Kleen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.