Re: [PATCH 02/16] mm: introduce leaf entry type and use to simplify leaf entry logic

From: Gregory Price

Date: Wed Nov 05 2025 - 14:25:40 EST


On Wed, Nov 05, 2025 at 07:06:11PM +0000, Matthew Wilcox wrote:
> On Mon, Nov 03, 2025 at 12:31:43PM +0000, Lorenzo Stoakes wrote:
> > The kernel maintains leaf page table entries which contain either:
> >
> > - Nothing ('none' entries)
> > - Present entries (that is stuff the hardware can navigate without fault)
> > - Everything else that will cause a fault which the kernel handles
>
> The problem is that we're already using 'pmd leaf entries' to mean "this
> is a pointer to a PMD entry rather than a table of PTEs".

Having not looked at the implications of this for leafent_t prototypes
...
Can't this be solved by just adding a leafent type "Pointer" which
implies there's exactly one leaf-ent type which won't cause faults?

is_present() => (table_ptr || leafent_ptr)
else(): => !leafent_ptr

if is_none()
do the none-thing
if is_present()
if is_leafent(ent) (== is_leafent_ptr)
do the pointer thing
else
do the table thing
else()
type = leafent_type(ent)
switch(type)
do the software things
can't be a present entry (see above)


A leaf is a leaf :shrug:

~Gregory