• Boqun Feng's avatar
    rcu: Annotate SRCU's update-side lockdep dependencies · f0f44752
    Boqun Feng authored
    Although all flavors of RCU readers are annotated correctly with
    lockdep as recursive read locks, they do not set the lock_acquire
    'check' parameter.  This means that RCU read locks are not added to
    the lockdep dependency graph, which in turn means that lockdep cannot
    detect RCU-based deadlocks.  This is not a problem for RCU flavors having
    atomic read-side critical sections because context-based annotations can
    catch these deadlocks, see for example the RCU_LOCKDEP_WARN() statement
    in synchronize_rcu().  But context-based annotations are not helpful
    for sleepable RCU, especially given that it is perfectly legal to do
    synchronize_srcu(&srcu1) within an srcu_read_lock(&srcu2).
    
    However, we can detect SRCU-based by: (1) Making srcu_read_lock() a
    'check'ed recursive read lock and (2) Making synchronize_srcu() a empty
    write lock critical section.  Even better, with the newly introduced
    lock_sync(), we can avoid false positives about irq-unsafe/safe.
    This commit therefore makes it so.
    
    Note that NMI-safe SRCU read side critical sections are currently not
    annotated, but might be annotated in the future.
    Signed-off-by: default avatarBoqun Feng <boqun.feng@gmail.com>
    Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
    [ boqun: Add comments for annotation per Waiman's suggestion ]
    [ boqun: Fix comment warning reported by Stephen Rothwell ]
    Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Signed-off-by: default avatarBoqun Feng <boqun.feng@gmail.com>
    f0f44752
srcutree.c 64.3 KB