Re: [RFC V2 0/3] lib/vsprintf: Add support for pgtable entries
From: Matthew Wilcox
Date: Thu Jun 11 2026 - 15:38:08 EST
On Thu, Jun 11, 2026 at 10:33:35PM +0300, Andy Shevchenko wrote:
> On Thu, Jun 11, 2026 at 08:15:57PM +0100, Matthew Wilcox wrote:
> > On Wed, Jun 10, 2026 at 05:35:42AM +0100, Anshuman Khandual wrote:
> > > Printing page table entries has been a common requirement both in generic
> > > and platform memory management for various purposes. Hence let's create a
> > > dedicated printk format for such entries which will also help standardize
> > > pgtable printing across different platforms.
> >
> > You didn't address my objection here:
> >
> > https://lore.kernel.org/linux-mm/aFQP8LzVMctf6XH5@xxxxxxxxxxxxxxxxxxxx/
> >
> > ie there is now no typechecking possible. So you've made it more
> > dangerous. I reiterate my NACK to the concept, not to the implementation.
>
> But this is more of a global question, how do we check the validity of
> the parameters of pointer extensions in the kernel? Does anybody go to
> commit into GCC plugin or so for this job?
I agree that it's a global question that it would be great for somebody
to answer. But it's specifically a problem for this patchset because:
- It's really easy to get confused about which page table level you're
working on. And hugetlbfs deliberately increases that confusion.
- Different levels of the page tables actually do have different sizes
on some architectures, so if you think you're looking at a pointer to a
64-bit quantity when it's really a pointer to a 32-bit quantity, things
Will Go Wrong (or vice-versa. And some architctures are big-endian)
- But on x86-64, Everything Is Fine because all levels of the page table
are basically identical, so you'll never notice there's a problem.