lkml.org 
[lkml]   [2021]   [Jan]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v17 11/26] x86/mm: Update ptep_set_wrprotect() and pmdp_set_wrprotect() for transition from _PAGE_DIRTY to _PAGE_COW
On Tue, Jan 26, 2021 at 09:46:36AM +0100, Peter Zijlstra wrote:
> On Mon, Jan 25, 2021 at 07:27:09PM +0100, Borislav Petkov wrote:
>
> > > + pte_t old_pte, new_pte;
> > > +
> > > + do {
> > > + old_pte = READ_ONCE(*ptep);
> > > + new_pte = pte_wrprotect(old_pte);
> >
> > Maybe I'm missing something but those two can happen outside of the
> > loop, no? Or is *ptep somehow changing concurrently while the loop is
> > doing the CMPXCHG and you need to recreate it each time?
> >
> > IOW, you can generate upfront and do the empty loop...
> >
> > > +
> > > + } while (!try_cmpxchg(&ptep->pte, &old_pte.pte, new_pte.pte));
> > > +
> > > + return;
> > > + }
>
> Empty loop would be wrong, but that wants to be written like:
>
> old_pte = READ_ONCE(*ptep);
> do {
> new_pte = pte_wrprotect(old_pte);
> } while (try_cmpxchg(&ptep->pte, &old_pte.pte, new_pte.pte));

! went missing, too early, moar wake-up juice.

> Since try_cmpxchg() will update old_pte on failure.

\
 
 \ /
  Last update: 2021-01-26 12:31    [W:1.931 / U:0.420 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site