linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [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; 2+ 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	[flat|nested] 2+ 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
  0 siblings, 0 replies; 2+ 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] 2+ messages in thread

end of thread, other threads:[~2026-03-04 17:29 UTC | newest]

Thread overview: 2+ 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox