lkml.org 
[lkml]   [2013]   [Apr]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] [RFC] mutex: w/w mutex slowpath debugging
From
Date
On Tue, 2013-04-30 at 20:45 +0200, Daniel Vetter wrote:
> /**
> diff --git a/kernel/mutex.c b/kernel/mutex.c
> index 66807c7..1cc3487 100644
> --- a/kernel/mutex.c
> +++ b/kernel/mutex.c
> @@ -827,6 +827,35 @@ int __sched mutex_trylock(struct mutex *lock)
> EXPORT_SYMBOL(mutex_trylock);
>
> #ifndef CONFIG_DEBUG_LOCK_ALLOC
> +
> +#ifdef CONFIG_DEBUG_WW_MUTEX_SLOWPATH
> +static int __sched
> +ww_mutex_deadlock_injection(struct ww_mutex *lock, struct ww_acquire_ctx *ctx)
> +{
> + if (ctx->deadlock_inject_countdown-- == 0) {
> + tmp = ctx->deadlock_inject_interval;
> + if (tmp > UINT_MAX/4)
> + tmp = UINT_MAX;
> + else
> + tmp = tmp*2 + tmp + tmp/2;
> +
> + ctx->deadlock_inject_interval = tmp;
> + ctx->deadlock_inject_countdown = tmp;
> +
> + ww_mutex_unlock(lock);
> +
> + return -EDEADLK;
> + }
> +
> + return 0;
> +}
> +#else
> +static int __sched
> +ww_mutex_deadlock_injection(struct ww_mutex *lock, struct ww_acquire_ctx *ctx)
> +{
> + return 0;
> +}

This should be a static inline, and remove the __sched. There's no
reason to make this anything but a nop when disabled.

-- Steve




\
 
 \ /
  Last update: 2013-04-30 21:41    [W:2.019 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site