lkml.org 
[lkml]   [2016]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH 3/3] locking/mutex: Add lock handoff to avoid starvation
On Wed, Aug 24, 2016 at 03:50:10PM -0400, Waiman Long wrote:

> --- a/kernel/locking/mutex.c
> +++ b/kernel/locking/mutex.c
> @@ -97,6 +97,8 @@ static void __mutex_handoff(struct mutex *lock, struct
> task_st
> for (;;) {
> unsigned long old, new;
>
> + if ((owner & ~MUTEX_FLAG_ALL) != current)
> + break;
> new = (owner & MUTEX_FLAG_WAITERS);
> new |= (unsigned long)task;
>
> I also think that the MUTEX_FLAG_HANDOFF bit needs to be cleared if the list
> is empty.
>
> @@ -614,7 +633,7 @@ __mutex_lock_common(struct mutex *lock, long state,
> unsigned
> mutex_remove_waiter(lock, &waiter, task);
> /* set it to 0 if there are no waiters left: */
> if (likely(list_empty(&lock->wait_list)))
> - __mutex_clear_flag(lock, MUTEX_FLAG_WAITERS);
> + __mutex_clear_flag(lock,
> MUTEX_FLAG_WAITERS|MUTEX_FLAG_HANDOFF);
>
> Or we should try to reset the handoff bit after the while loop exit if the
> bit is still set.

Yes, I think you're right. I've also found another issue wrt WAITERS in
patch 1.

I'm not trying to get aim7 running to see if I can reproduce Jason's
results and verify things.

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