From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Andi Kleen <ak@linux.intel.com>, linux-mm@kvack.org
Cc: linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org,
willy@infradead.org
Subject: Re: [PATCH] smaps: Report correct page sizes with THP
Date: Thu, 12 Feb 2026 13:42:36 +0100 [thread overview]
Message-ID: <94a21bda-5677-4949-a1df-3f0d90348021@kernel.org> (raw)
In-Reply-To: <20260209201731.231667-1-ak@linux.intel.com>
On 2/9/26 21:17, Andi Kleen wrote:
> 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);
We have AnonHugePages:, ShmemPmdMapped: and FilePmdMapped: that tell you
exactly what you want to know.
Especially the mixed thing is just nasty.
Once we go into cont-pte territory (or automatic pte coalescing by
hardware) it all gets confusing.
Sorry, NAK.
--
Cheers,
David
next prev parent reply other threads:[~2026-02-12 12:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-09 20:17 Andi Kleen
2026-02-12 12:42 ` David Hildenbrand (Arm) [this message]
2026-02-12 17:58 ` Andi Kleen
2026-02-12 18:05 ` David Hildenbrand (Arm)
2026-02-21 0:03 ` jane.chu
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=94a21bda-5677-4949-a1df-3f0d90348021@kernel.org \
--to=david@kernel.org \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.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