lkml.org 
[lkml]   [2016]   [Aug]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2] locking/mutex: Prevent lock starvation when spinning is enabled
From
Date
On Wed, 2016-08-10 at 11:44 -0700, Jason Low wrote:
> @@ -917,11 +976,12 @@ EXPORT_SYMBOL(mutex_trylock);
> int __sched
> __ww_mutex_lock(struct ww_mutex *lock, struct ww_acquire_ctx *ctx)
> {
> - int ret;
> + int ret = 1;
>
> might_sleep();
>
> - ret = __mutex_fastpath_lock_retval(&lock->base.count);
> + if (!need_yield_to_waiter(lock))
> + ret = __mutex_fastpath_lock_retval(&lock->base.count);
>
> if (likely(!ret)) {
> ww_mutex_set_context_fastpath(lock, ctx);
> @@ -935,11 +995,12 @@ EXPORT_SYMBOL(__ww_mutex_lock);
> int __sched
> __ww_mutex_lock_interruptible(struct ww_mutex *lock, struct ww_acquire_ctx *ctx)
> {
> - int ret;
> + int ret = 1;
>
> might_sleep();
>
> - ret = __mutex_fastpath_lock_retval(&lock->base.count);
> + if (!need_yield_to_waiter(lock))

And we would need to pass &lock->base instead of lock since lock is
struct ww_mutex * here.

\
 
 \ /
  Last update: 2016-08-11 05:21    [W:0.826 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site