Re: [PATCH] [RFC] mutex: w/w mutex slowpath debugging

From: Steven Rostedt
Date: Tue Apr 30 2013 - 15:29:49 EST


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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/