* [PATCH v3] smaps: Report PMD page size for pure PMD mappings
@ 2026-03-03 20:15 Andi Kleen
2026-03-04 17:29 ` Vlastimil Babka
0 siblings, 1 reply; 6+ messages in thread
From: Andi Kleen @ 2026-03-03 20:15 UTC (permalink / raw)
To: linux-mm; +Cc: akpm, Andi Kleen
When a smaps mapping is only PMD mappings report the
PMD page size for MMUPageSize instead of the base page size.
This is a revised version of an earlier patch that tried
to report multiple page sizes, but there were many objections
mainly centered around compatibility for mixed page size
reporting. This patch side steps all of this by
only handling the non mixed case in the simplest possible way.
It also avoids a problem introduced with v2 that page sizes
for mappings with no pages were incorrectly reported.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
fs/proc/task_mmu.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index e091931d7ca1..a5c7bc88a539 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -1371,6 +1371,7 @@ static int show_smap(struct seq_file *m, void *v)
{
struct vm_area_struct *vma = v;
struct mem_size_stats mss = {};
+ unsigned ps;
smap_gather_stats(vma, &mss, 0);
@@ -1378,7 +1379,16 @@ 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));
+ ps = vma_mmu_pagesize(vma);
+ /*
+ * When the mapping is only PMD THP report the correct page size.
+ * When multiple pages are there the user has to figure it out
+ * from other fields.
+ */
+ if (mss.shmem_thp + mss.file_thp + mss.anonymous_thp == mss.resident &&
+ mss.resident)
+ ps = HPAGE_PMD_SIZE;
+ SEQ_PUT_DEC(" kB\nMMUPageSize: ", ps);
seq_puts(m, " kB\n");
__show_smap(m, &mss, false);
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v3] smaps: Report PMD page size for pure PMD mappings
2026-03-03 20:15 [PATCH v3] smaps: Report PMD page size for pure PMD mappings Andi Kleen
@ 2026-03-04 17:29 ` Vlastimil Babka
2026-03-04 19:13 ` Andi Kleen
2026-03-04 19:20 ` David Hildenbrand (Arm)
0 siblings, 2 replies; 6+ messages in thread
From: Vlastimil Babka @ 2026-03-04 17:29 UTC (permalink / raw)
To: Andi Kleen, linux-mm; +Cc: akpm, David Hildenbrand (Arm), Lorenzo Stoakes
Why do you keep not CCing people from v1/v2 discussions? David said that
already on v2. It seems rather rude to me.
On 3/3/26 9:15 PM, Andi Kleen wrote:
> When a smaps mapping is only PMD mappings report the
> PMD page size for MMUPageSize instead of the base page size.
>
> This is a revised version of an earlier patch that tried
> to report multiple page sizes, but there were many objections
> mainly centered around compatibility for mixed page size
> reporting. This patch side steps all of this by
> only handling the non mixed case in the simplest possible way.
> It also avoids a problem introduced with v2 that page sizes
> for mappings with no pages were incorrectly reported.
>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
Will this be useful in practice or just confusing? There can be e.g.
misaligned mappings, or other reasons why there won't be 100% THP
coverage. This all or nothing value (IIUC) seems inferior to the
counters we have that say how much is pmd mapped, so I'm not really sure
it's worth changing this.
> ---
> fs/proc/task_mmu.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index e091931d7ca1..a5c7bc88a539 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -1371,6 +1371,7 @@ static int show_smap(struct seq_file *m, void *v)
> {
> struct vm_area_struct *vma = v;
> struct mem_size_stats mss = {};
> + unsigned ps;
>
> smap_gather_stats(vma, &mss, 0);
>
> @@ -1378,7 +1379,16 @@ 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));
> + ps = vma_mmu_pagesize(vma);
> + /*
> + * When the mapping is only PMD THP report the correct page size.
> + * When multiple pages are there the user has to figure it out
> + * from other fields.
> + */
> + if (mss.shmem_thp + mss.file_thp + mss.anonymous_thp == mss.resident &&
> + mss.resident)
> + ps = HPAGE_PMD_SIZE;
> + SEQ_PUT_DEC(" kB\nMMUPageSize: ", ps);
> seq_puts(m, " kB\n");
>
> __show_smap(m, &mss, false);
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v3] smaps: Report PMD page size for pure PMD mappings
2026-03-04 17:29 ` Vlastimil Babka
@ 2026-03-04 19:13 ` Andi Kleen
2026-03-04 19:20 ` David Hildenbrand (Arm)
1 sibling, 0 replies; 6+ messages in thread
From: Andi Kleen @ 2026-03-04 19:13 UTC (permalink / raw)
To: Vlastimil Babka; +Cc: linux-mm, akpm, David Hildenbrand (Arm), Lorenzo Stoakes
On Wed, Mar 04, 2026 at 06:29:09PM +0100, Vlastimil Babka wrote:
> Why do you keep not CCing people from v1/v2 discussions? David said that
> already on v2. It seems rather rude to me.
>
> On 3/3/26 9:15 PM, Andi Kleen wrote:
> > When a smaps mapping is only PMD mappings report the
> > PMD page size for MMUPageSize instead of the base page size.
> >
> > This is a revised version of an earlier patch that tried
> > to report multiple page sizes, but there were many objections
> > mainly centered around compatibility for mixed page size
> > reporting. This patch side steps all of this by
> > only handling the non mixed case in the simplest possible way.
> > It also avoids a problem introduced with v2 that page sizes
> > for mappings with no pages were incorrectly reported.
> >
> > Signed-off-by: Andi Kleen <ak@linux.intel.com>
>
> Will this be useful in practice or just confusing? There can be e.g.
It might have saved me some wasted time.
I found the current situation confusing!
> misaligned mappings, or other reasons why there won't be 100% THP
> coverage. This all or nothing value (IIUC) seems inferior to the
s/nothing/4K like what's there today/
Yes probably multiple page sizes would be better, but I'm not reopening
that discussion now.
> counters we have that say how much is pmd mapped, so I'm not really sure
> it's worth changing this.
The other counters still exist of course.
I don't see how there can be confusion if we report the correct page
size if the mapping is only that page size vs a page size that is not
used at all.
-Andi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] smaps: Report PMD page size for pure PMD mappings
2026-03-04 17:29 ` Vlastimil Babka
2026-03-04 19:13 ` Andi Kleen
@ 2026-03-04 19:20 ` David Hildenbrand (Arm)
2026-03-05 10:33 ` Lorenzo Stoakes (Oracle)
1 sibling, 1 reply; 6+ messages in thread
From: David Hildenbrand (Arm) @ 2026-03-04 19:20 UTC (permalink / raw)
To: Vlastimil Babka, Andi Kleen, linux-mm; +Cc: akpm, Lorenzo Stoakes
On 3/4/26 18:29, Vlastimil Babka wrote:
> Why do you keep not CCing people from v1/v2 discussions? David said that
> already on v2. It seems rather rude to me.
>
> On 3/3/26 9:15 PM, Andi Kleen wrote:
>> When a smaps mapping is only PMD mappings report the
>> PMD page size for MMUPageSize instead of the base page size.
>>
>> This is a revised version of an earlier patch that tried
>> to report multiple page sizes, but there were many objections
>> mainly centered around compatibility for mixed page size
>> reporting. This patch side steps all of this by
>> only handling the non mixed case in the simplest possible way.
>> It also avoids a problem introduced with v2 that page sizes
>> for mappings with no pages were incorrectly reported.
>>
>> Signed-off-by: Andi Kleen <ak@linux.intel.com>
>
> Will this be useful in practice or just confusing? There can be e.g.
> misaligned mappings, or other reasons why there won't be 100% THP
> coverage. This all or nothing value (IIUC) seems inferior to the
> counters we have that say how much is pmd mapped, so I'm not really sure
> it's worth changing this.
My opinion on this remains unchanged.
Not CCing me once more is questionable and makes me want to recommend
Andi to work on different parts of the kernel.
I sent a doc update to clarify this. Won't make everybody happy, but we
can't turn back time.
--
Cheers,
David
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] smaps: Report PMD page size for pure PMD mappings
2026-03-04 19:20 ` David Hildenbrand (Arm)
@ 2026-03-05 10:33 ` Lorenzo Stoakes (Oracle)
0 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Stoakes (Oracle) @ 2026-03-05 10:33 UTC (permalink / raw)
To: David Hildenbrand (Arm)
Cc: Vlastimil Babka, Andi Kleen, linux-mm, akpm, Lorenzo Stoakes
On Wed, Mar 04, 2026 at 08:20:38PM +0100, David Hildenbrand (Arm) wrote:
> On 3/4/26 18:29, Vlastimil Babka wrote:
> > Why do you keep not CCing people from v1/v2 discussions? David said that
> > already on v2. It seems rather rude to me.
> >
> > On 3/3/26 9:15 PM, Andi Kleen wrote:
> >> When a smaps mapping is only PMD mappings report the
> >> PMD page size for MMUPageSize instead of the base page size.
> >>
> >> This is a revised version of an earlier patch that tried
> >> to report multiple page sizes, but there were many objections
> >> mainly centered around compatibility for mixed page size
> >> reporting. This patch side steps all of this by
> >> only handling the non mixed case in the simplest possible way.
> >> It also avoids a problem introduced with v2 that page sizes
> >> for mappings with no pages were incorrectly reported.
> >>
> >> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> >
> > Will this be useful in practice or just confusing? There can be e.g.
> > misaligned mappings, or other reasons why there won't be 100% THP
> > coverage. This all or nothing value (IIUC) seems inferior to the
> > counters we have that say how much is pmd mapped, so I'm not really sure
> > it's worth changing this.
>
> My opinion on this remains unchanged.
Mine also.
>
> Not CCing me once more is questionable and makes me want to recommend
> Andi to work on different parts of the kernel.
Andi - I'm genuinely concerned that you're doing this on purpose here -
especially since you ignored that part of Vlastimil's reply and ignored
previous feedback about failing to cc- on more than one occasion.
Responding to negative technical feedback by being rude and dismissive then
(seemingly) intentionally trying to circumvent the review by failing to cc-
those who commented is completely unacceptable.
Sadly I have to join David in suggesting you find other parts of the kernel
to work on.
>
> I sent a doc update to clarify this. Won't make everybody happy, but we
> can't turn back time.
Thanks, will take a look!
>
> --
> Cheers,
>
> David
>
Cheers, Lorenzo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] smaps: Report PMD page size for pure PMD mappings
@ 2026-03-04 6:52 kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2026-03-04 6:52 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: <20260303201556.107960-1-ak@linux.intel.com>
References: <20260303201556.107960-1-ak@linux.intel.com>
TO: Andi Kleen <ak@linux.intel.com>
TO: linux-mm@kvack.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 akpm-mm/mm-everything linus/master v7.0-rc2 next-20260303]
[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-PMD-page-size-for-pure-PMD-mappings/20260304-041922
base: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.all
patch link: https://lore.kernel.org/r/20260303201556.107960-1-ak%40linux.intel.com
patch subject: [PATCH v3] smaps: Report PMD page size for pure PMD mappings
:::::: branch date: 10 hours ago
:::::: commit date: 10 hours ago
config: hexagon-allnoconfig (https://download.01.org/0day-ci/archive/20260304/202603041448.j9gaSbUi-lkp@intel.com/config)
compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project 9a109fbb6e184ec9bcce10615949f598f4c974a9)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260304/202603041448.j9gaSbUi-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/202603041448.j9gaSbUi-lkp@intel.com/
All errors (new ones prefixed by >>):
>> fs/proc/task_mmu.c:1390:8: error: call to '__compiletime_assert_405' declared with 'error' attribute: BUILD_BUG failed
1390 | 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:694:2: note: expanded from macro '_compiletime_assert'
694 | __compiletime_assert(condition, msg, prefix, suffix)
| ^
include/linux/compiler_types.h:687:4: note: expanded from macro '__compiletime_assert'
687 | prefix ## suffix(); \
| ^
<scratch space>:79:1: note: expanded from here
79 | __compiletime_assert_405
| ^
1 error generated.
vim +1390 fs/proc/task_mmu.c
f1547959d9efd0 Vlastimil Babka 2018-08-21 1369
8e68d689afe328 Vlastimil Babka 2018-08-21 1370 static int show_smap(struct seq_file *m, void *v)
8e68d689afe328 Vlastimil Babka 2018-08-21 1371 {
8e68d689afe328 Vlastimil Babka 2018-08-21 1372 struct vm_area_struct *vma = v;
860a2e7fa4a186 Alexey Dobriyan 2023-09-29 1373 struct mem_size_stats mss = {};
9378536cc887d4 Andi Kleen 2026-03-03 1374 unsigned ps;
8e68d689afe328 Vlastimil Babka 2018-08-21 1375
03b4b1149308b0 Chinwen Chang 2020-10-13 1376 smap_gather_stats(vma, &mss, 0);
4752c369789250 Matt Mackall 2008-02-04 1377
871305bb202808 Vlastimil Babka 2018-08-21 1378 show_map_vma(m, vma);
4752c369789250 Matt Mackall 2008-02-04 1379
d1be35cb6f9697 Andrei Vagin 2018-04-10 1380 SEQ_PUT_DEC("Size: ", vma->vm_end - vma->vm_start);
d1be35cb6f9697 Andrei Vagin 2018-04-10 1381 SEQ_PUT_DEC(" kB\nKernelPageSize: ", vma_kernel_pagesize(vma));
9378536cc887d4 Andi Kleen 2026-03-03 1382 ps = vma_mmu_pagesize(vma);
9378536cc887d4 Andi Kleen 2026-03-03 1383 /*
9378536cc887d4 Andi Kleen 2026-03-03 1384 * When the mapping is only PMD THP report the correct page size.
9378536cc887d4 Andi Kleen 2026-03-03 1385 * When multiple pages are there the user has to figure it out
9378536cc887d4 Andi Kleen 2026-03-03 1386 * from other fields.
9378536cc887d4 Andi Kleen 2026-03-03 1387 */
9378536cc887d4 Andi Kleen 2026-03-03 1388 if (mss.shmem_thp + mss.file_thp + mss.anonymous_thp == mss.resident &&
9378536cc887d4 Andi Kleen 2026-03-03 1389 mss.resident)
9378536cc887d4 Andi Kleen 2026-03-03 @1390 ps = HPAGE_PMD_SIZE;
9378536cc887d4 Andi Kleen 2026-03-03 1391 SEQ_PUT_DEC(" kB\nMMUPageSize: ", ps);
d1be35cb6f9697 Andrei Vagin 2018-04-10 1392 seq_puts(m, " kB\n");
d1be35cb6f9697 Andrei Vagin 2018-04-10 1393
ee2ad71b0756e9 Luigi Semenzato 2019-07-11 1394 __show_smap(m, &mss, false);
f1547959d9efd0 Vlastimil Babka 2018-08-21 1395
daa60ae64c6587 Hugh Dickins 2023-08-14 1396 seq_printf(m, "THPeligible: %8u\n",
1f1c061089dcd2 David Hildenbrand 2025-08-15 1397 !!thp_vma_allowable_orders(vma, vma->vm_flags, TVA_SMAPS,
1f1c061089dcd2 David Hildenbrand 2025-08-15 1398 THP_ORDERS_ALL));
7635d9cbe8327e Michal Hocko 2018-12-28 1399
27cca866e3fce0 Ram Pai 2018-04-13 1400 if (arch_pkeys_enabled())
27cca866e3fce0 Ram Pai 2018-04-13 1401 seq_printf(m, "ProtectionKey: %8u\n", vma_pkey(vma));
834f82e2aa9a8e Cyrill Gorcunov 2012-12-17 1402 show_smap_vma_flags(m, vma);
258f669e7e88c1 Vlastimil Babka 2018-08-21 1403
258f669e7e88c1 Vlastimil Babka 2018-08-21 1404 return 0;
258f669e7e88c1 Vlastimil Babka 2018-08-21 1405 }
258f669e7e88c1 Vlastimil Babka 2018-08-21 1406
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-03-05 10:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-03 20:15 [PATCH v3] smaps: Report PMD page size for pure PMD mappings Andi Kleen
2026-03-04 17:29 ` Vlastimil Babka
2026-03-04 19:13 ` Andi Kleen
2026-03-04 19:20 ` David Hildenbrand (Arm)
2026-03-05 10:33 ` Lorenzo Stoakes (Oracle)
-- strict thread matches above, loose matches on Subject: below --
2026-03-04 6:52 kernel test robot
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.