Re: [PATCH v8 04/30] powerpc: mm: add PMD swap-exclusive helpers

From: LEROY Christophe

Date: Mon Oct 05 2026 - 00:55:53 EST


Don't forget to CC <linuxppc-dev@xxxxxxxxxxxxxxxx> when addressing
powerpc architecture.

Le 02/10/2026 à 11:52, Usama Arif a écrit :
> Prepare for keeping a PMD-mapped anonymous THP mapped by a PMD across the
> swap round-trip, which makes PG_anon_exclusive have to survive in a swap
> PMD and not just in a swap PTE.
>
> book3s64 builds a swap PMD by running the PTE encoding over pmd_pte(), so
> the PMD helpers wrap the PTE ones and reuse _PAGE_SWP_EXCLUSIVE, exactly
> as the soft-dirty PMD helpers next to them do. It is also the only powerpc
> variant that selects ARCH_HAS_PMD_SOFTLEAVES, via PPC_THP.
>
> Cc: Madhavan Srinivasan <maddy@xxxxxxxxxxxxx>
> Signed-off-by: Usama Arif <usama.arif@xxxxxxxxx>
> ---
> arch/powerpc/include/asm/book3s/64/pgtable.h | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
> index dff8790a047db..458c85cebfa65 100644
> --- a/arch/powerpc/include/asm/book3s/64/pgtable.h
> +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
> @@ -1060,6 +1060,12 @@ static inline pte_t *pmdp_ptep(pmd_t *pmd)
> #endif
> #endif /* CONFIG_HAVE_ARCH_SOFT_DIRTY */
>
> +#ifdef CONFIG_ARCH_HAS_PMD_SOFTLEAVES
> +#define pmd_swp_mkexclusive(pmd) pte_pmd(pte_swp_mkexclusive(pmd_pte(pmd)))
> +#define pmd_swp_exclusive(pmd) pte_swp_exclusive(pmd_pte(pmd))
> +#define pmd_swp_clear_exclusive(pmd) pte_pmd(pte_swp_clear_exclusive(pmd_pte(pmd)))
> +#endif
> +
> #ifdef CONFIG_ARCH_HAS_PTE_PROTNONE
> static inline int pmd_protnone(pmd_t pmd)
> {