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

From: Lance Yang

Date: Sat Oct 03 2026 - 23:09:06 EST


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.

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.

---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