From: Andi Kleen <ak@linux.intel.com>
To: linux-mm@kvack.org
Cc: akpm@linux-foundation.org, Andi Kleen <ak@linux.intel.com>
Subject: [PATCH v3] smaps: Report PMD page size for pure PMD mappings
Date: Tue, 3 Mar 2026 12:15:56 -0800 [thread overview]
Message-ID: <20260303201556.107960-1-ak@linux.intel.com> (raw)
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
reply other threads:[~2026-03-03 20:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260303201556.107960-1-ak@linux.intel.com \
--to=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox