Re: deadlock in synchronize_srcu() in debugfs?

From: Johannes Berg
Date: Mon Mar 27 2017 - 07:24:50 EST


On Fri, 2017-03-24 at 13:20 -0700, Paul E. McKenney wrote:
>
> And I cannot resist adding this one:
>
> CPU 1 CPU 2
> i = srcu_read_lock(&s1); mutex_lock(&l1);
> mutex_lock(&l1); synchronize_srcu(&s2);
> mutex_unlock(&l1); mutex_unlock(&l1);
> srcu_read_unlock(&s1, i);
>
> CPU 3 CPU 4
> i = srcu_read_lock(&s2); mutex_lock(&l2);
> mutex_lock(&l2); synchronize_srcu(&s1);
> mutex_unlock(&l2); mutex_unlock(&l2);
> srcu_read_unlock(&s2, i);
>
> Removing the SRCU statements from any of these CPU would break the
> deadlock.ÂÂThis can be easily extended to a deadlock cycle involving
> any number of srcu_struct structures.
>
> But this would still be a cycle involving an srcu_read_lock() and a
> synchronize_srcu() on the same srcu_struct, which is reassuring.

Right, you can cycle this indefinitely. lockdep has some kind of
maximum chain length I think. :)

johannes