Patch "srcu: Use try-lock lockdep annotation for NMI-safe access." has been added to the 6.7-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    srcu: Use try-lock lockdep annotation for NMI-safe access.

to the 6.7-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     srcu-use-try-lock-lockdep-annotation-for-nmi-safe-ac.patch
and it can be found in the queue-6.7 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 257d2e528303943fab6571e85ec3c7cae1ecaab8
Author: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
Date:   Thu Nov 30 14:27:29 2023 +0100

    srcu: Use try-lock lockdep annotation for NMI-safe access.
    
    [ Upstream commit 3c6b0c1c28184038d90dffe8eb542bedcb8ccf98 ]
    
    It is claimed that srcu_read_lock_nmisafe() NMI-safe. However it
    triggers a lockdep if used from NMI because lockdep expects a deadlock
    since nothing disables NMIs while the lock is acquired.
    
    This is because commit f0f44752f5f61 ("rcu: Annotate SRCU's update-side
    lockdep dependencies") annotates synchronize_srcu() as a write lock
    usage. This helps to detect a deadlocks such as
            srcu_read_lock();
            synchronize_srcu();
            srcu_read_unlock();
    
    The side effect is that the lock srcu_struct now has a USED usage in normal
    contexts, so it conflicts with a USED_READ usage in NMI. But this shouldn't
    cause a real deadlock because the write lock usage from synchronize_srcu()
    is a fake one and only used for read/write deadlock detection.
    
    Use a try-lock annotation for srcu_read_lock_nmisafe() to avoid lockdep
    complains if used from NMI.
    
    Fixes: f0f44752f5f6 ("rcu: Annotate SRCU's update-side lockdep dependencies")
    Link: https://lore.kernel.org/r/20230927160231.XRCDDSK4@xxxxxxxxxxxxx
    Reviewed-by: Boqun Feng <boqun.feng@xxxxxxxxx>
    Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
    Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
    Signed-off-by: Neeraj Upadhyay (AMD) <neeraj.iitr10@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index f7206b2623c9..31d523c4e089 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -301,6 +301,11 @@ static inline void rcu_lock_acquire(struct lockdep_map *map)
 	lock_acquire(map, 0, 0, 2, 0, NULL, _THIS_IP_);
 }
 
+static inline void rcu_try_lock_acquire(struct lockdep_map *map)
+{
+	lock_acquire(map, 0, 1, 2, 0, NULL, _THIS_IP_);
+}
+
 static inline void rcu_lock_release(struct lockdep_map *map)
 {
 	lock_release(map, _THIS_IP_);
@@ -315,6 +320,7 @@ int rcu_read_lock_any_held(void);
 #else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
 
 # define rcu_lock_acquire(a)		do { } while (0)
+# define rcu_try_lock_acquire(a)	do { } while (0)
 # define rcu_lock_release(a)		do { } while (0)
 
 static inline int rcu_read_lock_held(void)
diff --git a/include/linux/srcu.h b/include/linux/srcu.h
index 127ef3b2e607..236610e4a8fa 100644
--- a/include/linux/srcu.h
+++ b/include/linux/srcu.h
@@ -229,7 +229,7 @@ static inline int srcu_read_lock_nmisafe(struct srcu_struct *ssp) __acquires(ssp
 
 	srcu_check_nmi_safety(ssp, true);
 	retval = __srcu_read_lock_nmisafe(ssp);
-	rcu_lock_acquire(&ssp->dep_map);
+	rcu_try_lock_acquire(&ssp->dep_map);
 	return retval;
 }
 




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux