On Mon, 7 Mar 2022 16:03:12 -0800 Yang Shi <shy828301@xxxxxxxxx> wrote: > On Mon, Mar 7, 2022 at 3:43 PM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote: > > @@ -2133,8 +2133,6 @@ void __split_huge_pmd(struct vm_area_str > > { > > spinlock_t *ptl; > > struct mmu_notifier_range range; > > - bool do_unlock_folio = false; > > - pmd_t _pmd; > > > > mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, vma, vma->vm_mm, > > address & HPAGE_PMD_MASK, > > @@ -2153,42 +2151,14 @@ void __split_huge_pmd(struct vm_area_str > > goto out; > > } > > > > -repeat: > > if (pmd_trans_huge(*pmd)) { > > - if (!folio) { > > + if (!folio) > > folio = page_folio(pmd_page(*pmd)); > > We could remove the "if (pmd_trans_huge(*pmd))" section since folio is > actually not used afterward at all. > > ... > > > With the above if removed, this could be changed to: > > if (pmd_trans_huge(*pmd) || pmd_devmap(*pmd) || > is_pmd_migration_entry(*pmd)) > __split_huge_pmd_locked(vma, pmd, range.start, freeze); > OK, looks sane. Can someone please test all this? --- a/mm/huge_memory.c~mm-huge_memory-remove-stale-locking-logic-from-__split_huge_pmd-fix +++ a/mm/huge_memory.c @@ -2151,12 +2151,10 @@ void __split_huge_pmd(struct vm_area_str goto out; } - if (pmd_trans_huge(*pmd)) { - if (!folio) - folio = page_folio(pmd_page(*pmd)); - } else if (!(pmd_devmap(*pmd) || is_pmd_migration_entry(*pmd))) - goto out; - __split_huge_pmd_locked(vma, pmd, range.start, freeze); + if (pmd_trans_huge(*pmd) || pmd_devmap(*pmd) || + is_pmd_migration_entry(*pmd))) + __split_huge_pmd_locked(vma, pmd, range.start, freeze); + out: spin_unlock(ptl); /* _