Re: [PATCH v8 00/30] mm: PMD-level swap entries for anonymous THPs

From: Usama Arif

Date: Tue Nov 03 2026 - 11:44:03 EST


On Sun, 4 Oct 2026 11:08:44 +0800 Lance Yang <lance.yang@xxxxxxxxx> wrote:

> Hey Usama,
>
> Staring at the swap-entry bits across architectures, and RISC-V looks a
> bit off in that regard ...
>
> With Svrsw60t59b and CONFIG_MEM_SOFT_DIRTY=y, setting swap soft-dirty also
> sets _PAGE_EXEC. A migration PMD then looks present ... so the fault
> handler skips the migration wait :(
>
> And yeah, this is a pre-existing bug. I've sent a separate fix for it.
>

Thanks for the fix! PMD swap entries also preserve soft-dirty, so the
same encoding issue affects this series. The dependency note lists
your separate fix for RISC-V with Svrsw60t59b and soft-dirty enabled.
It applies cleanly and preserves the exclusive marker at bit 6.


> https://lore.kernel.org/linux-mm/20261004030312.90163-1-lance.yang@xxxxxxxxx/
>
> BTW, could we also add more checks to pmd_leaf_soft_dirty_tests() so we
> catch this kind of issue early? Setting a swap flag shouldn't make a
> non-present PMD present, IIUC.

Done. The pgtable test now sets swap soft-dirty, checks that the flag
is set, and checks that the PMD remains non-present.

>
> ---8<---
> diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
> index 863111c6d4eb..80686e2baaa1 100644
> --- a/mm/debug_vm_pgtable.c
> +++ b/mm/debug_vm_pgtable.c
> @@ -762,7 +762,9 @@ static void __init pmd_leaf_soft_dirty_tests(struct pgtable_debug_args *args)
> WARN_ON(!pmd_is_huge(pmd));
> WARN_ON(!pmd_is_valid_softleaf(pmd));
>
> - WARN_ON(!pmd_swp_soft_dirty(pmd_swp_mksoft_dirty(pmd)));
> + pmd = pmd_swp_mksoft_dirty(pmd);
> + WARN_ON(!pmd_swp_soft_dirty(pmd));
> + WARN_ON(pmd_present(pmd));
> WARN_ON(pmd_swp_soft_dirty(pmd_swp_clear_soft_dirty(pmd)));
> }
> #else /* !CONFIG_TRANSPARENT_HUGEPAGE */
> --
>
> [...]
>
> Cheers, Lance
>