Re: [PATCH 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-15 Thread Thomas Hellstrom
On 06/14/2018 08:51 PM, Peter Zijlstra wrote: On Thu, Jun 14, 2018 at 06:43:40PM +0200, Thomas Hellstrom wrote: Overall, I think this looks fine. I'll just fix up the FLAG_WAITERS setting and affected comments and do some torture testing on it. Thanks! Are you OK with adding the new feature a

Re: [PATCH 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-14 Thread Peter Zijlstra
On Thu, Jun 14, 2018 at 06:43:40PM +0200, Thomas Hellstrom wrote: > Overall, I think this looks fine. I'll just fix up the FLAG_WAITERS setting > and affected comments and do some torture testing on it. Thanks! > Are you OK with adding the new feature and the cleanup in the same patch? I suppose

Re: [PATCH 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-14 Thread Thomas Hellstrom
On 06/14/2018 04:42 PM, Peter Zijlstra wrote: On Thu, Jun 14, 2018 at 01:48:39PM +0200, Thomas Hellstrom wrote: The literature makes a distinction between "killed" and "wounded". In our context, "Killed" is when a transaction actually receives an -EDEADLK and needs to back off. "Wounded" is when

Re: [PATCH 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-14 Thread Peter Zijlstra
On Thu, Jun 14, 2018 at 01:48:39PM +0200, Thomas Hellstrom wrote: > The literature makes a distinction between "killed" and "wounded". In our > context, "Killed" is when a transaction actually receives an -EDEADLK and > needs to back off. "Wounded" is when someone (typically another transaction) >

Re: [PATCH 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-14 Thread Thomas Hellstrom
On 06/14/2018 12:51 PM, Peter Zijlstra wrote: On Wed, Jun 13, 2018 at 04:05:43PM +0200, Thomas Hellstrom wrote: In short, with Wait-Die (before the patch) it's the process _taking_ the contended lock that backs off if necessary. No preemption required. With Wound-Wait, it's the process _holding_

Re: [PATCH 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-14 Thread Peter Zijlstra
On Wed, Jun 13, 2018 at 04:05:43PM +0200, Thomas Hellstrom wrote: > In short, with Wait-Die (before the patch) it's the process _taking_ the > contended lock that backs off if necessary. No preemption required. With > Wound-Wait, it's the process _holding_ the contended lock that gets wounded > (pr

Re: [PATCH 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-13 Thread Thomas Hellstrom
On 06/13/2018 03:10 PM, Peter Zijlstra wrote: On Wed, Jun 13, 2018 at 12:40:29PM +0200, Thomas Hellstrom wrote: On 06/13/2018 11:50 AM, Peter Zijlstra wrote: + + lockdep_assert_held(&lock->wait_lock); + + if (owner && hold_ctx && __ww_ctx_stamp_after(hold_ctx, ww_ctx) && +

Re: [PATCH 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-13 Thread Peter Zijlstra
On Wed, Jun 13, 2018 at 12:40:29PM +0200, Thomas Hellstrom wrote: > On 06/13/2018 11:50 AM, Peter Zijlstra wrote: > > > > > + > > > + lockdep_assert_held(&lock->wait_lock); > > > + > > > + if (owner && hold_ctx && __ww_ctx_stamp_after(hold_ctx, ww_ctx) && > > > + ww_ctx->acquired > 0) { > > >

Re: [PATCH 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-13 Thread Thomas Hellstrom
On 06/13/2018 11:50 AM, Peter Zijlstra wrote: + + lockdep_assert_held(&lock->wait_lock); + + if (owner && hold_ctx && __ww_ctx_stamp_after(hold_ctx, ww_ctx) && + ww_ctx->acquired > 0) { + WRITE_ONCE(hold_ctx->wounded, true); + if (owner != curre

Re: [PATCH 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-13 Thread Peter Zijlstra
/me wonders what's up with partial Cc's today.. On Wed, Jun 13, 2018 at 09:47:44AM +0200, Thomas Hellstrom wrote: > The current Wound-Wait mutex algorithm is actually not Wound-Wait but > Wait-Die. Implement also Wound-Wait as a per-ww-class choice. Wound-Wait > is, contrary to Wait-Die a preempt

Re: [PATCH 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-13 Thread Thomas Hellstrom
On 06/13/2018 09:54 AM, Greg Kroah-Hartman wrote: On Wed, Jun 13, 2018 at 09:47:44AM +0200, Thomas Hellstrom wrote: - +The algorithm (Wait-Die vs Wound-Wait) is chosen using the _is_wait_die +argument to DEFINE_WW_CLASS(). As a rough rule of thumb, use Wound-Wait iff you +typically exp

Re: [PATCH 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-13 Thread Greg Kroah-Hartman
On Wed, Jun 13, 2018 at 09:47:44AM +0200, Thomas Hellstrom wrote: > - > > +The algorithm (Wait-Die vs Wound-Wait) is chosen using the _is_wait_die > +argument to DEFINE_WW_CLASS(). As a rough rule of thumb, use Wound-Wait iff > you > +typically expect the number of simultaneous competing tr