Re: spin_lock implicit/explicit memory barrier

2016-08-22 Thread Boqun Feng
On Fri, Aug 12, 2016 at 08:43:55PM +0200, Manfred Spraul wrote: > Hi Boqun, > > On 08/12/2016 04:47 AM, Boqun Feng wrote: > > > We should not be doing an smp_mb() right after a spin_lock(), makes no > > > sense. The > > > spinlock machinery should guarantee us the barriers in the unorthodox > >

Re: spin_lock implicit/explicit memory barrier

2016-08-19 Thread Peter Zijlstra
On Fri, Aug 12, 2016 at 10:59:46AM +0800, Boqun Feng wrote: > But if an arch implements its spin_lock() with a full barrier, even > though the atomic is implemented by ll/sc, the STORE part of which can't > be reordered with memory operations in the critcal sections. I think > maybe that's the case

Re: spin_lock implicit/explicit memory barrier

2016-08-15 Thread Paul E. McKenney
On Mon, Aug 15, 2016 at 10:06:39PM +0200, Manfred Spraul wrote: > Hi Paul, > > On 08/10/2016 11:00 PM, Paul E. McKenney wrote: > >On Wed, Aug 10, 2016 at 12:17:57PM -0700, Davidlohr Bueso wrote: > >>[...] > >> CPU0 CPU1 > >> complex_mode = truespin_lock(l)

Re: spin_lock implicit/explicit memory barrier

2016-08-15 Thread Manfred Spraul
Hi Paul, On 08/10/2016 11:00 PM, Paul E. McKenney wrote: On Wed, Aug 10, 2016 at 12:17:57PM -0700, Davidlohr Bueso wrote: [...] CPU0 CPU1 complex_mode = truespin_lock(l) smp_mb() <--- do we want a smp_mb() here? spin_unlock

Re: spin_lock implicit/explicit memory barrier

2016-08-12 Thread Manfred Spraul
Hi Boqun, On 08/12/2016 04:47 AM, Boqun Feng wrote: We should not be doing an smp_mb() right after a spin_lock(), makes no sense. The spinlock machinery should guarantee us the barriers in the unorthodox locking cases, such as this. Do we really want to go there? Trying to handle all unortho

Re: spin_lock implicit/explicit memory barrier

2016-08-11 Thread Boqun Feng
On Thu, Aug 11, 2016 at 11:31:06AM -0700, Davidlohr Bueso wrote: > On Thu, 11 Aug 2016, Peter Zijlstra wrote: > > > On Wed, Aug 10, 2016 at 04:29:22PM -0700, Davidlohr Bueso wrote: > > > > > (1) As Manfred suggested, have a patch 1 that fixes the race against > > > mainline > > > with the redund

Re: spin_lock implicit/explicit memory barrier

2016-08-11 Thread Boqun Feng
On Wed, Aug 10, 2016 at 12:17:57PM -0700, Davidlohr Bueso wrote: > On Wed, 10 Aug 2016, Manfred Spraul wrote: > > > On 08/10/2016 02:05 AM, Benjamin Herrenschmidt wrote: > > > On Tue, 2016-08-09 at 20:52 +0200, Manfred Spraul wrote: > > > > Hi Benjamin, Hi Michael, > > > > > > > > regarding commi

Re: spin_lock implicit/explicit memory barrier

2016-08-11 Thread Davidlohr Bueso
On Thu, 11 Aug 2016, Peter Zijlstra wrote: On Wed, Aug 10, 2016 at 04:29:22PM -0700, Davidlohr Bueso wrote: (1) As Manfred suggested, have a patch 1 that fixes the race against mainline with the redundant smp_rmb, then apply a second patch that gets rid of it for mainline, but only backport th

Re: spin_lock implicit/explicit memory barrier

2016-08-11 Thread Peter Zijlstra
On Wed, Aug 10, 2016 at 04:29:22PM -0700, Davidlohr Bueso wrote: > (1) As Manfred suggested, have a patch 1 that fixes the race against mainline > with the redundant smp_rmb, then apply a second patch that gets rid of it > for mainline, but only backport the original patch 1 down to 3.12. I have

Re: spin_lock implicit/explicit memory barrier

2016-08-10 Thread Benjamin Herrenschmidt
On Wed, 2016-08-10 at 15:23 -0700, Davidlohr Bueso wrote: > On Wed, 10 Aug 2016, Paul E. McKenney wrote: > > > > > On Wed, Aug 10, 2016 at 08:21:22PM +0200, Manfred Spraul wrote: >   4) > > > spin_unlock_wait() and spin_unlock() pair > >

Re: spin_lock implicit/explicit memory barrier

2016-08-10 Thread Davidlohr Bueso
On Wed, 10 Aug 2016, Paul E. McKenney wrote: On Wed, Aug 10, 2016 at 03:23:16PM -0700, Davidlohr Bueso wrote: On Wed, 10 Aug 2016, Paul E. McKenney wrote: >On Wed, Aug 10, 2016 at 08:21:22PM +0200, Manfred Spraul wrote: >> 4) >>spin

Re: spin_lock implicit/explicit memory barrier

2016-08-10 Thread Paul E. McKenney
On Wed, Aug 10, 2016 at 03:23:16PM -0700, Davidlohr Bueso wrote: > On Wed, 10 Aug 2016, Paul E. McKenney wrote: > > >On Wed, Aug 10, 2016 at 08:21:22PM +0200, Manfred Spraul wrote: > > >> 4) > >>spin_unlock_wait() and spin_unlock() pair

Re: spin_lock implicit/explicit memory barrier

2016-08-10 Thread Davidlohr Bueso
On Wed, 10 Aug 2016, Paul E. McKenney wrote: On Wed, Aug 10, 2016 at 08:21:22PM +0200, Manfred Spraul wrote: 4) spin_unlock_wait() and spin_unlock() pair http://git.cmpxchg.org/cgit.cgi/linux-mmots.git/tree/ipc/sem.c#n291 http://gi

Re: spin_lock implicit/explicit memory barrier

2016-08-10 Thread Paul E. McKenney
On Wed, Aug 10, 2016 at 12:17:57PM -0700, Davidlohr Bueso wrote: > On Wed, 10 Aug 2016, Manfred Spraul wrote: > > >On 08/10/2016 02:05 AM, Benjamin Herrenschmidt wrote: > >>On Tue, 2016-08-09 at 20:52 +0200, Manfred Spraul wrote: > >>>Hi Benjamin, Hi Michael, > >>> > >>>regarding commit 51d7d5205d

Re: spin_lock implicit/explicit memory barrier

2016-08-10 Thread Paul E. McKenney
On Wed, Aug 10, 2016 at 08:21:22PM +0200, Manfred Spraul wrote: > Hi, > > [adding Peter, correcting Davidlohr's mail address] > > On 08/10/2016 02:05 AM, Benjamin Herrenschmidt wrote: > >On Tue, 2016-08-09 at 20:52 +0200, Manfred Spraul wrote: > >>Hi Benjamin, Hi Michael, > >> > >>regarding commi

Re: spin_lock implicit/explicit memory barrier

2016-08-10 Thread Paul E. McKenney
On Wed, Aug 10, 2016 at 10:05:37AM +1000, Benjamin Herrenschmidt wrote: > On Tue, 2016-08-09 at 20:52 +0200, Manfred Spraul wrote: > > Hi Benjamin, Hi Michael, > > > > regarding commit 51d7d5205d33 ("powerpc: Add smp_mb() to  > > arch_spin_is_locked()"): > > > > For the ipc/sem code, I would like

Re: spin_lock implicit/explicit memory barrier

2016-08-10 Thread Davidlohr Bueso
On Wed, 10 Aug 2016, Manfred Spraul wrote: On 08/10/2016 02:05 AM, Benjamin Herrenschmidt wrote: On Tue, 2016-08-09 at 20:52 +0200, Manfred Spraul wrote: Hi Benjamin, Hi Michael, regarding commit 51d7d5205d33 ("powerpc: Add smp_mb() to arch_spin_is_locked()"): For the ipc/sem code, I would l

Re: spin_lock implicit/explicit memory barrier

2016-08-10 Thread Manfred Spraul
Hi, [adding Peter, correcting Davidlohr's mail address] On 08/10/2016 02:05 AM, Benjamin Herrenschmidt wrote: On Tue, 2016-08-09 at 20:52 +0200, Manfred Spraul wrote: Hi Benjamin, Hi Michael, regarding commit 51d7d5205d33 ("powerpc: Add smp_mb() to arch_spin_is_locked()"): For the ipc/sem co

Re: spin_lock implicit/explicit memory barrier

2016-08-09 Thread Benjamin Herrenschmidt
On Tue, 2016-08-09 at 20:52 +0200, Manfred Spraul wrote: > Hi Benjamin, Hi Michael, > > regarding commit 51d7d5205d33 ("powerpc: Add smp_mb() to  > arch_spin_is_locked()"): > > For the ipc/sem code, I would like to replace the spin_is_locked() with  > a smp_load_acquire(), see: > > http://git.cm

spin_lock implicit/explicit memory barrier

2016-08-09 Thread Manfred Spraul
Hi Benjamin, Hi Michael, regarding commit 51d7d5205d33 ("powerpc: Add smp_mb() to arch_spin_is_locked()"): For the ipc/sem code, I would like to replace the spin_is_locked() with a smp_load_acquire(), see: http://git.cmpxchg.org/cgit.cgi/linux-mmots.git/tree/ipc/sem.c#n367 http://www.ozlab