locking/mutex: Optimize mutex_trylock() fast-path
authorPeter Zijlstra <peterz@infradead.org>
Wed, 1 Jun 2016 18:58:15 +0000 (20:58 +0200)
committerIngo Molnar <mingo@kernel.org>
Wed, 8 Jun 2016 13:17:01 +0000 (15:17 +0200)
commit6428671bae97caa7040e24e79e969fd87908f4f3
tree67549d91213b5fc3bb48a243ebfaf1ef3fc2b9a2
parentddd0fa73c2b71c35de4fe7ae60a5f1a6cddc2cf0
locking/mutex: Optimize mutex_trylock() fast-path

A while back Viro posted a number of 'interesting' mutex_is_locked()
users on IRC, one of those was RCU.

RCU seems to use mutex_is_locked() to avoid doing mutex_trylock(), the
regular load before modify pattern.

While the use isn't wrong per se, its curious in that its needed at all,
mutex_trylock() should be good enough on its own to avoid the pointless
cacheline bounces.

So fix those and remove the mutex_is_locked() (ab)use from RCU.

Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Paul McKenney <paulmck@linux.vnet.ibm.com>
Acked-by: Davidlohr Bueso <dave@stgolabs.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Waiman Long <Waiman.Long@hpe.com>
Link: http://lkml.kernel.org/r/20160601185815.GW3190@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/ia64/include/asm/mutex.h
arch/powerpc/include/asm/mutex.h
arch/x86/include/asm/mutex_32.h
arch/x86/include/asm/mutex_64.h
include/asm-generic/mutex-dec.h
include/asm-generic/mutex-xchg.h
kernel/rcu/tree.c