Re: [PATCH] mm/khugepaged: Fix ->anon_vma race

From: Kirill A. Shutemov
Date: Mon Jan 23 2023 - 19:51:13 EST


On Mon, Jan 23, 2023 at 12:07:05PM +0100, David Hildenbrand wrote:
> > > commit bedf03416913d88c796288f9dca109a53608c745
> > > Author: Yang Shi <shy828301@xxxxxxxxx>
> > > Date: Wed Sep 7 11:01:44 2022 -0700
> > >
> > > powerpc/64s/radix: don't need to broadcast IPI for radix pmd collapse flush
> > > The IPI broadcast is used to serialize against fast-GUP, but fast-GUP will
> > > move to use RCU instead of disabling local interrupts in fast-GUP. Using
> > > an IPI is the old-styled way of serializing against fast-GUP although it
> > > still works as expected now.
> > > And fast-GUP now fixed the potential race with THP collapse by checking
> > > whether PMD is changed or not. So IPI broadcast in radix pmd collapse
> > > flush is not necessary anymore. But it is still needed for hash TLB.
> >
> > Okay. But I think tlb_remove_table_sync_one() belongs inside
> > pmdp_collapse_flush(). Collapsing pmd table into huge page without
> > serialization is a bug. They should not be separate.
>
> Agreed. But I wonder if it should be moved into a generic
> pmdp_collapse_flush(), that calls an arch specific __pmdp_collapse_flush().

Um? There's no __pmdp_collapse_flush(). Architectural code overrides
pmdp_collapse_flush() altogether. It has know how to serialize properly
for the arch.

--
Kiryl Shutsemau / Kirill A. Shutemov