Re: [PATCH mm-unstable v18 06/14] mm/khugepaged: generalize collapse_huge_page for mTHP collapse
From: Nico Pache
Date: Mon Jun 01 2026 - 11:07:01 EST
On Mon, Jun 1, 2026 at 5:14 AM David Hildenbrand (Arm) <david@xxxxxxxxxx> wrote:
>
> On 6/1/26 12:47, Lance Yang wrote:
> >
> >
> > On 2026/6/1 18:23, David Hildenbrand (Arm) wrote:
> >> On 6/1/26 11:08, Lance Yang wrote:
> >>>
> >>>
> >>>
> >>> One small thing, I think we should probably keep the smp_wmb(), and just
> >>> move it before the earlier pmd_populate().
> >>>
> >>> IIUC, the ordering we want is still:
> >>>
> >>> clear old PTEs
> >>> smp_wmb()
> >>> pmd_populate()
> >>>
> >>> so another CPU cannot walk through the re-installed PMD and still observe
> >>> the old PTEs, right?
> >>
> >> There is a smp_wmb() in __folio_mark_uptodate(), that should be sufficient?
> >
> > Ah, cool! __folio_mark_uptodate() already does the job :P
> >
> > So yeah, no extra smp_wmb() needed here!
>
> Yeah. BTW, I think we'd need a spin_lock_nested(), so @Nico, treat my code as a
> draft.
Okay, I read the above and did some investigating.
I will try to implement and verify the changes you suggested :)
Or an even crazier idea... what if we ensure MIPS checks for PMD_none
before walking a PTE table?
-- Nico
>
> --
> Cheers,
>
> David
>