Re: [PATCH RFC tip/core/rcu 12/15] lib/assoc_array: Remove smp_read_barrier_depends()

From: Peter Zijlstra
Date: Wed Oct 11 2017 - 12:12:39 EST


On Wed, Oct 11, 2017 at 08:59:48AM -0700, Paul E. McKenney wrote:
> On Wed, Oct 11, 2017 at 04:17:25PM +0100, David Howells wrote:
> > I will, however, quibble with the appropriateness of the name READ_ONCE()...
> > I still think it's not sufficiently obvious that this is a barrier and the
> > barrier is after. Maybe READ_AND_BARRIER()?
>
> Linus was unhappy with READ_ONCE_CTRL() to tag control dependencies, but
> indicated that he might consider it if it helped code-analysis tools.
> Adding Dmitry Vyukov for his thoughts on whether tagging READ_ONCE()
> for dependencies would help. Me, I would suggest READ_ONCE_DEP(), but
> let's figure out if the bikeshed needs to be painted before arguing over
> the color. ;-)

Count me one vote for the READ_ONCE() name. This is about dependent
reads, which are nothing special on anything except Alpha.

We want to remove the exception/specialness from the memory model; and
therefore have to fix up all primitives that could possibly be used for
these reads to unconditionally issue the barrier (on Alpha). The
alternative is: rm -rf arch/alpha.

Adding something like READ_ONCE_DEP() does not rid us of the idea that
dependent reads are special and thus defeats the purpose, we might as
well retain lockless_dereference().

Now; any user of dependent reads must use READ_ONCE() in any case, to
avoid load tearing and reloads. So using READ_ONCE() for the dependent
reads is not extra or additional (note we'll also have to add the
barrier to all our relaxed and release atomics and anything else that
implies READ_ONCE and doesn't already imply smp_mb() after).