Re: [PATCH v5 tip/core/locking 5/7] Documentation/memory-barriers.txt: Downgrade UNLOCK+LOCK

2013-12-10 Thread Paul E. McKenney
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 differ

Re: [PATCH v5 tip/core/locking 5/7] Documentation/memory-barriers.txt: Downgrade UNLOCK+LOCK

2013-12-10 Thread Paul E. McKenney
On Tue, Dec 10, 2013 at 09:43:20AM -0800, Josh Triplett wrote: > On Tue, Dec 10, 2013 at 06:25:28PM +0100, Peter Zijlstra wrote: > > On Tue, Dec 10, 2013 at 09:12:47AM -0800, Paul E. McKenney wrote: > > > > The way I read the above it says that you need > > > > smp_mb__after_unlock_lock() when the

Re: [PATCH v5 tip/core/locking 5/7] Documentation/memory-barriers.txt: Downgrade UNLOCK+LOCK

2013-12-10 Thread Paul E. McKenney
On Tue, Dec 10, 2013 at 06:25:28PM +0100, Peter Zijlstra wrote: > On Tue, Dec 10, 2013 at 09:12:47AM -0800, Paul E. McKenney wrote: > > > The way I read the above it says that you need > > > smp_mb__after_unlock_lock() when the UNLOCK and LOCK are on the same > > > variable. That doesn't make sense

Re: [PATCH v5 tip/core/locking 5/7] Documentation/memory-barriers.txt: Downgrade UNLOCK+LOCK

2013-12-10 Thread Peter Zijlstra
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 foll

Re: [PATCH v5 tip/core/locking 5/7] Documentation/memory-barriers.txt: Downgrade UNLOCK+LOCK

2013-12-10 Thread Josh Triplett
On Tue, Dec 10, 2013 at 06:25:28PM +0100, Peter Zijlstra wrote: > On Tue, Dec 10, 2013 at 09:12:47AM -0800, Paul E. McKenney wrote: > > > The way I read the above it says that you need > > > smp_mb__after_unlock_lock() when the UNLOCK and LOCK are on the same > > > variable. That doesn't make sense

Re: [PATCH v5 tip/core/locking 5/7] Documentation/memory-barriers.txt: Downgrade UNLOCK+LOCK

2013-12-10 Thread Oleg Nesterov
On 12/10, Paul E. McKenney wrote: > > On Tue, Dec 10, 2013 at 05:44:37PM +0100, Oleg Nesterov wrote: > > > > Well, but smp_mb__before_spinlock + LOCK is not wmb... But it is not > > the full barrier. It should guarantee that, say, > > > > CONDITION = true; // 1 > > > > // try_

Re: [PATCH v5 tip/core/locking 5/7] Documentation/memory-barriers.txt: Downgrade UNLOCK+LOCK

2013-12-10 Thread Peter Zijlstra
On Tue, Dec 10, 2013 at 09:12:47AM -0800, Paul E. McKenney wrote: > > The way I read the above it says that you need > > smp_mb__after_unlock_lock() when the UNLOCK and LOCK are on the same > > variable. That doesn't make sense, I thought that was the one case we > > all agreed on it would indeed b

Re: [PATCH v5 tip/core/locking 5/7] Documentation/memory-barriers.txt: Downgrade UNLOCK+LOCK

2013-12-10 Thread Paul E. McKenney
On Tue, Dec 10, 2013 at 05:44:37PM +0100, Oleg Nesterov wrote: > On 12/09, Paul E. McKenney wrote: > > > > @@ -1626,7 +1626,10 @@ for each construct. These operations all imply > > certain barriers: > > operation has completed. > > > > Memory operations issued before the LOCK may be c

Re: [PATCH v5 tip/core/locking 5/7] Documentation/memory-barriers.txt: Downgrade UNLOCK+LOCK

2013-12-10 Thread Paul E. McKenney
On Tue, Dec 10, 2013 at 02:14:22PM +0100, Peter Zijlstra wrote: > On Mon, Dec 09, 2013 at 05:28:01PM -0800, Paul E. McKenney wrote: > > +An UNLOCK followed by a LOCK may -not- be assumed to be a full memory > > +barrier because it is possible for a preceding UNLOCK to pass a later LOCK > > +from th

Re: [PATCH v5 tip/core/locking 5/7] Documentation/memory-barriers.txt: Downgrade UNLOCK+LOCK

2013-12-10 Thread Oleg Nesterov
On 12/09, Paul E. McKenney wrote: > > @@ -1626,7 +1626,10 @@ for each construct. These operations all imply > certain barriers: > operation has completed. > > Memory operations issued before the LOCK may be completed after the LOCK > - operation has completed. > + operation ha

Re: [PATCH v5 tip/core/locking 5/7] Documentation/memory-barriers.txt: Downgrade UNLOCK+LOCK

2013-12-10 Thread Peter Zijlstra
On Mon, Dec 09, 2013 at 05:28:01PM -0800, Paul E. McKenney wrote: > +An UNLOCK followed by a LOCK may -not- be assumed to be a full memory > +barrier because it is possible for a preceding UNLOCK to pass a later LOCK > +from the viewpoint of the CPU, but not from the viewpoint of the compiler. > +N

Re: [PATCH v5 tip/core/locking 5/7] Documentation/memory-barriers.txt: Downgrade UNLOCK+LOCK

2013-12-09 Thread Paul E. McKenney
On Mon, Dec 09, 2013 at 05:32:31PM -0800, Josh Triplett wrote: > On Mon, Dec 09, 2013 at 05:28:01PM -0800, Paul E. McKenney wrote: > > From: "Paul E. McKenney" > > > > Historically, an UNLOCK+LOCK pair executed by one CPU, by one task, > > or on a given lock variable has implied a full memory bar

Re: [PATCH v5 tip/core/locking 5/7] Documentation/memory-barriers.txt: Downgrade UNLOCK+LOCK

2013-12-09 Thread Josh Triplett
On Mon, Dec 09, 2013 at 05:28:01PM -0800, Paul E. McKenney wrote: > From: "Paul E. McKenney" > > Historically, an UNLOCK+LOCK pair executed by one CPU, by one task, > or on a given lock variable has implied a full memory barrier. In a > recent LKML thread, the wisdom of this historical approach

[PATCH v5 tip/core/locking 5/7] Documentation/memory-barriers.txt: Downgrade UNLOCK+LOCK

2013-12-09 Thread Paul E. McKenney
From: "Paul E. McKenney" Historically, an UNLOCK+LOCK pair executed by one CPU, by one task, or on a given lock variable has implied a full memory barrier. In a recent LKML thread, the wisdom of this historical approach was called into question: http://www.spinics.net/lists/linux-mm/msg65653.htm