Re: Confused about hlist_unhashed_lockless()

From: Paul E. McKenney
Date: Mon Feb 03 2020 - 10:58:41 EST


On Mon, Feb 03, 2020 at 03:45:54PM +0000, David Laight wrote:
> From: Eric Dumazet
> > Sent: 31 January 2020 18:53
> >
> > On Fri, Jan 31, 2020 at 10:48 AM Eric Dumazet <edumazet@xxxxxxxxxx> wrote:
> > >
> >
> > > This is nice, now with have data_race()
> > >
> > > Remember these patches were sent 2 months ago, at a time we were
> > > trying to sort out things.
> > >
> > > data_race() was merged a few days ago.
> >
> > Well, actually data_race() is not there yet anyway.
>
> Shouldn't it be NO_DATA_RACE() ??

No, because you use data_race() when there really are data races, but you
want KCSAN to ignore them. For example, diagnostic code that doesn't
participate in the actual concurrency design and that doesn't run all
that often might use data_race(). For another example, if a developer
knew that data races existed, but that the compiler could not reasonably
do anything untoward with those data races, that developer might well
choose to use data_race() instead of READ_ONCE(). Especially if the
access in question was on a fastpath where helpful compiler optimizations
would be prohibited by use of READ_ONCE().

Thanx, Paul