Re: [RFC][PATCH] mutex: Optimize mutex_trylock() fast-path

From: Davidlohr Bueso
Date: Thu Jun 02 2016 - 10:26:37 EST


On Wed, 01 Jun 2016, Peter Zijlstra wrote:


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.

Yeah, and we use ccas just about everywhere else for mutexes.


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

Reported-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>

Acked-by: Davidlohr Bueso <dave@xxxxxxxxxxxx>