Re: [RFC PATCH 00/12] remove is_swap_[pte, pmd]() + non-swap confusion
From: Jason Gunthorpe
Date: Wed Oct 29 2025 - 10:10:51 EST
On Tue, Oct 28, 2025 at 06:20:54PM +0000, Lorenzo Stoakes wrote:
> > > And use the new type right away.
> >
> > Then the followup series is cleaning away swap_entry_t as a name.
>
> OK so you're good with the typedef? This would be quite nice actually as we
> could then use leaf_entry_t in all the core leafent_xxx() logic ahead of
> time and reduce confusion _there_ and effectively document that swp_entry_t
> is just badly named.
Yeah, I think so, a commit message explaining it is temporary and a
future series will mechanically rename it away and this is
preparation.
> I mean I'm not so sure that's all that useful, you often want to skip over
> things that are 'none' entries without doing this conversion.
Maybe go directly from a pte to the leaf entry type for this check?
#define __swp_type(x) ((x).val >> (64 - SWP_TYPE_BITS))
That's basically free on most arches..
> We could use the concept of 'none is an empty leaf_entry_t' more thoroughly
> internally in functions though.
>
> I will see what I can do.
Sure, maybe something works out
Though if we want to keep them seperate then maybe pte_is_leafent() is
the right name for pte_none(). Reads so much better like this:
if (pte_is_leafent(pte)) {
leafent_t leaf = leafent_from_pte(pte)
if (leafent_is_swap(leaf)) {..}
}
> > Then this:
> >
> > pmd_is_present_or_leafent(pmd)
>
> A PMD can be present and contain an entry pointing at a PTE table so I'm
> not sure that helps... naming is hard :)
pmd_is_leaf_or_leafent()
In the PTE API we are calling present entries that are address, not
tables, leafs.
Jason