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

From: Peter Zijlstra
Date: Wed Apr 24 2019 - 04:45:04 EST


On Wed, Apr 24, 2019 at 01:29:48AM -0700, Paul E. McKenney wrote:
> 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.

Right, and that was not intentional.

> 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.

Right. I'll go make a more complete patch, covering all the
architectures.

> 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.

Agreed, that is an unsupported idiom and it would be good to have
something check for this.

> 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?

I think we're good :-)