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

From: Lorenzo Stoakes
Date: Mon Nov 10 2025 - 13:37:18 EST


On Sun, Nov 09, 2025 at 09:10:18PM +0800, Kairui Song wrote:
> Hi Lorenzo,
>
> Thanks, overloading swap entry types for things like migration always
> looked confusing to me.
>
> There is a problem with this patch as I mentioned here:
> https://lore.kernel.org/linux-mm/CAMgjq7AP383YfU3L5ZxJ9U3x-vRPnEkEUtmnPdXD29HiNC8OrA@xxxxxxxxxxxxxx/

Will reply there.

> > +/**
> > + * softleaf_is_swap() - Is this leaf entry a swap entry?
> > + * @entry: Leaf entry.
> > + *
> > + * Returns: true if the leaf entry is a swap entry, otherwise false.
> > + */
> > +static inline bool softleaf_is_swap(softleaf_t entry)
> > +{
> > + return softleaf_type(entry) == SOFTLEAF_SWAP;
> > +}
> > +
> > +/**
> > + * softleaf_is_swap() - Is this leaf entry a migration entry?
> > + * @entry: Leaf entry.
> > + *
> > + * Returns: true if the leaf entry is a migration entry, otherwise false.
> > + */
> > +static inline bool softleaf_is_migration(softleaf_t entry)
>
> And a nitpick here, the kerneldoc above doesn't match the function name here.

Oops copy/paste error, will fix.

>
> And now swap functions (swap_cache_*) that expects a swp_entry_t is
> getting a softleaf_t instead, they are the same thing right now, so
> that's fine. Will we need something like a softleaf_to_swap?

Yeah that's on purpose. Chris is also keen to keep these as swp_entry_t.

Obviously the second I make this type different it'll be easy to get the
compiler to identify as it'll throw a bunch of errors :) so this will be no
problem if/when we do that.

Cheers, Lorenzo