]> git.baikalelectronics.ru Git - kernel.git/commit
rtmutex: Make wait_lock irq safe
authorThomas Gleixner <tglx@linutronix.de>
Wed, 13 Jan 2016 10:25:38 +0000 (11:25 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 26 Jan 2016 10:08:35 +0000 (11:08 +0100)
commitbeb9b5554a1e37796f135a79ea3f1095340ee781
treea018e1a33d72f3c8f154db82acad5b70858417ba
parent5367e65a538f2d59834d845f582bc1f1ae9599b8
rtmutex: Make wait_lock irq safe

Sasha reported a lockdep splat about a potential deadlock between RCU boosting
rtmutex and the posix timer it_lock.

CPU0 CPU1

rtmutex_lock(&rcu->rt_mutex)
  spin_lock(&rcu->rt_mutex.wait_lock)
local_irq_disable()
spin_lock(&timer->it_lock)
spin_lock(&rcu->mutex.wait_lock)
--> Interrupt
    spin_lock(&timer->it_lock)

This is caused by the following code sequence on CPU1

     rcu_read_lock()
     x = lookup();
     if (x)
      spin_lock_irqsave(&x->it_lock);
     rcu_read_unlock();
     return x;

We could fix that in the posix timer code by keeping rcu read locked across
the spinlocked and irq disabled section, but the above sequence is common and
there is no reason not to support it.

Taking rt_mutex.wait_lock irq safe prevents the deadlock.

Reported-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
kernel/futex.c
kernel/locking/rtmutex.c