Messages in this thread | | | Date | Wed, 28 Aug 2013 08:59:57 -0400 | From | Steven Rostedt <> | Subject | Re: [PATCH RFC v2 1/2] qspinlock: Introducing a 4-byte queue spinlock implementation |
| |
On Wed, 28 Aug 2013 10:19:37 +0200 Peter Zijlstra <peterz@infradead.org> wrote:
> > An unlock followed by a lock needs to act like a full barrier, but there > > is no requirement that a lock or unlock taken separately act like a > > full barrier. > > But that is already a property of the acquisition/release barrier.
As I mentioned in my fixes for the -rt swait barrier patches I sent. Spin locks only prevent leaks out of the critical section. It does not guarantee leaks into the critical section, thus:
A = 1
spin_lock()
spin_unlock()
B = C
Can turn into:
(A = 1)
spin_lock()
load C
store 1 into A
spin_unlock()
B = C
This shows that a spin_lock()/unlock() combo is not equivalent to a mb(). But as Paul has mentioned, if we had:
A = 1
spin_unlock()
spin_lock()
B = C
That would be equivalent to
A = 1
mb()
B = C
as the unlock prevents leaks going past it, and lock prevents leaks going before it.
-- Steve
| |