[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20131210184920.GA4208@linux.vnet.ibm.com>
Date: Tue, 10 Dec 2013 10:49:20 -0800
From: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: linux-kernel@...r.kernel.org, mingo@...nel.org,
laijs@...fujitsu.com, dipankar@...ibm.com,
akpm@...ux-foundation.org, mathieu.desnoyers@...icios.com,
josh@...htriplett.org, niv@...ibm.com, tglx@...utronix.de,
rostedt@...dmis.org, dhowells@...hat.com, edumazet@...gle.com,
darren@...art.com, fweisbec@...il.com, sbw@....edu,
Ingo Molnar <mingo@...hat.com>,
Oleg Nesterov <oleg@...hat.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Will Deacon <will.deacon@....com>,
Tim Chen <tim.c.chen@...ux.intel.com>,
Waiman Long <waiman.long@...com>,
Andrea Arcangeli <aarcange@...hat.com>,
Andi Kleen <andi@...stfloor.org>,
Michel Lespinasse <walken@...gle.com>,
Davidlohr Bueso <davidlohr.bueso@...com>,
Rik van Riel <riel@...hat.com>,
Peter Hurley <peter@...leysoftware.com>,
"H. Peter Anvin" <hpa@...or.com>, Arnd Bergmann <arnd@...db.de>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>
Subject: Re: [PATCH v5 tip/core/locking 5/7]
Documentation/memory-barriers.txt: Downgrade UNLOCK+LOCK
On Tue, Dec 10, 2013 at 06:43:45PM +0100, Peter Zijlstra wrote:
> On Tue, Dec 10, 2013 at 09:12:47AM -0800, Paul E. McKenney wrote:
> > Good point -- the UNLOCK and LOCK are guaranteed to be ordered only
> > if they both operate on the same lock variable. OK, I will make the
> > example use different lock variables and show the different outcomes.
> > How about the following?
> >
> > If it is necessary for an UNLOCK-LOCK pair to
> > produce a full barrier, the LOCK can be followed by an
> > smp_mb__after_unlock_lock() invocation. This will produce a
> > full barrier if either (a) the UNLOCK and the LOCK are executed
> > by the same CPU or task, or (b) the UNLOCK and LOCK act on the
> > same lock variable.
>
> So you're still requiring smp_mb__after_unlock_lock() even if they're on
> the same variable?
Yep!
> > The smp_mb__after_unlock_lock() primitive is
> > free on many architectures. Without smp_mb__after_unlock_lock(),
> > the UNLOCK and LOCK can cross:
>
> Contradicted below :-)
Good eyes! I changed this to:
The smp_mb__after_unlock_lock() primitive is free on many
architectures. Without smp_mb__after_unlock_lock(), the critical
sections corresponding to the UNLOCK and the LOCK can cross:
Is that better?
> > *A = a;
> > UNLOCK M
> > LOCK N
> > *B = b;
> >
> > could occur as:
> >
> > LOCK N, STORE *B, STORE *A, UNLOCK M
> >
> > With smp_mb__after_unlock_lock(), they cannot, so that:
> >
> > *A = a;
> > UNLOCK M
> > LOCK N
> > smp_mb__after_unlock_lock();
> > *B = b;
> >
> > will always occur as either of the following:
> >
> > STORE *A, UNLOCK, LOCK, STORE *B
> > STORE *A, LOCK, UNLOCK, STORE *B
>
> See, UNLOCK and LOCK can still cross :-)
Indeed they can! ;-)
> > If the UNLOCK and LOCK were instead both operating on the same
> > lock variable, only the first of these two alternatives can occur.
>
> Agreed.
>
> Sorry for being a pedant. :-)
;-) ;-) ;-)
Thanx, Paul
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists