Re: [PATCH -v4 5/8] locking/mutex: Add lock handoff to avoid starvation

2016-12-27 Thread Chris Wilson
On Fri, Oct 07, 2016 at 04:52:48PM +0200, Peter Zijlstra wrote: > Implement lock handoff to avoid lock starvation. > > Lock starvation is possible because mutex_lock() allows lock stealing, > where a running (or optimistic spinning) task beats the woken waiter > to the acquire. > > Lock stealing

Re: [PATCH -v4 5/8] locking/mutex: Add lock handoff to avoid starvation

2016-12-27 Thread Chris Wilson
On Fri, Oct 07, 2016 at 04:52:48PM +0200, Peter Zijlstra wrote: > Implement lock handoff to avoid lock starvation. > > Lock starvation is possible because mutex_lock() allows lock stealing, > where a running (or optimistic spinning) task beats the woken waiter > to the acquire. > > Lock stealing

Re: [PATCH -v4 5/8] locking/mutex: Add lock handoff to avoid starvation

2016-10-18 Thread Peter Zijlstra
On Mon, Oct 17, 2016 at 03:07:54PM -0400, Waiman Long wrote: > One more thing, I think it may be worthwhile to add another comment about > what happens when the HANDOFF bit was set while we take the error path (goto > err). As the actual handoff is serialized by the wait_lock, the code will >

Re: [PATCH -v4 5/8] locking/mutex: Add lock handoff to avoid starvation

2016-10-18 Thread Peter Zijlstra
On Mon, Oct 17, 2016 at 03:07:54PM -0400, Waiman Long wrote: > One more thing, I think it may be worthwhile to add another comment about > what happens when the HANDOFF bit was set while we take the error path (goto > err). As the actual handoff is serialized by the wait_lock, the code will >

Re: [PATCH -v4 5/8] locking/mutex: Add lock handoff to avoid starvation

2016-10-18 Thread Peter Zijlstra
On Mon, Oct 17, 2016 at 02:45:50PM -0400, Waiman Long wrote: > On 10/07/2016 10:52 AM, Peter Zijlstra wrote: > > /* > > * Actual trylock that will work on any unlocked state. > >+ * > >+ * When setting the owner field, we must preserve the low flag bits. > >+ * > >+ * Be careful with @handoff,

Re: [PATCH -v4 5/8] locking/mutex: Add lock handoff to avoid starvation

2016-10-18 Thread Peter Zijlstra
On Mon, Oct 17, 2016 at 02:45:50PM -0400, Waiman Long wrote: > On 10/07/2016 10:52 AM, Peter Zijlstra wrote: > > /* > > * Actual trylock that will work on any unlocked state. > >+ * > >+ * When setting the owner field, we must preserve the low flag bits. > >+ * > >+ * Be careful with @handoff,

Re: [PATCH -v4 5/8] locking/mutex: Add lock handoff to avoid starvation

2016-10-17 Thread Waiman Long
On 10/17/2016 02:45 PM, Waiman Long wrote: On 10/07/2016 10:52 AM, Peter Zijlstra wrote: /* * Actual trylock that will work on any unlocked state. + * + * When setting the owner field, we must preserve the low flag bits. + * + * Be careful with @handoff, only set that in a wait-loop (where

Re: [PATCH -v4 5/8] locking/mutex: Add lock handoff to avoid starvation

2016-10-17 Thread Waiman Long
On 10/17/2016 02:45 PM, Waiman Long wrote: On 10/07/2016 10:52 AM, Peter Zijlstra wrote: /* * Actual trylock that will work on any unlocked state. + * + * When setting the owner field, we must preserve the low flag bits. + * + * Be careful with @handoff, only set that in a wait-loop (where

Re: [PATCH -v4 5/8] locking/mutex: Add lock handoff to avoid starvation

2016-10-17 Thread Waiman Long
On 10/07/2016 10:52 AM, Peter Zijlstra wrote: /* * Actual trylock that will work on any unlocked state. + * + * When setting the owner field, we must preserve the low flag bits. + * + * Be careful with @handoff, only set that in a wait-loop (where you set + * HANDOFF) to avoid recursive

Re: [PATCH -v4 5/8] locking/mutex: Add lock handoff to avoid starvation

2016-10-17 Thread Waiman Long
On 10/07/2016 10:52 AM, Peter Zijlstra wrote: /* * Actual trylock that will work on any unlocked state. + * + * When setting the owner field, we must preserve the low flag bits. + * + * Be careful with @handoff, only set that in a wait-loop (where you set + * HANDOFF) to avoid recursive

Re: [PATCH -v4 5/8] locking/mutex: Add lock handoff to avoid starvation

2016-10-17 Thread Peter Zijlstra
On Thu, Oct 13, 2016 at 04:14:47PM +0100, Will Deacon wrote: > > + if (__owner_task(owner)) { > > + if (handoff && unlikely(__owner_task(owner) == > > current)) { > > + /* > > +* Provide ACQUIRE semantics for the

Re: [PATCH -v4 5/8] locking/mutex: Add lock handoff to avoid starvation

2016-10-17 Thread Peter Zijlstra
On Thu, Oct 13, 2016 at 04:14:47PM +0100, Will Deacon wrote: > > + if (__owner_task(owner)) { > > + if (handoff && unlikely(__owner_task(owner) == > > current)) { > > + /* > > +* Provide ACQUIRE semantics for the

Re: [PATCH -v4 5/8] locking/mutex: Add lock handoff to avoid starvation

2016-10-13 Thread Will Deacon
Hi Peter, Just one comment below. On Fri, Oct 07, 2016 at 04:52:48PM +0200, Peter Zijlstra wrote: > --- a/kernel/locking/mutex.c > +++ b/kernel/locking/mutex.c > @@ -54,8 +54,10 @@ EXPORT_SYMBOL(__mutex_init); > * bits to store extra state. > * > * Bit0 indicates a non-empty waiter list;

Re: [PATCH -v4 5/8] locking/mutex: Add lock handoff to avoid starvation

2016-10-13 Thread Will Deacon
Hi Peter, Just one comment below. On Fri, Oct 07, 2016 at 04:52:48PM +0200, Peter Zijlstra wrote: > --- a/kernel/locking/mutex.c > +++ b/kernel/locking/mutex.c > @@ -54,8 +54,10 @@ EXPORT_SYMBOL(__mutex_init); > * bits to store extra state. > * > * Bit0 indicates a non-empty waiter list;

[PATCH -v4 5/8] locking/mutex: Add lock handoff to avoid starvation

2016-10-07 Thread Peter Zijlstra
Implement lock handoff to avoid lock starvation. Lock starvation is possible because mutex_lock() allows lock stealing, where a running (or optimistic spinning) task beats the woken waiter to the acquire. Lock stealing is an important performance optimization because waiting for a waiter to wake

[PATCH -v4 5/8] locking/mutex: Add lock handoff to avoid starvation

2016-10-07 Thread Peter Zijlstra
Implement lock handoff to avoid lock starvation. Lock starvation is possible because mutex_lock() allows lock stealing, where a running (or optimistic spinning) task beats the woken waiter to the acquire. Lock stealing is an important performance optimization because waiting for a waiter to wake