Re: [PATCH -v4 2/8] locking/mutex: Rework mutex::owner

2016-10-13 Thread Will Deacon
On Fri, Oct 07, 2016 at 04:52:45PM +0200, Peter Zijlstra wrote: > The current mutex implementation has an atomic lock word and a > non-atomic owner field. > > This disparity leads to a number of issues with the current mutex code > as it means that we can have a locked mutex without an explicit

Re: [PATCH -v4 2/8] locking/mutex: Rework mutex::owner

2016-10-13 Thread Will Deacon
On Fri, Oct 07, 2016 at 04:52:45PM +0200, Peter Zijlstra wrote: > The current mutex implementation has an atomic lock word and a > non-atomic owner field. > > This disparity leads to a number of issues with the current mutex code > as it means that we can have a locked mutex without an explicit

Re: [PATCH -v4 2/8] locking/mutex: Rework mutex::owner

2016-10-12 Thread Jason Low
On Wed, 2016-10-12 at 10:59 -0700, Davidlohr Bueso wrote: > On Fri, 07 Oct 2016, Peter Zijlstra wrote: > >+/* > >+ * Optimistic trylock that only works in the uncontended case. Make sure to > >+ * follow with a __mutex_trylock() before failing. > >+ */ > >+static __always_inline bool

Re: [PATCH -v4 2/8] locking/mutex: Rework mutex::owner

2016-10-12 Thread Jason Low
On Wed, 2016-10-12 at 10:59 -0700, Davidlohr Bueso wrote: > On Fri, 07 Oct 2016, Peter Zijlstra wrote: > >+/* > >+ * Optimistic trylock that only works in the uncontended case. Make sure to > >+ * follow with a __mutex_trylock() before failing. > >+ */ > >+static __always_inline bool

Re: [PATCH -v4 2/8] locking/mutex: Rework mutex::owner

2016-10-12 Thread Davidlohr Bueso
On Fri, 07 Oct 2016, Peter Zijlstra wrote: +/* + * Optimistic trylock that only works in the uncontended case. Make sure to + * follow with a __mutex_trylock() before failing. + */ +static __always_inline bool __mutex_trylock_fast(struct mutex *lock) +{ + unsigned long curr = (unsigned

Re: [PATCH -v4 2/8] locking/mutex: Rework mutex::owner

2016-10-12 Thread Davidlohr Bueso
On Fri, 07 Oct 2016, Peter Zijlstra wrote: +/* + * Optimistic trylock that only works in the uncontended case. Make sure to + * follow with a __mutex_trylock() before failing. + */ +static __always_inline bool __mutex_trylock_fast(struct mutex *lock) +{ + unsigned long curr = (unsigned

[PATCH -v4 2/8] locking/mutex: Rework mutex::owner

2016-10-07 Thread Peter Zijlstra
The current mutex implementation has an atomic lock word and a non-atomic owner field. This disparity leads to a number of issues with the current mutex code as it means that we can have a locked mutex without an explicit owner (because the owner field has not been set, or already cleared). This

[PATCH -v4 2/8] locking/mutex: Rework mutex::owner

2016-10-07 Thread Peter Zijlstra
The current mutex implementation has an atomic lock word and a non-atomic owner field. This disparity leads to a number of issues with the current mutex code as it means that we can have a locked mutex without an explicit owner (because the owner field has not been set, or already cleared). This