lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMZfGtWk+gG7Z2bOy_bq=XnuuSJzic16zpeajhJiiekpJEFrFg@mail.gmail.com>
Date:   Tue, 14 Apr 2020 20:01:06 +0800
From:   Muchun Song <songmuchun@...edance.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Will Deacon <will@...nel.org>, mingo@...hat.com, mingo@...nel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [External] Re: [PATCH] seqlock: Use while instead of if+goto in __read_seqcount_begin

On Tue, Apr 14, 2020 at 7:05 PM Peter Zijlstra <peterz@...radead.org> wrote:
>
> On Fri, Apr 10, 2020 at 12:56:58PM +0100, Will Deacon wrote:
> > On Thu, Apr 09, 2020 at 09:45:58PM +0800, Muchun Song wrote:
> > > The creators of the C language gave us the while keyword. Let's use
> > > that instead of synthesizing it from if+goto.
> > >
> > > Signed-off-by: Muchun Song <songmuchun@...edance.com>
> > > ---
> > >  include/linux/seqlock.h | 6 +-----
> > >  1 file changed, 1 insertion(+), 5 deletions(-)
> > >
> > > diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
> > > index 8b97204f35a77..7bdea019814ce 100644
> > > --- a/include/linux/seqlock.h
> > > +++ b/include/linux/seqlock.h
> > > @@ -125,12 +125,8 @@ static inline unsigned __read_seqcount_begin(const seqcount_t *s)
> > >  {
> > >     unsigned ret;
> > >
> > > -repeat:
> > > -   ret = READ_ONCE(s->sequence);
> > > -   if (unlikely(ret & 1)) {
> > > +   while (unlikely((ret = READ_ONCE(s->sequence)) & 1))
> > >             cpu_relax();
> > > -           goto repeat;
> > > -   }
> > >     kcsan_atomic_next(KCSAN_SEQLOCK_REGION_MAX);
> > >     return ret;
> >
> > Patch looks fine to me, but I'll leave it to Peter as I don't have a
> > preference either way.
>
> Linus sometimes prefers the goto variant as that better expresses the
> exception model. But like Will, I don't particularly care. That said,
> Will, would it make sense to use smp_cond_load_relaxed() here ?

I have a similar idea. Would it make sense to use smp_cond_load_acquire()
in raw_read_seqcount_begin()?

-- 
Yours,
Muchun

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ