From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Andi Kleen <ak@linux.intel.com>
Cc: "David Hildenbrand (Arm)" <david@kernel.org>,
linux-mm@kvack.org, akpm@linux-foundation.org
Subject: Re: [PATCH v2] smaps: Report correct page sizes with THP
Date: Tue, 3 Mar 2026 09:39:14 +0000 [thread overview]
Message-ID: <72667151-816f-49a7-90e7-c68db3ac3390@lucifer.local> (raw)
In-Reply-To: <aaYFpEmiH99dryA4@tassilo>
On Mon, Mar 02, 2026 at 01:48:20PM -0800, Andi Kleen wrote:
> On Mon, Mar 02, 2026 at 10:05:23PM +0100, David Hildenbrand (Arm) wrote:
> > 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
>
> PPC user space doesn't do it.
>
> > actually crosses two 4k pages. So it must be aware that mmap etc operate
> > in 64k, but the underlying emulation might be smaller.
>
> Sounds like a very contrived use case, which I'm not sure actually
> happens. From my past experiences most software usually doesn't use
> complicated enumerations anyways but just hard codes something
> reasonable (like in your example just always assume 4K worst case).
> From their POV it makes sense, how would you test
> a complicated enumeration for cases that don't happen on your
> current system.
I'm sorry but it's a legacy user-facing stat, we don't get to change it or add a
nearly-identically named entry that means something totally different (?!!)
>
> > >> 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.
>
> That doesn't solve the problem that motivated my patch
> smaps is confusing today and would stay so.
Except as you've been told you can find this information out in different
ways.
>
> >
> > Instead, if we want better statistics (and I think we want) regarding
> > how things are mapped, we should look into a better interface.
>
> I don't see how a new interface helps really. Some of the problems
I mean, you want information X, we're suggesting the providing of an interface
to provide information X and... you don't see how that helps?
> you mentioned earlier could be either solved today with smaps
> (e.g. handling the case when a folio is mapped partially and just
> report the smaller page size), or are unsolveable in the general case
> (what the TLB actually handles)
We're not having multiple entries in smaps for every mapping size, it's broken
and ungreppable, and very liable to add additional confusion to users.
A new interface gives us flexibility to do what we want, we aren't running out
of syscalls or places to put statistics.
Smaps is necessarily a user-facing contract at this point so we have to tread
carefully there.
>
> A new interface doesn't really change anything given that smaps
> is extensible.
See above.
>
> I'll look at the partial folio case, but will only handle
> it if it's simple.
Feel free to look at whatever you like, maintainers decide what gets
merged.
>
> > Ideally, that will tell you "how much" of a certain contiguous size is
> > mapped, if that contiguous size benefits somehow from TLB optimizations,
> > etc.
>
> The key word is "somehow". It's better to work with real use cases
> instead of such hypothetics.
Except your suggestion already demonstrates fundamental confusion about how
folios are mapped in userspace?
We have to live with the legacy of MMUPageSize it means what it
means. We're not adding variable-key entries to smaps full stop, because
they're ungreppable and confusing.
so in _real world_ terms we are looking at a new interface, not overloading
smaps.
>
> -Andi
>
Thanks, Lorenzo
next prev parent reply other threads:[~2026-03-03 9:39 UTC|newest]
Thread overview: 12+ 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)
2026-03-02 21:48 ` Andi Kleen
2026-03-03 9:05 ` David Hildenbrand (Arm)
2026-03-03 9:39 ` Lorenzo Stoakes [this message]
2026-03-03 9:27 ` Lorenzo Stoakes
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=72667151-816f-49a7-90e7-c68db3ac3390@lucifer.local \
--to=lorenzo.stoakes@oracle.com \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.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