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: <20241218162934.GJ12500@noisy.programming.kicks-ass.net>
Date: Wed, 18 Dec 2024 17:29:34 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: "Paul E. McKenney" <paulmck@...nel.org>
Cc: Daniel Xu <dxu@...uu.xyz>, mingo@...hat.com, will@...nel.org,
	longman@...hat.com, boqun.feng@...il.com,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] seqlock: Use WRITE_ONCE() when updating sequence

On Wed, Dec 18, 2024 at 05:23:25PM +0100, Peter Zijlstra wrote:
> On Wed, Dec 18, 2024 at 07:43:41AM -0800, Paul E. McKenney wrote:
> > On Wed, Dec 18, 2024 at 11:30:00AM +0100, Peter Zijlstra wrote:
> > > On Tue, Dec 17, 2024 at 03:17:36PM -0800, Daniel Xu wrote:
> 
> 
> > > > @@ -405,7 +405,7 @@ do {									\
> > > >  static inline void do_raw_write_seqcount_begin(seqcount_t *s)
> > > >  {
> > > >  	kcsan_nestable_atomic_begin();
> > > > -	s->sequence++;
> > > > +	WRITE_ONCE(s->sequence, READ_ONCE(s->sequence) + 1);
> > > >  	smp_wmb();
> > > >  }
> > > 
> > > This results in significantly worse code-gen, it will change an inc to
> > > memory with a load,inc,store.
> > 
> > Isn't that code-generation bug in the process of being fixed? 
> 
> Last time I looked the compiler wasn't allowed to touch it because of
> all the volatile going around. Did anything change?
> 
> > And, either way, given the likely cache miss, should we really care?
> 
> Yeah, extra register pressure too.

Perhaps something like: (*(volatile unsigned int *)&s->sequence)++; ?
I'd have to check what the compiler makes of that.

/me mucks about with godbolt for a bit...

GCC doesn't optimize that, but Clang does.

I would still very much refrain from making this change until both
compilers can generate sane code for it.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ