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:	Fri, 12 Feb 2016 14:02:49 -0800
From:	Davidlohr Bueso <dave@...olabs.net>
To:	Waiman Long <Waiman.Long@....com>
Cc:	Ingo Molnar <mingo@...hat.com>,
	Peter Zijlstra <peterz@...radead.org>,
	linux-kernel@...r.kernel.org,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Ding Tianhong <dingtianhong@...wei.com>,
	Jason Low <jason.low2@....com>,
	"Paul E. McKenney" <paulmck@...ibm.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Will Deacon <Will.Deacon@....com>,
	Tim Chen <tim.c.chen@...ux.intel.com>,
	Waiman Long <Waiman.Long@...com>
Subject: Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to
 mutex_optimistic_spin()

On Fri, 12 Feb 2016, Waiman Long wrote:

>This patch adds a new waiter parameter to the mutex_optimistic_spin()
>function to prepare it to be used by a waiter-spinner that doesn't
>need to go into the OSQ as there can only be one waiter-spinner which
>is the head of the waiting queue.
>
>Signed-off-by: Waiman Long <Waiman.Long@...com>
>---
> kernel/locking/mutex.c |   55 ++++++++++++++++++++++++++++++++---------------
> 1 files changed, 37 insertions(+), 18 deletions(-)
>
>diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
>index 0551c21..3c41448 100644
>--- a/kernel/locking/mutex.c
>+++ b/kernel/locking/mutex.c
>@@ -273,11 +273,15 @@ static inline int mutex_can_spin_on_owner(struct mutex *lock)
>
> /*
>  * Atomically try to take the lock when it is available
>+ *
>+ * For waiter-spinner, the count needs to be set to -1 first which will be
>+ * cleared to 0 later on if the list becomes empty. For regular spinner,
>+ * the count will be set to 0.
>  */
>-static inline bool mutex_try_to_acquire(struct mutex *lock)
>+static inline bool mutex_try_to_acquire(struct mutex *lock, int waiter)
> {
> 	return !mutex_is_locked(lock) &&
>-		(atomic_cmpxchg_acquire(&lock->count, 1, 0) == 1);
>+		(atomic_cmpxchg_acquire(&lock->count, 1, waiter ? -1 : 0) == 1);
> }

This can be a really hot path, could we get rid of the waiter check and just
introduce mutex_tro_to_acquire_waiter() or such and set the counter to -1 there?

Thanks,
Davidlohr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ