[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHbLzkoMMWAgai2bvgu7y5EAcKOhhx3gK+OA4v2+kOHBW4cauw@mail.gmail.com>
Date: Wed, 31 Aug 2022 12:08:48 -0700
From: Yang Shi <shy828301@...il.com>
To: David Hildenbrand <david@...hat.com>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
Andrew Morton <akpm@...ux-foundation.org>,
Jason Gunthorpe <jgg@...dia.com>,
John Hubbard <jhubbard@...dia.com>,
Andrea Arcangeli <aarcange@...hat.com>,
Hugh Dickins <hughd@...gle.com>, Peter Xu <peterx@...hat.com>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Subject: Re: [PATCH v1] mm/ksm: update stale comment in write_protect_page()
On Wed, Aug 31, 2022 at 11:29 AM David Hildenbrand <david@...hat.com> wrote:
>
> On 31.08.22 19:55, Yang Shi wrote:
> > On Wed, Aug 31, 2022 at 1:30 AM David Hildenbrand <david@...hat.com> wrote:
> >>
> >> The comment is stale, because a TLB flush is no longer sufficient and
> >> required to synchronize against concurrent GUP-fast. This used to be true
> >> in the past, whereby a TLB flush would have implied an IPI on architectures
> >> that support GUP-fast, resulting in GUP-fast that disables local interrupts
> >> from completing before completing the flush.
> >
> > Hmm... it seems there might be problem for THP collapse IIUC. THP
> > collapse clears and flushes pmd before doing anything on pte and
> > relies on interrupt disable of fast GUP to serialize against fast GUP.
> > But if TLB flush is no longer sufficient, then we may run into the
> > below race IIUC:
> >
> > CPU A CPU B
> > THP collapse fast GUP
> >
> > gup_pmd_range() <-- see valid pmd
> >
> > gup_pte_range() <-- work on pte
> > clear pmd and flush TLB
> > __collapse_huge_page_isolate()
> > isolate page <-- before GUP bump refcount
> >
> > pin the page
> > __collapse_huge_page_copy()
> > copy data to huge page
> > clear pte (don't flush TLB)
> > Install huge pmd for huge page
> >
> > return the obsolete page
>
> Hm, the is_refcount_suitable() check runs while the PTE hasn't been
> cleared yet. And we don't check if the PMD changed once we're in
> gup_pte_range().
Yes
>
> The comment most certainly should be stale as well -- unless there is
> some kind of an implicit IPI broadcast being done.
>
> 2667f50e8b81 mentions: "The RCU page table free logic coupled with an
> IPI broadcast on THP split (which is a rare event), allows one to
> protect a page table walker by merely disabling the interrupts during
> the walk."
>
> I'm not able to quickly locate that IPI broadcast -- maybe there is one
> being done here (in collapse) as well?
The TLB flush may call IPI. I'm supposed it is arch dependent, right?
Some do use IPI, some may not.
>
> --
> Thanks,
>
> David / dhildenb
>
Powered by blists - more mailing lists