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:07:11 EST


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.