Re: [PATCH] Documentation: atomic_t.txt: Explain ordering provided by smp_mb__{before,after}_atomic()

From: Paul E. McKenney
Date: Wed Apr 24 2019 - 04:31:36 EST


On Tue, Apr 23, 2019 at 10:28:31PM +0200, Peter Zijlstra wrote:
> On Tue, Apr 23, 2019 at 01:16:37PM -0700, Paul E. McKenney wrote:
>
> > Agreed, but I thought that one of the ideas going forward was to get
> > rid of smp_mb__{before,after}_atomic().
>
> It's not one I had considered.. I just wanted to get rid of this
> 'surprise' behaviour.

Ah, good point, your patch is in fact a midpoint between those two
positions. Just to make sure I understand:

1. Without your patch, smp_mb__{before,after}_atomic() orders
only against the atomic itself.

2. With your patch, smp_mb__{before,after}_atomic() orders against
the atomic itself and the accesses on the other side of that
atomic. However, it does not order the atomic against the
accesses on the other side of that atomic.

Putting things between the smp_mb__{before,after}_atomic()
and the atomic is in my opinion a bad idea, but in this case
they are not necessarily ordered.

3. Dispensing with smp_mb__{before,after}_atomic() would have
void RMW atomics fully ordered, but I suspect that it results
in ugly performance regressions.

Or am I still missing something?

Thanx, Paul