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: <20140728090821.GO6758@twins.programming.kicks-ass.net>
Date:	Mon, 28 Jul 2014 11:08:21 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Davidlohr Bueso <davidlohr@...com>
Cc:	mingo@...nel.org, jason.low2@...com, aswin@...com,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH -tip/master 4/7] locking/mutex: Refactor optimistic
 spinning code

On Sun, Jul 27, 2014 at 10:18:41PM -0700, Davidlohr Bueso wrote:
> @@ -180,6 +266,126 @@ static inline int mutex_can_spin_on_owner(struct mutex *lock)
>  	 */
>  	return retval;
>  }
> +
> +/*
> + * Atomically try to take the lock when it is available */

comment fail.

> +static inline bool mutex_try_to_acquire(struct mutex *lock)
> +{
> +	return !mutex_is_locked(lock) &&
> +		(atomic_cmpxchg(&lock->count, 1, 0) == 1);
> +}

> +static bool mutex_optimistic_spin(struct mutex *lock,
> +				  struct ww_acquire_ctx *ww_ctx, const bool use_ww_ctx)
> +{


> +	/*
> +	 * If we fell out of the spin path because of need_resched(),
> +	 * reschedule now, before we try-lock the mutex. This avoids getting
> +	 * scheduled out right after we obtained the mutex.
> +	 */
> +	if (need_resched())
> +		schedule_preempt_disabled();
> +
> +	return false;
> +}


> +	if (mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx)) {
> +		/* got it, yay! */
> +		preempt_enable();
> +		return 0;
>  	}
> +
>  	/*
>  	 * If we fell out of the spin path because of need_resched(),
>  	 * reschedule now, before we try-lock the mutex. This avoids getting
> @@ -475,7 +512,7 @@ slowpath:
>  	 */
>  	if (need_resched())
>  		schedule_preempt_disabled();
> +
>  	spin_lock_mutex(&lock->wait_lock, flags);

We now have two if (need_resched) schedule_preempt_disable() instances,
was that on purpose?

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ