• Thomas Gleixner's avatar
    rtmutex: Make wait_lock irq safe · b4abf910
    Thomas Gleixner authored
    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: default avatarSasha Levin <[email protected]>
    Signed-off-by: default avatarThomas Gleixner <[email protected]>
    Cc: Peter Zijlstra <[email protected]>
    Cc: Paul McKenney <[email protected]>
    b4abf910
rtmutex.c 44.5 KB