Re: [PATCH] locking/osq_lock: fix a data race in osq_wait_next

From: Paul E. McKenney
Date: Wed Jan 29 2020 - 14:26:12 EST


On Wed, Jan 29, 2020 at 07:49:35PM +0100, Peter Zijlstra wrote:
> On Tue, Jan 28, 2020 at 04:22:53PM -0800, Paul E. McKenney wrote:
> > On Tue, Jan 28, 2020 at 05:56:55PM +0100, Peter Zijlstra wrote:
> > > On Tue, Jan 28, 2020 at 12:46:26PM +0100, Marco Elver wrote:
> > >
> > > > > Marco, any thought on improving KCSAN for this to reduce the false
> > > > > positives?
> > > >
> > > > Define 'false positive'.
> > >
> > > I'll use it where the code as written is correct while the tool
> > > complains about it.
> >
> > I could be wrong, but I would guess that Marco is looking for something
> > a little less subjective and a little more specific. ;-)
>
> How is that either? If any valid translation by a compile results in
> correct functionality, yet the tool complains, then surely we can speak
> of a objective fact.

Marco covered my concern in his point about the need to change the
compiler.

In any case, agreed, if a read does nothing but feed into the old/new
values for a CAS, the only thing a reasonable compiler (as opposed to
a just-barely-meets-the-standard demonic compiler) can do to you is to
decrease the CAS success rate.

Thanx, Paul