Re: [RESEND v7 08/29] mm: recognize PMD swap entries in the softleaf layer
From: Kiryl Shutsemau
Date: Wed Sep 16 2026 - 10:54:40 EST
On Mon, Sep 14, 2026 at 05:27:58AM -0700, Usama Arif wrote:
> Reclaim splits a PMD-mapped anonymous THP into PTE-level swap entries
> before unmapping it, so an ordinary swap entry has never had to appear in a
> PMD. Later patches install one there instead, and the softleaf layer is
> where every consumer decodes non-present PMDs.
>
> Accept swap entries as valid PMD softleaves and add pmd_is_swap_entry().
> A swap entry carries no PFN, so make pmd_softleaf_to_folio() warn and
> return NULL rather than interpret a swap offset as a page frame number.
>
> Unlike migration and device-private entries, a PMD swap entry can also
> carry the swap-exclusive marker, which softleaf_from_pmd() has to strip
> before decoding. Strip all three overlays unconditionally while we are
> here: each clear is a plain bit clear, so testing first only buys a branch.
>
> Signed-off-by: Usama Arif <usama.arif@xxxxxxxxx>
Reviewed-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>
--
Kiryl Shutsemau / Kirill A. Shutemov