On Wed, 28 Aug 2013 10:19:37 +0200
Peter Zijlstra <pet...@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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to