Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-21 Thread Paul E. McKenney
On Wed, Oct 21, 2015 at 09:36:44PM +0200, Peter Zijlstra wrote: > On Wed, Oct 21, 2015 at 12:29:23PM -0700, Paul E. McKenney wrote: > > On Wed, Oct 21, 2015 at 10:24:52AM +0200, Peter Zijlstra wrote: > > > On Tue, Oct 20, 2015 at 04:34:51PM -0700, Paul E. McKenney wrote: > > > > There is also the q

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-21 Thread Peter Zijlstra
On Wed, Oct 21, 2015 at 12:29:23PM -0700, Paul E. McKenney wrote: > On Wed, Oct 21, 2015 at 10:24:52AM +0200, Peter Zijlstra wrote: > > On Tue, Oct 20, 2015 at 04:34:51PM -0700, Paul E. McKenney wrote: > > > There is also the question of whether the barrier forces ordering > > > of unrelated stores

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-21 Thread Paul E. McKenney
On Wed, Oct 21, 2015 at 04:04:04PM +, David Laight wrote: > From: Paul E. McKenney > > Sent: 21 October 2015 00:35 > ... > > There is also the question of whether the barrier forces ordering > > of unrelated stores, everything initially zero and all accesses > > READ_ONCE() or WRITE_ONCE(): > >

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-21 Thread Paul E. McKenney
On Wed, Oct 21, 2015 at 10:24:52AM +0200, Peter Zijlstra wrote: > On Tue, Oct 20, 2015 at 04:34:51PM -0700, Paul E. McKenney wrote: > > There is also the question of whether the barrier forces ordering > > of unrelated stores, everything initially zero and all accesses > > READ_ONCE() or WRITE_ONCE

RE: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-21 Thread David Laight
From: Paul E. McKenney > Sent: 21 October 2015 00:35 ... > There is also the question of whether the barrier forces ordering > of unrelated stores, everything initially zero and all accesses > READ_ONCE() or WRITE_ONCE(): > > P0 P1 P2 P3 > X = 1;

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-21 Thread Peter Zijlstra
On Tue, Oct 20, 2015 at 04:34:51PM -0700, Paul E. McKenney wrote: > There is also the question of whether the barrier forces ordering > of unrelated stores, everything initially zero and all accesses > READ_ONCE() or WRITE_ONCE(): > > P0 P1 P2 P3 >

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-20 Thread Paul E. McKenney
On Mon, Oct 19, 2015 at 09:17:18AM +0800, Boqun Feng wrote: > On Fri, Oct 09, 2015 at 10:40:39AM +0100, Will Deacon wrote: > > On Fri, Oct 09, 2015 at 10:31:38AM +0200, Peter Zijlstra wrote: > [snip] > > > > > > So lots of little confusions added up to complete fail :-{ > > > > > > Mostly I think

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-20 Thread Boqun Feng
On Mon, Oct 12, 2015 at 04:30:48PM -0700, Paul E. McKenney wrote: > On Fri, Oct 09, 2015 at 07:33:28PM +0100, Will Deacon wrote: > > On Fri, Oct 09, 2015 at 10:43:27AM -0700, Paul E. McKenney wrote: > > > On Fri, Oct 09, 2015 at 10:51:29AM +0100, Will Deacon wrote: [snip] > > > > > We could also i

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-20 Thread Boqun Feng
On Mon, Oct 19, 2015 at 12:23:24PM +0200, Peter Zijlstra wrote: > On Mon, Oct 19, 2015 at 09:17:18AM +0800, Boqun Feng wrote: > > This is confusing me right now. ;-) > > > > Let's use a simple example for only one primitive, as I understand it, > > if we say a primitive A is "fully ordered", we ac

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-19 Thread Peter Zijlstra
On Mon, Oct 19, 2015 at 09:17:18AM +0800, Boqun Feng wrote: > This is confusing me right now. ;-) > > Let's use a simple example for only one primitive, as I understand it, > if we say a primitive A is "fully ordered", we actually mean: > > 1.The memory operations preceding(in program order)

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-18 Thread Boqun Feng
On Fri, Oct 09, 2015 at 10:40:39AM +0100, Will Deacon wrote: > On Fri, Oct 09, 2015 at 10:31:38AM +0200, Peter Zijlstra wrote: [snip] > > > > So lots of little confusions added up to complete fail :-{ > > > > Mostly I think it was the UNLOCK x + LOCK x are fully ordered (where I > > forgot: but n

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-12 Thread Paul E. McKenney
On Fri, Oct 09, 2015 at 07:33:28PM +0100, Will Deacon wrote: > On Fri, Oct 09, 2015 at 10:43:27AM -0700, Paul E. McKenney wrote: > > On Fri, Oct 09, 2015 at 10:51:29AM +0100, Will Deacon wrote: > > > How do people feel about including these in memory-barriers.txt? I find > > > them considerably eas

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-09 Thread Will Deacon
On Fri, Oct 09, 2015 at 10:43:27AM -0700, Paul E. McKenney wrote: > On Fri, Oct 09, 2015 at 10:51:29AM +0100, Will Deacon wrote: > > How do people feel about including these in memory-barriers.txt? I find > > them considerably easier to read than our current kernel code + list of > > possible order

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-09 Thread Paul E. McKenney
On Fri, Oct 09, 2015 at 01:25:54PM +0200, Peter Zijlstra wrote: > On Fri, Oct 09, 2015 at 10:51:29AM +0100, Will Deacon wrote: > > > The corresponding litmus tests are below. > > > > How do people feel about including these in memory-barriers.txt? I find > > them considerably easier to read than o

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-09 Thread Paul E. McKenney
On Fri, Oct 09, 2015 at 10:51:29AM +0100, Will Deacon wrote: > Hi Paul, > > On Thu, Oct 08, 2015 at 03:17:16PM -0700, Paul E. McKenney wrote: > > On Thu, Oct 08, 2015 at 01:59:38PM +0100, Will Deacon wrote: > > > I thought Paul was talking about something like this case: > > > > > > CPU A CPU

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-09 Thread Paul E. McKenney
On Fri, Oct 09, 2015 at 10:40:39AM +0100, Will Deacon wrote: > On Fri, Oct 09, 2015 at 10:31:38AM +0200, Peter Zijlstra wrote: > > On Thu, Oct 08, 2015 at 02:44:39PM -0700, Paul E. McKenney wrote: > > > On Thu, Oct 08, 2015 at 01:16:38PM +0200, Peter Zijlstra wrote: > > > > On Thu, Oct 08, 2015 at

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-09 Thread Peter Zijlstra
On Fri, Oct 09, 2015 at 01:51:11PM +0100, Will Deacon wrote: > On Fri, Oct 09, 2015 at 01:12:02PM +0200, Peter Zijlstra wrote: > > On Fri, Oct 09, 2015 at 10:40:39AM +0100, Will Deacon wrote: > > > > Which leads me to think I would like to suggest alternative rules for > > > > RELEASE/ACQUIRE (to r

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-09 Thread Will Deacon
On Fri, Oct 09, 2015 at 01:12:02PM +0200, Peter Zijlstra wrote: > On Fri, Oct 09, 2015 at 10:40:39AM +0100, Will Deacon wrote: > > > Which leads me to think I would like to suggest alternative rules for > > > RELEASE/ACQUIRE (to replace those Will suggested; as I think those are > > > partly respon

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-09 Thread Will Deacon
On Fri, Oct 09, 2015 at 01:02:46PM +0200, Peter Zijlstra wrote: > On Fri, Oct 09, 2015 at 10:40:39AM +0100, Will Deacon wrote: > > Stepping back a second, I believe that there are three cases: > > > > > > RELEASE X -> ACQUIRE Y (same CPU) > >* Needs a barrier on TSO architectures for full or

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-09 Thread Peter Zijlstra
On Fri, Oct 09, 2015 at 10:51:29AM +0100, Will Deacon wrote: > > The corresponding litmus tests are below. > > How do people feel about including these in memory-barriers.txt? I find > them considerably easier to read than our current kernel code + list of > possible orderings + wall of text, but

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-09 Thread Peter Zijlstra
On Fri, Oct 09, 2015 at 10:40:39AM +0100, Will Deacon wrote: > > > - RELEASE -> ACQUIRE _chains_ (on shared variables) preserve causality, > >(because each link is fully ordered) but are not transitive. > > Yup, and that's the same for UNLOCK -> LOCK, too. Agreed, except RELEASE/ACQUIRE is

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-09 Thread Peter Zijlstra
On Fri, Oct 09, 2015 at 10:40:39AM +0100, Will Deacon wrote: > > Which leads me to think I would like to suggest alternative rules for > > RELEASE/ACQUIRE (to replace those Will suggested; as I think those are > > partly responsible for my confusion). > > Yeah, sorry. I originally used the phrase

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-09 Thread Peter Zijlstra
On Fri, Oct 09, 2015 at 10:40:39AM +0100, Will Deacon wrote: > Stepping back a second, I believe that there are three cases: > > > RELEASE X -> ACQUIRE Y (same CPU) >* Needs a barrier on TSO architectures for full ordering +PPC > UNLOCK X -> LOCK Y (same CPU) >* Needs a barrier

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-09 Thread Will Deacon
Hi Paul, On Thu, Oct 08, 2015 at 03:17:16PM -0700, Paul E. McKenney wrote: > On Thu, Oct 08, 2015 at 01:59:38PM +0100, Will Deacon wrote: > > I thought Paul was talking about something like this case: > > > > CPU A CPU B CPU C > > foo = 1 > > UNLOCK x > > LOCK x > >

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-09 Thread Will Deacon
On Fri, Oct 09, 2015 at 10:31:38AM +0200, Peter Zijlstra wrote: > On Thu, Oct 08, 2015 at 02:44:39PM -0700, Paul E. McKenney wrote: > > On Thu, Oct 08, 2015 at 01:16:38PM +0200, Peter Zijlstra wrote: > > > On Thu, Oct 08, 2015 at 02:50:36PM +1100, Michael Ellerman wrote: > > > > On Wed, 2015-10-07

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-09 Thread Peter Zijlstra
On Thu, Oct 08, 2015 at 02:44:39PM -0700, Paul E. McKenney wrote: > On Thu, Oct 08, 2015 at 01:16:38PM +0200, Peter Zijlstra wrote: > > On Thu, Oct 08, 2015 at 02:50:36PM +1100, Michael Ellerman wrote: > > > On Wed, 2015-10-07 at 08:25 -0700, Paul E. McKenney wrote: > > > > > > Currently, we do ne

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-09 Thread Peter Zijlstra
On Thu, Oct 08, 2015 at 02:44:39PM -0700, Paul E. McKenney wrote: > > > > I am with Peter -- we do need the benchmark results for PPC. > > > > > > Urgh, sorry guys. I have been slowly doing some benchmarks, but time is > > > not > > > plentiful at the moment. > > > > > > If we do a straight lws

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-08 Thread Paul E. McKenney
On Thu, Oct 08, 2015 at 01:59:38PM +0100, Will Deacon wrote: > On Thu, Oct 08, 2015 at 01:16:38PM +0200, Peter Zijlstra wrote: > > On Thu, Oct 08, 2015 at 02:50:36PM +1100, Michael Ellerman wrote: > > > On Wed, 2015-10-07 at 08:25 -0700, Paul E. McKenney wrote: > > > > > > Currently, we do need sm

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-08 Thread Paul E. McKenney
On Thu, Oct 08, 2015 at 01:16:38PM +0200, Peter Zijlstra wrote: > On Thu, Oct 08, 2015 at 02:50:36PM +1100, Michael Ellerman wrote: > > On Wed, 2015-10-07 at 08:25 -0700, Paul E. McKenney wrote: > > > > Currently, we do need smp_mb__after_unlock_lock() to be after the > > > acquisition on PPC -- p

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-08 Thread Will Deacon
On Thu, Oct 08, 2015 at 01:16:38PM +0200, Peter Zijlstra wrote: > On Thu, Oct 08, 2015 at 02:50:36PM +1100, Michael Ellerman wrote: > > On Wed, 2015-10-07 at 08:25 -0700, Paul E. McKenney wrote: > > > > Currently, we do need smp_mb__after_unlock_lock() to be after the > > > acquisition on PPC -- p

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-08 Thread Peter Zijlstra
On Thu, Oct 08, 2015 at 02:50:36PM +1100, Michael Ellerman wrote: > On Wed, 2015-10-07 at 08:25 -0700, Paul E. McKenney wrote: > > Currently, we do need smp_mb__after_unlock_lock() to be after the > > acquisition on PPC -- putting it between the unlock and the lock > > of course doesn't cut it for

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-07 Thread Michael Ellerman
On Wed, 2015-10-07 at 08:25 -0700, Paul E. McKenney wrote: > On Wed, Oct 07, 2015 at 02:23:17PM +0100, Will Deacon wrote: > > Hi Peter, > > > > Thanks for the headache ;) > > > > On Wed, Oct 07, 2015 at 01:19:15PM +0200, Peter Zijlstra wrote: > > > On Wed, Oct 07, 2015 at 11:59:28AM +0100, Will D

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-07 Thread Paul E. McKenney
On Wed, Oct 07, 2015 at 02:23:17PM +0100, Will Deacon wrote: > Hi Peter, > > Thanks for the headache ;) > > On Wed, Oct 07, 2015 at 01:19:15PM +0200, Peter Zijlstra wrote: > > On Wed, Oct 07, 2015 at 11:59:28AM +0100, Will Deacon wrote: > > > As much as we'd like to live in a world where RELEASE

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-07 Thread Peter Zijlstra
On Wed, Oct 07, 2015 at 02:23:17PM +0100, Will Deacon wrote: > Hi Peter, > > Thanks for the headache ;) Most welcome :-) > > Does we want to go revert 12d560f4ea87 ("rcu,locking: Privatize > > smp_mb__after_unlock_lock()") for that same reason? > > I don't think we want a straight revert. smp_m

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-07 Thread Will Deacon
Hi Peter, Thanks for the headache ;) On Wed, Oct 07, 2015 at 01:19:15PM +0200, Peter Zijlstra wrote: > On Wed, Oct 07, 2015 at 11:59:28AM +0100, Will Deacon wrote: > > As much as we'd like to live in a world where RELEASE -> ACQUIRE is > > always cheaply ordered and can be used to construct UNLOC

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-07 Thread Peter Zijlstra
On Wed, Oct 07, 2015 at 11:59:28AM +0100, Will Deacon wrote: > As much as we'd like to live in a world where RELEASE -> ACQUIRE is > always cheaply ordered and can be used to construct UNLOCK -> LOCK > definitions with similar guarantees, the grim reality is that this isn't > even possible on x86 (

[PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-07 Thread Will Deacon
As much as we'd like to live in a world where RELEASE -> ACQUIRE is always cheaply ordered and can be used to construct UNLOCK -> LOCK definitions with similar guarantees, the grim reality is that this isn't even possible on x86 (thanks to Paul for bringing us crashing down to Earth). This patch h