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]
Date:	Wed, 30 Jul 2014 08:18:56 -0700
From:	Jason Low <jason.low2@...com>
To:	Davidlohr Bueso <davidlohr@...com>
Cc:	peterz@...radead.org, mingo@...nel.org, aswin@...com,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH -tip/master 4/7] locking/mutex: Refactor optimistic
 spinning code

On Sun, 2014-07-27 at 22:18 -0700, Davidlohr Bueso wrote:

> +static bool mutex_optimistic_spin(struct mutex *lock,
> +				  struct ww_acquire_ctx *ww_ctx, const bool use_ww_ctx)
> +{
> +	struct task_struct *task = current;
> +
> +	if (!mutex_can_spin_on_owner(lock))
> +		return false;
> +
> +	if (!osq_lock(&lock->osq))
> +		return false;
> +
> +	while (true) {
> +		struct task_struct *owner;
> +
> +		if (use_ww_ctx && ww_ctx->acquired > 0) {
> +			struct ww_mutex *ww;
> +
> +			ww = container_of(lock, struct ww_mutex, base);
> +			/*
> +			 * If ww->ctx is set the contents are undefined, only
> +			 * by acquiring wait_lock there is a guarantee that
> +			 * they are not invalid when reading.
> +			 *
> +			 * As such, when deadlock detection needs to be
> +			 * performed the optimistic spinning cannot be done.
> +			 */
> +			if (ACCESS_ONCE(ww->ctx))
> +				break;
> +		}
> +
> +		/*
> +		 * If there's an owner, wait for it to either
> +		 * release the lock or go to sleep.
> +		 */
> +		owner = ACCESS_ONCE(lock->owner);
> +		if (owner && !mutex_spin_on_owner(lock, owner))
> +			break;
> +
> +		/* Try to acquire the mutex if it is unlocked. */
> +		if (mutex_try_to_acquire(lock)) {

Was it intended to remove the call to lock_acquired() which was
in the original code?

> +			if (use_ww_ctx) {
> +				struct ww_mutex *ww;
> +				ww = container_of(lock, struct ww_mutex, base);
> +
> +				ww_mutex_set_context_fastpath(ww, ww_ctx);
> +			}
> +
> +			mutex_set_owner(lock);
> +			osq_unlock(&lock->osq);
> +			return true;
> +		}


--
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