On Tue, Oct 15, 2024 at 01:12:36PM +0200, David Hildenbrand wrote: > pmd_leaf()/pud_leaf() only implies a pmd_present()/pud_present() check on > some architectures. Should we clarify what behaviour we actually want from arch code? > We really should check for > pmd_present()/pud_present() first. > > This should explain the report we got on ppc64 (which has > CONFIG_PGTABLE_HAS_HUGE_LEAVES set in the config) that triggered: > VM_WARN_ON_ONCE(pmd_leaf(pmdp_get_lockless(pmdp))); > > Likely we had a PMD migration entry for which pmd_leaf() did not > trigger. We raced with restoring the PMD migration entry, and suddenly > saw a pmd_leaf(). In this case, pte_offset_map_lock() saved us from more > trouble, because it rechecks the PMD value, but we would not have processed > the migration entry -- which is not too bad because the only user of > FW_MIGRATION is KSM for unsharing, and KSM only applies to small folios. > > Further, we shouldn't re-read the PMD/PUD value for our warning, the > primary purpose of the VM_WARN_ON_ONCE() is to find spurious use of > pmd_leaf()/pud_leaf() without CONFIG_PGTABLE_HAS_HUGE_LEAVES. > > As a side note, we are currently not implementing FW_MIGRATION support > for PUD migration entries, which likely should exist due to hugetlb. Add > a TODO so this won't fall through the cracks if more FW_MIGRATION users > get added. > > Fixes: aa39ca6940f1 ("mm/pagewalk: introduce folio_walk_start() + folio_walk_end()") > Reported-by: syzbot+7d917f67c05066cec295@xxxxxxxxxxxxxxxxxxxxxxxxx > Closes: https://lkml.kernel.org/r/670d3248.050a0220.3e960.0064.GAE@xxxxxxxxxx > Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> > Cc: Jann Horn <jannh@xxxxxxxxxx> > Signed-off-by: David Hildenbrand <david@xxxxxxxxxx> Acked-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> -- Kiryl Shutsemau / Kirill A. Shutemov