lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150310124352.GB2896@worktop.programming.kicks-ass.net>
Date:	Tue, 10 Mar 2015 13:43:52 +0100
From:	Peter Zijlstra <peterz@...radead.org>
To:	Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc:	linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...hat.com>,
	Maarten Lankhorst <maarten.lankhorst@...onical.com>,
	Mike Galbraith <umgwanakikbuti@...il.com>
Subject: Re: [PATCH 2/3] locking: ww_mutex: Allow to use rt_mutex instead of
 mutex for the baselock

On Fri, Feb 27, 2015 at 05:57:08PM +0100, Sebastian Andrzej Siewior wrote:
> +#ifdef CONFIG_WW_MUTEX_RTMUTEX
> +static void ww_mutex_lock_acquired(struct ww_mutex *ww,
> +				   struct ww_acquire_ctx *ww_ctx)
> +{
> +#ifdef CONFIG_DEBUG_MUTEXES
> +	/*
> +	 * If this WARN_ON triggers, you used ww_mutex_lock to acquire,
> +	 * but released with a normal mutex_unlock in this call.
> +	 *
> +	 * This should never happen, always use ww_mutex_unlock.
> +	 */
> +	DEBUG_LOCKS_WARN_ON(ww->ctx);
> +
> +	/*
> +	 * Not quite done after calling ww_acquire_done() ?
> +	 */
> +	DEBUG_LOCKS_WARN_ON(ww_ctx->done_acquire);
> +
> +	if (ww_ctx->contending_lock) {
> +		/*
> +		 * After -EDEADLK you tried to
> +		 * acquire a different ww_mutex? Bad!
> +		 */
> +		DEBUG_LOCKS_WARN_ON(ww_ctx->contending_lock != ww);
> +
> +		/*
> +		 * You called ww_mutex_lock after receiving -EDEADLK,
> +		 * but 'forgot' to unlock everything else first?
> +		 */
> +		DEBUG_LOCKS_WARN_ON(ww_ctx->acquired > 0);
> +		ww_ctx->contending_lock = NULL;
> +	}
> +
> +	/*
> +	 * Naughty, using a different class will lead to undefined behavior!
> +	 */
> +	DEBUG_LOCKS_WARN_ON(ww_ctx->ww_class != ww->ww_class);
> +#endif
> +	ww_ctx->acquired++;
> +}
> +#endif

> +#ifdef CONFIG_WW_MUTEX_RTMUTEX
> +static int ww_mutex_deadlock_injection(struct ww_mutex *lock,
> +				       struct ww_acquire_ctx *ctx)
> +{
> +#ifdef CONFIG_DEBUG_WW_MUTEX_SLOWPATH
> +	unsigned tmp;
> +
> +	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;
> +		ctx->contending_lock = lock;
> +
> +		ww_mutex_unlock(lock);
> +
> +		return -EDEADLK;
> +	}
> +#endif
> +
> +	return 0;
> +}

AFAICT these functions are identical in both cases, should we stuff them
in a common file instead of copy/pasting them?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ