From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Andi Kleen <ak@linux.intel.com>
Cc: linux-mm@kvack.org, akpm@linux-foundation.org,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Subject: Re: [PATCH v2] smaps: Report correct page sizes with THP
Date: Mon, 2 Mar 2026 22:05:23 +0100 [thread overview]
Message-ID: <4a08a249-211b-40b9-b6bd-7c54af2b9d15@kernel.org> (raw)
In-Reply-To: <aaX2B9Efh0dBed6c@tassilo>
On 3/2/26 21:41, Andi Kleen wrote:
>> Especially after reading 3340289ddf29ca75c3acfb3a6b72f234b2f74d5c I
>> ended up with he following conclusion:
>>
>> "KernelPageSize" tells you in which granularity we can mmap()/munmap()
>> etc. Simple.
>>
>> "MMUPageSize" tells us how this granularity is implemented (or emulated)
>> under the hood.
>>
>> The case we care about is when MMUPageSize < KernelPageSize. A process
>> might have to know that detail even when nothing is currently/yet
>> faulted in.
>>
>> Assume a process would perform an atomic that would cross MMUPageSize,
>> but not KernelPageSize. Depending on the architecture, atomics would not
>> work as expected in that case.
>
> I thought most architectures don't support atomics crossing pages
> anyways. x86 supports it, but it's discouraged.
Right. And if your user space thinks it has "64k" pages, when it's
actually emulated through "4k" pages under the hood, that could be a
problem: user space could perform an atomic "within" a 64k page that
actually crosses two 4k pages. So it must be aware that mmap etc operate
in 64k, but the underlying emulation might be smaller.
I suspect (but don't know for sure) that ppc exposed it for such a
reason (maybe not atomic, but something else where user space might be
able to detect the difference).
It's not that common nowadays, but I suspect it might get more common in
the future again.
>
>>
>> I'd expect other cases where an architecture might have to care about
>> the actual, smallest possible MMUPageSize it might be executed on while
>> running the program.
>
> That's fine, they can use the min, or just the first match
> (which is always the smallest)
>
>>
>> It's a shame we had to add MMUPageSize, but maybe it might resurface if
>> we ever support emulating 64K/16K user pagesizes on 4K MMUs.
>
> Okay, so if I follow that correctly you're suggesting
> to change KernelPageSize, not MMUPageSize. I can do that change.
Not at all. I'm saying that we leave KernelPageSize and MMUPageSize
alone, just as they are today.
Instead, if we want better statistics (and I think we want) regarding
how things are mapped, we should look into a better interface.
Ideally, that will tell you "how much" of a certain contiguous size is
mapped, if that contiguous size benefits somehow from TLB optimizations,
etc.
Similar to tlbmaps but easier to consume (and obtain, IIRC thpmaps
requires root permissions and has to jump through some racy hoops to
detect folio sizes) and easier to configure and extend.
--
Cheers,
David
next prev parent reply other threads:[~2026-03-02 21:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 23:27 Andi Kleen
2026-02-26 12:08 ` Usama Arif
2026-03-01 17:20 ` Andi Kleen
2026-02-26 17:31 ` David Hildenbrand (Arm)
2026-03-01 17:35 ` Andi Kleen
2026-03-02 19:29 ` David Hildenbrand (Arm)
2026-03-02 20:41 ` Andi Kleen
2026-03-02 21:05 ` David Hildenbrand (Arm) [this message]
2026-03-02 21:48 ` Andi Kleen
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=4a08a249-211b-40b9-b6bd-7c54af2b9d15@kernel.org \
--to=david@kernel.org \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
/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