lkml.org 
[lkml]   [2016]   [Aug]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] locking/mutex: Prevent lock starvation when spinning is enabled
On Wed, Aug 10, 2016 at 11:44:08AM -0700, Jason Low wrote:
> @@ -556,8 +604,12 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
> * other waiters. We only attempt the xchg if the count is
> * non-negative in order to avoid unnecessary xchg operations:
> */
> - if (atomic_read(&lock->count) >= 0 &&
> + if ((!need_yield_to_waiter(lock) || wakeups > 1) &&
> + atomic_read(&lock->count) >= 0 &&
> (atomic_xchg_acquire(&lock->count, -1) == 1))
> + if (wakeups > 1)
> + clear_yield_to_waiter(lock);
> +
> break;
>
> /*

There's some { } gone missing there...

Also, I think I'll change it to avoid that extra wakeups > 1 condition..

\
 
 \ /
  Last update: 2016-09-17 09:57    [W:0.171 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site