Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-03-06 Thread Peter Zijlstra
On Mon, Feb 26, 2018 at 09:00:43AM -0800, Linus Torvalds wrote: > On Mon, Feb 26, 2018 at 8:24 AM, Will Deacon wrote: > > > > Strictly speaking, that's not what we've got implemented on arm64: only > > the read part of the RmW has Acquire semantics, but there is a total > > order on the lock/unloc

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-03-01 Thread Daniel Lustig
On 3/1/2018 1:54 PM, Palmer Dabbelt wrote: > On Thu, 01 Mar 2018 07:11:41 PST (-0800), parri.and...@gmail.com wrote: >> Hi Daniel, >> >> On Thu, Feb 22, 2018 at 11:47:57AM -0800, Daniel Lustig wrote: >>> On 2/22/2018 10:27 AM, Peter Zijlstra wrote: >>> > On Thu, Feb 22, 2018 at 10:13:17AM -0800, Pa

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-03-01 Thread Palmer Dabbelt
On Thu, 01 Mar 2018 07:11:41 PST (-0800), parri.and...@gmail.com wrote: Hi Daniel, On Thu, Feb 22, 2018 at 11:47:57AM -0800, Daniel Lustig wrote: On 2/22/2018 10:27 AM, Peter Zijlstra wrote: > On Thu, Feb 22, 2018 at 10:13:17AM -0800, Paul E. McKenney wrote: >> So we have something that is not

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-03-01 Thread Andrea Parri
Hi Daniel, On Thu, Feb 22, 2018 at 11:47:57AM -0800, Daniel Lustig wrote: > On 2/22/2018 10:27 AM, Peter Zijlstra wrote: > > On Thu, Feb 22, 2018 at 10:13:17AM -0800, Paul E. McKenney wrote: > >> So we have something that is not all that rare in the Linux kernel > >> community, namely two conflict

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-27 Thread Boqun Feng
On Tue, Feb 27, 2018 at 01:06:35PM +0800, Boqun Feng wrote: > On Mon, Feb 26, 2018 at 04:24:27PM +, Will Deacon wrote: > > On Mon, Feb 26, 2018 at 08:06:59AM -0800, Linus Torvalds wrote: > > > On Mon, Feb 26, 2018 at 6:21 AM, Luc Maranget > > > wrote: > > > > > > > > That is, locks are not im

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-26 Thread Boqun Feng
On Mon, Feb 26, 2018 at 04:24:27PM +, Will Deacon wrote: > On Mon, Feb 26, 2018 at 08:06:59AM -0800, Linus Torvalds wrote: > > On Mon, Feb 26, 2018 at 6:21 AM, Luc Maranget wrote: > > > > > > That is, locks are not implemented from more basic primitive but are > > > specified. > > > The speci

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-26 Thread Will Deacon
On Mon, Feb 26, 2018 at 09:00:43AM -0800, Linus Torvalds wrote: > On Mon, Feb 26, 2018 at 8:24 AM, Will Deacon wrote: > > > > Strictly speaking, that's not what we've got implemented on arm64: only > > the read part of the RmW has Acquire semantics, but there is a total > > order on the lock/unloc

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-26 Thread Linus Torvalds
On Mon, Feb 26, 2018 at 8:24 AM, Will Deacon wrote: > > Strictly speaking, that's not what we've got implemented on arm64: only > the read part of the RmW has Acquire semantics, but there is a total > order on the lock/unlock operations for the lock. Hmm. I thought we had exactly that bug on som

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-26 Thread Will Deacon
On Mon, Feb 26, 2018 at 08:06:59AM -0800, Linus Torvalds wrote: > On Mon, Feb 26, 2018 at 6:21 AM, Luc Maranget wrote: > > > > That is, locks are not implemented from more basic primitive but are > > specified. > > The specification can be described as behaving that way: > > - A lock behaves as

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-26 Thread Linus Torvalds
On Mon, Feb 26, 2018 at 6:21 AM, Luc Maranget wrote: > > That is, locks are not implemented from more basic primitive but are > specified. > The specification can be described as behaving that way: > - A lock behaves as a read-modify-write. the read behaving as a read-acquire This is wrong, or

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-26 Thread Luc Maranget
> On 2/22/2018 10:27 AM, Peter Zijlstra wrote: > > On Thu, Feb 22, 2018 at 10:13:17AM -0800, Paul E. McKenney wrote: > >> So we have something that is not all that rare in the Linux kernel > >> community, namely two conflicting more-or-less concurrent changes. > >> This clearly needs to be resolved

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-26 Thread Will Deacon
On Thu, Feb 22, 2018 at 11:47:57AM -0800, Daniel Lustig wrote: > On 2/22/2018 10:27 AM, Peter Zijlstra wrote: > > On Thu, Feb 22, 2018 at 10:13:17AM -0800, Paul E. McKenney wrote: > >> So we have something that is not all that rare in the Linux kernel > >> community, namely two conflicting more-or-

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-23 Thread Andrea Parri
On Thu, Feb 22, 2018 at 11:47:57AM -0800, Daniel Lustig wrote: > On 2/22/2018 10:27 AM, Peter Zijlstra wrote: > > On Thu, Feb 22, 2018 at 10:13:17AM -0800, Paul E. McKenney wrote: > >> So we have something that is not all that rare in the Linux kernel > >> community, namely two conflicting more-or-

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-22 Thread Paul E. McKenney
On Thu, Feb 22, 2018 at 07:27:17PM +0100, Peter Zijlstra wrote: > On Thu, Feb 22, 2018 at 10:13:17AM -0800, Paul E. McKenney wrote: > > So we have something that is not all that rare in the Linux kernel > > community, namely two conflicting more-or-less concurrent changes. > > This clearly needs to

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-22 Thread Daniel Lustig
On 2/22/2018 10:27 AM, Peter Zijlstra wrote: > On Thu, Feb 22, 2018 at 10:13:17AM -0800, Paul E. McKenney wrote: >> So we have something that is not all that rare in the Linux kernel >> community, namely two conflicting more-or-less concurrent changes. >> This clearly needs to be resolved, either b

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-22 Thread Peter Zijlstra
On Thu, Feb 22, 2018 at 10:13:17AM -0800, Paul E. McKenney wrote: > So we have something that is not all that rare in the Linux kernel > community, namely two conflicting more-or-less concurrent changes. > This clearly needs to be resolved, either by us not strengthening the > Linux-kernel memory m

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-22 Thread Peter Zijlstra
On Thu, Feb 22, 2018 at 09:27:09AM -0800, Daniel Lustig wrote: > On 2/22/2018 6:12 AM, Andrea Parri wrote: > > On Thu, Feb 22, 2018 at 02:40:04PM +0100, Peter Zijlstra wrote: > >> On Thu, Feb 22, 2018 at 01:19:50PM +0100, Andrea Parri wrote: > >> > >>> C unlock-lock-read-ordering > >>> > >>> {} > >

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-22 Thread Paul E. McKenney
On Thu, Feb 22, 2018 at 09:27:09AM -0800, Daniel Lustig wrote: > On 2/22/2018 6:12 AM, Andrea Parri wrote: > > On Thu, Feb 22, 2018 at 02:40:04PM +0100, Peter Zijlstra wrote: > >> On Thu, Feb 22, 2018 at 01:19:50PM +0100, Andrea Parri wrote: > >> > >>> C unlock-lock-read-ordering > >>> > >>> {} > >

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-22 Thread Daniel Lustig
On 2/22/2018 6:12 AM, Andrea Parri wrote: > On Thu, Feb 22, 2018 at 02:40:04PM +0100, Peter Zijlstra wrote: >> On Thu, Feb 22, 2018 at 01:19:50PM +0100, Andrea Parri wrote: >> >>> C unlock-lock-read-ordering >>> >>> {} >>> /* s initially owned by P1 */ >>> >>> P0(int *x, int *y) >>> { >>> WRITE

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-22 Thread Andrea Parri
On Thu, Feb 22, 2018 at 02:40:04PM +0100, Peter Zijlstra wrote: > On Thu, Feb 22, 2018 at 01:19:50PM +0100, Andrea Parri wrote: > > > C unlock-lock-read-ordering > > > > {} > > /* s initially owned by P1 */ > > > > P0(int *x, int *y) > > { > > WRITE_ONCE(*x, 1); > > smp_wmb(); > > WR

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-22 Thread Peter Zijlstra
On Thu, Feb 22, 2018 at 01:19:50PM +0100, Andrea Parri wrote: > C unlock-lock-read-ordering > > {} > /* s initially owned by P1 */ > > P0(int *x, int *y) > { > WRITE_ONCE(*x, 1); > smp_wmb(); > WRITE_ONCE(*y, 1); > } > > P1(int *x, int *y, spinlock_t *s) > { > int r0; >

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-22 Thread Andrea Parri
On Thu, Feb 22, 2018 at 01:19:50PM +0100, Andrea Parri wrote: > The LKMM defines certain memory ordering constraints for spin_lock(), > spin_unlock() and other primitives that the kernel developer can rely > on; unfortunately, some of these constraints are not currently met by > the RISC-V implemen