Re: [PATCH v3 01/11] mm: add PMD swap entry detection support
From: Usama Arif
Date: Thu Jul 09 2026 - 10:22:12 EST
On Fri, 3 Jul 2026 10:38:18 -0700 Usama Arif <usama.arif@xxxxxxxxx> wrote:
> Currently when a PMD-mapped THP is swapped out, the PMD is always split into 512 PTE-level swap entries. To preserve huge page information across swap cycles, later patches will install a single PMD-level swap entry instead. This patch adds the infrastructure to detect those entries.
>
> Teach the softleaf layer to recognise PMD swap entries: pmd_is_swap_entry() detects them and softleaf_is_valid_pmd_entry() accepts them as a valid non-present type. Clear the exclusive overlay bit in softleaf_from_pmd() before decoding, matching how soft_dirty and uffd_wp bits are already stripped.
>
> Add pmd_swp_mkexclusive(), pmd_swp_exclusive(), and pmd_swp_clear_exclusive() helpers to each architecture that supports PMD softleaf entries (x86, arm64, s390, riscv, loongarch, powerpc), mirroring the existing PTE swap exclusive helpers in each arch's pgtable.h. Provide generic no-op PMD swap exclusive fallbacks for architectures without PMD softleaf support, matching the generic PMD swap soft-dirty fallbacks.
>
> Signed-off-by: Usama Arif <usama.arif@xxxxxxxxx>
I forgot to format the commit message before sending this patch,
sorry about this, will fix in the next revision.