Re: [PATCH v3 2/3] locking: Clarify requirements for smp_mb__after_spinlock()
From: Andrea Parri
Date: Tue Jul 03 2018 - 13:08:11 EST
On Tue, Jul 03, 2018 at 08:39:10AM -0700, Paul E. McKenney wrote:
[...]
> > + * smp_mb__after_spinlock() provides the equivalent of a full memory barrier
> > + * between program-order earlier lock acquisitions and program-order later
>
> Not just the earlier lock acquisition, but also all program-order earlier
> memory accesses, correct?
I understand: "but also all program-order earlier memory accesses program-order
before that lock acquisition(s) ...". Yes, but:
- I considered this as implied by the above (L ->mb M2 and M1 ->po L implies
M1 ->mb M2, where M1, M2 are memory accesses and L is a lock acquisition);
- my prose abilities are limited ;-), and I was/am unable to come up with an
(to me) acceptable or readable enough way to make it explicit; some ideas?
> > + * WRITE_ONCE(X, 1); WRITE_ONCE(Y, 1);
> > + * spin_lock(S); smp_mb();
> > + * smp_mb__after_spinlock(); r1 = READ_ONCE(X);
> > + * r0 = READ_ONCE(Y);
> > + * spin_unlock(S);
>
> Should we say that this is an instance of the SB pattern? (Am OK either
> way, just asking the question.)
I don't think we *should* ;-), but I'm also OK either way.
Andrea