Re: [PATCH RFC tools/lkmm 10/12] tools/memory-model: Add a S lock-based external-view litmus test

From: Peter Zijlstra
Date: Thu Feb 22 2018 - 05:20:48 EST


On Thu, Feb 22, 2018 at 11:06:36AM +0100, Peter Zijlstra wrote:
> On Wed, Feb 21, 2018 at 09:42:08PM -0800, Daniel Lustig wrote:
> > And yes, if we go with a purely RCpc interpretation of acquire and
> > release, then I don't believe the writes in the previous critical
> > section would be ordered with the writes in the subsequent critical
> > section.
>
> Excuse my ignorance (also jumping in the middle of things), but how can
> this be?
>
> spin_unlock() is a store-release, this means the write to the lock word
> must happen after any stores inside the critical section.
>
> spin_lock() is a load-acquire + test-and-set-ctrl-dep, we'll only
> proceed with the critical section if we observe the lock 'unlocked',
> which also means we must observe the stores prior to the unlock.
>
> And both the ctrl-dep and the ACQUIRE ensure future stores cannot happen
> before.
>
> So while the lock store and subsequent critical section stores are
> unordered, I don't see how it would be possible to not be ordered
> against stores from a previous critical section.
>

Or are we talking about a third party observing while not partaking in
the lock-chain? Then I agree, the stores can be observed out of order by
this 3rd actor.