rtmutex: Simplify rtmutex_slowtrylock()
authorThomas Gleixner <tglx@linutronix.de>
Tue, 10 Jun 2014 20:53:40 +0000 (22:53 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Sat, 21 Jun 2014 20:05:30 +0000 (22:05 +0200)
commit88f2b4c15e561bb5c28709d666364f273bf54b98
tree7afc35714df46561b18b78bb39e70d7cbaafabe3
parentfddeca638ed428d447d60fc0942a094814073cc6
rtmutex: Simplify rtmutex_slowtrylock()

Oleg noticed that rtmutex_slowtrylock() has a pointless check for
rt_mutex_owner(lock) != current.

To avoid calling try_to_take_rtmutex() we really want to check whether
the lock has an owner at all or whether the trylock failed because the
owner is NULL, but the RT_MUTEX_HAS_WAITERS bit is set. This covers
the lock is owned by caller situation as well.

We can actually do this check lockless. trylock is taking a chance
whether we take lock->wait_lock to do the check or not.

Add comments to the function while at it.

Reported-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Reviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>
kernel/locking/rtmutex.c