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:	Tue, 29 Mar 2016 18:36:54 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Waiman Long <Waiman.Long@....com>
Cc:	Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Ding Tianhong <dingtianhong@...wei.com>,
	Jason Low <jason.low2@....com>,
	Davidlohr Bueso <dave@...olabs.net>,
	"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 v3 3/3] locking/mutex: Avoid missed wakeup of mutex waiter

On Tue, Mar 22, 2016 at 01:46:44PM -0400, Waiman Long wrote:
> The current mutex code sets count to -1 and then sets the task
> state. This is the same sequence that the mutex unlock path is checking
> count and task state. That could lead to a missed wakeup even though
> the problem will be cleared when a new waiter enters the waiting queue.
> 
> This patch reverses the order in the locking slowpath so that the task
> state is set first before setting the count. This should eliminate
> the potential missed wakeup and improve latency.

Is it really a problem though?

So the 'race' is __mutex_lock_common() against
__mutex_fastpath_unlock(), and that is fully serialized as per the
atomic instructions. Either the fast unlock path does 1->0 and the lock
acquires, or the lock sets -1, at which the unlock fails and enters
__mutex_unlock_common_slowpath, which is fully serialised against
__mutex_lock_common by the lock->wait_lock.

I agree that the code is nicer after your patch, but I don't actually
see a problem.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ