]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
srcu: Add srcu_read_lock_fast_notrace() and srcu_read_unlock_fast_notrace()
authorPaul E. McKenney <paulmck@kernel.org>
Wed, 16 Jul 2025 16:12:16 +0000 (09:12 -0700)
committerPaul E. McKenney <paulmck@kernel.org>
Thu, 14 Aug 2025 22:25:48 +0000 (15:25 -0700)
This commit adds no-trace variants of the srcu_read_lock_fast() and
srcu_read_unlock_fast() functions for tracing use.

[ paulmck: Apply notrace feedback from Joel Fernandes, Steven Rostedt, and Mathieu Desnoyers. ]
[ paulmck: Apply excess-notrace feedback from Boqun Feng. ]

Link: https://lore.kernel.org/all/20250721162433.10454-1-paulmck@kernel.org
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: <bpf@vger.kernel.org>
include/linux/srcu.h
include/linux/srcutree.h

index 478c73d067f7d3b2deee244e3c10141af2c641d7..7a692bf8f99b96396ba5f366e4ed105afa8db913 100644 (file)
@@ -282,6 +282,20 @@ static inline struct srcu_ctr __percpu *srcu_read_lock_fast(struct srcu_struct *
        return retval;
 }
 
+/*
+ * Used by tracing, cannot be traced and cannot call lockdep.
+ * See srcu_read_lock_fast() for more information.
+ */
+static inline struct srcu_ctr __percpu *srcu_read_lock_fast_notrace(struct srcu_struct *ssp)
+       __acquires(ssp)
+{
+       struct srcu_ctr __percpu *retval;
+
+       srcu_check_read_flavor_force(ssp, SRCU_READ_FLAVOR_FAST);
+       retval = __srcu_read_lock_fast(ssp);
+       return retval;
+}
+
 /**
  * srcu_down_read_fast - register a new reader for an SRCU-protected structure.
  * @ssp: srcu_struct in which to register the new reader.
@@ -394,6 +408,17 @@ static inline void srcu_read_unlock_fast(struct srcu_struct *ssp, struct srcu_ct
        RCU_LOCKDEP_WARN(!rcu_is_watching(), "RCU must be watching srcu_read_unlock_fast().");
 }
 
+/*
+ * Used by tracing, cannot be traced and cannot call lockdep.
+ * See srcu_read_unlock_fast() for more information.
+ */
+static inline void srcu_read_unlock_fast_notrace(struct srcu_struct *ssp,
+                                                struct srcu_ctr __percpu *scp) __releases(ssp)
+{
+       srcu_check_read_flavor(ssp, SRCU_READ_FLAVOR_FAST);
+       __srcu_read_unlock_fast(ssp, scp);
+}
+
 /**
  * srcu_up_read_fast - unregister a old reader from an SRCU-protected structure.
  * @ssp: srcu_struct in which to unregister the old reader.
index 043b5a67ef71eb0cbae0b453fb391891e3c445cc..4d2fee4d38289f81b5bcaac83df4c35bf41de1e0 100644 (file)
@@ -240,7 +240,7 @@ static inline struct srcu_ctr __percpu *__srcu_ctr_to_ptr(struct srcu_struct *ss
  * on architectures that support NMIs but do not supply NMI-safe
  * implementations of this_cpu_inc().
  */
-static inline struct srcu_ctr __percpu *__srcu_read_lock_fast(struct srcu_struct *ssp)
+static inline struct srcu_ctr __percpu notrace *__srcu_read_lock_fast(struct srcu_struct *ssp)
 {
        struct srcu_ctr __percpu *scp = READ_ONCE(ssp->srcu_ctrp);
 
@@ -267,7 +267,8 @@ static inline struct srcu_ctr __percpu *__srcu_read_lock_fast(struct srcu_struct
  * on architectures that support NMIs but do not supply NMI-safe
  * implementations of this_cpu_inc().
  */
-static inline void __srcu_read_unlock_fast(struct srcu_struct *ssp, struct srcu_ctr __percpu *scp)
+static inline void notrace
+__srcu_read_unlock_fast(struct srcu_struct *ssp, struct srcu_ctr __percpu *scp)
 {
        barrier();  /* Avoid leaking the critical section. */
        if (!IS_ENABLED(CONFIG_NEED_SRCU_NMI_SAFE))