Re: [PATCH] rwsem: fix missed wakeup due to reordering of load

2017-09-27 Thread Davidlohr Bueso
On Wed, 20 Sep 2017, Andrea Parri wrote: Instead, how about just removing the release from atomic_long_sub_return_release() such that the osq load is not hoisted over the atomic compound (along with Peter's comment): This solution will actually enforce a stronger (full) ordering w.r.t. the s

Re: [PATCH] rwsem: fix missed wakeup due to reordering of load

2017-09-26 Thread Prateek Sood
On 09/07/2017 08:00 PM, Prateek Sood wrote: > If a spinner is present, there is a chance that the load of > rwsem_has_spinner() in rwsem_wake() can be reordered with > respect to decrement of rwsem count in __up_write() leading > to wakeup being missed. > > spinning writer up_wri

Re: [PATCH] rwsem: fix missed wakeup due to reordering of load

2017-09-20 Thread Andrea Parri
On Wed, Sep 20, 2017 at 07:52:54AM -0700, Davidlohr Bueso wrote: > On Thu, 07 Sep 2017, Prateek Sood wrote: > > /* > >+* __rwsem_down_write_failed_common(sem) > >+* rwsem_optimistic_spin(sem) > >+* osq_unlock(sem->osq) > >+* ... > >+* atomic_long_add_return(&sem->c

Re: [PATCH] rwsem: fix missed wakeup due to reordering of load

2017-09-20 Thread Davidlohr Bueso
On Thu, 07 Sep 2017, Prateek Sood wrote: /* + * __rwsem_down_write_failed_common(sem) + * rwsem_optimistic_spin(sem) + * osq_unlock(sem->osq) + * ... + * atomic_long_add_return(&sem->count) + * + * - VS - + * + *

Re: [PATCH] rwsem: fix missed wakeup due to reordering of load

2017-09-19 Thread Andrea Parri
On Thu, Sep 07, 2017 at 08:00:58PM +0530, Prateek Sood wrote: > If a spinner is present, there is a chance that the load of > rwsem_has_spinner() in rwsem_wake() can be reordered with > respect to decrement of rwsem count in __up_write() leading > to wakeup being missed. > > spinning writer

[PATCH] rwsem: fix missed wakeup due to reordering of load

2017-09-07 Thread Prateek Sood
If a spinner is present, there is a chance that the load of rwsem_has_spinner() in rwsem_wake() can be reordered with respect to decrement of rwsem count in __up_write() leading to wakeup being missed. spinning writer up_write caller ---

Re: [PATCH] rwsem: fix missed wakeup due to reordering of load

2017-09-07 Thread Prateek Sood
On 08/24/2017 06:22 PM, Peter Zijlstra wrote: > On Thu, Aug 24, 2017 at 02:33:04PM +0200, Peter Zijlstra wrote: >> On Thu, Aug 24, 2017 at 01:29:27PM +0200, Peter Zijlstra wrote: >>> >>> WTH did you not Cc the people that commented on your patch last time? >>> >>> On Wed, Aug 23, 2017 at 04:58:55PM

Re: [PATCH] rwsem: fix missed wakeup due to reordering of load

2017-08-24 Thread Peter Zijlstra
On Thu, Aug 24, 2017 at 02:33:04PM +0200, Peter Zijlstra wrote: > On Thu, Aug 24, 2017 at 01:29:27PM +0200, Peter Zijlstra wrote: > > > > WTH did you not Cc the people that commented on your patch last time? > > > > On Wed, Aug 23, 2017 at 04:58:55PM +0530, Prateek Sood wrote: > > > If a spinner

Re: [PATCH] rwsem: fix missed wakeup due to reordering of load

2017-08-24 Thread Peter Zijlstra
On Thu, Aug 24, 2017 at 01:29:27PM +0200, Peter Zijlstra wrote: > > WTH did you not Cc the people that commented on your patch last time? > > On Wed, Aug 23, 2017 at 04:58:55PM +0530, Prateek Sood wrote: > > If a spinner is present, there is a chance that the load of > > rwsem_has_spinner() in rw

Re: [PATCH] rwsem: fix missed wakeup due to reordering of load

2017-08-24 Thread Peter Zijlstra
WTH did you not Cc the people that commented on your patch last time? On Wed, Aug 23, 2017 at 04:58:55PM +0530, Prateek Sood wrote: > If a spinner is present, there is a chance that the load of > rwsem_has_spinner() in rwsem_wake() can be reordered with > respect to decrement of rwsem count in __

[PATCH] rwsem: fix missed wakeup due to reordering of load

2017-08-23 Thread Prateek Sood
If a spinner is present, there is a chance that the load of rwsem_has_spinner() in rwsem_wake() can be reordered with respect to decrement of rwsem count in __up_write() leading to wakeup being missed. spinning writer up_write caller --- -

Re: [PATCH] rwsem: fix missed wakeup due to reordering of load

2017-08-10 Thread Peter Zijlstra
On Thu, Jul 27, 2017 at 01:47:52AM +0530, Prateek Sood wrote: > diff --git a/kernel/locking/rwsem-xadd.c b/kernel/locking/rwsem-xadd.c > index 34e727f..21c111a 100644 > --- a/kernel/locking/rwsem-xadd.c > +++ b/kernel/locking/rwsem-xadd.c > @@ -585,6 +585,40 @@ struct rw_semaphore *rwsem_wake(struc

Re: [PATCH] rwsem: fix missed wakeup due to reordering of load

2017-08-10 Thread Peter Zijlstra
On Thu, Aug 10, 2017 at 10:32:56AM +0200, Andrea Parri wrote: > On Thu, Jul 27, 2017 at 11:48:53AM -0400, Waiman Long wrote: > > On 07/26/2017 04:17 PM, Prateek Sood wrote: > > > If a spinner is present, there is a chance that the load of > > > rwsem_has_spinner() in rwsem_wake() can be reordered w

Re: [PATCH] rwsem: fix missed wakeup due to reordering of load

2017-08-10 Thread Andrea Parri
On Thu, Jul 27, 2017 at 11:48:53AM -0400, Waiman Long wrote: > On 07/26/2017 04:17 PM, Prateek Sood wrote: > > If a spinner is present, there is a chance that the load of > > rwsem_has_spinner() in rwsem_wake() can be reordered with > > respect to decrement of rwsem count in __up_write() leading >

Re: [PATCH] rwsem: fix missed wakeup due to reordering of load

2017-07-27 Thread Peter Zijlstra
On Thu, Jul 27, 2017 at 11:48:53AM -0400, Waiman Long wrote: > atomic_long_sub_return_release() is implmented. I've not had time to really thing about the problem at hand, but this I can answer: TSO (x86, s390, sparc): fully serialized PPC: lwsync; ll/sc (RCpc) ARM64: ll/sc-release(RCsc)

Re: [PATCH] rwsem: fix missed wakeup due to reordering of load

2017-07-27 Thread Waiman Long
On 07/26/2017 04:17 PM, Prateek Sood wrote: > If a spinner is present, there is a chance that the load of > rwsem_has_spinner() in rwsem_wake() can be reordered with > respect to decrement of rwsem count in __up_write() leading > to wakeup being missed. > > spinning writer up_writ

[PATCH] rwsem: fix missed wakeup due to reordering of load

2017-07-26 Thread Prateek Sood
If a spinner is present, there is a chance that the load of rwsem_has_spinner() in rwsem_wake() can be reordered with respect to decrement of rwsem count in __up_write() leading to wakeup being missed. spinning writer up_write caller ---