Skip to content

Commit 7e2a2d0

Browse files
committed
srcu: Add srcu_read_lock_fast_notrace() and srcu_read_unlock_fast_notrace()
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>
1 parent f394940 commit 7e2a2d0

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

include/linux/srcu.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,20 @@ static inline struct srcu_ctr __percpu *srcu_read_lock_fast(struct srcu_struct *
282282
return retval;
283283
}
284284

285+
/*
286+
* Used by tracing, cannot be traced and cannot call lockdep.
287+
* See srcu_read_lock_fast() for more information.
288+
*/
289+
static inline struct srcu_ctr __percpu *srcu_read_lock_fast_notrace(struct srcu_struct *ssp)
290+
__acquires(ssp)
291+
{
292+
struct srcu_ctr __percpu *retval;
293+
294+
srcu_check_read_flavor_force(ssp, SRCU_READ_FLAVOR_FAST);
295+
retval = __srcu_read_lock_fast(ssp);
296+
return retval;
297+
}
298+
285299
/**
286300
* srcu_down_read_fast - register a new reader for an SRCU-protected structure.
287301
* @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
394408
RCU_LOCKDEP_WARN(!rcu_is_watching(), "RCU must be watching srcu_read_unlock_fast().");
395409
}
396410

411+
/*
412+
* Used by tracing, cannot be traced and cannot call lockdep.
413+
* See srcu_read_unlock_fast() for more information.
414+
*/
415+
static inline void srcu_read_unlock_fast_notrace(struct srcu_struct *ssp,
416+
struct srcu_ctr __percpu *scp) __releases(ssp)
417+
{
418+
srcu_check_read_flavor(ssp, SRCU_READ_FLAVOR_FAST);
419+
__srcu_read_unlock_fast(ssp, scp);
420+
}
421+
397422
/**
398423
* srcu_up_read_fast - unregister a old reader from an SRCU-protected structure.
399424
* @ssp: srcu_struct in which to unregister the old reader.

include/linux/srcutree.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static inline struct srcu_ctr __percpu *__srcu_ctr_to_ptr(struct srcu_struct *ss
240240
* on architectures that support NMIs but do not supply NMI-safe
241241
* implementations of this_cpu_inc().
242242
*/
243-
static inline struct srcu_ctr __percpu *__srcu_read_lock_fast(struct srcu_struct *ssp)
243+
static inline struct srcu_ctr __percpu notrace *__srcu_read_lock_fast(struct srcu_struct *ssp)
244244
{
245245
struct srcu_ctr __percpu *scp = READ_ONCE(ssp->srcu_ctrp);
246246

@@ -267,7 +267,8 @@ static inline struct srcu_ctr __percpu *__srcu_read_lock_fast(struct srcu_struct
267267
* on architectures that support NMIs but do not supply NMI-safe
268268
* implementations of this_cpu_inc().
269269
*/
270-
static inline void __srcu_read_unlock_fast(struct srcu_struct *ssp, struct srcu_ctr __percpu *scp)
270+
static inline void notrace
271+
__srcu_read_unlock_fast(struct srcu_struct *ssp, struct srcu_ctr __percpu *scp)
271272
{
272273
barrier(); /* Avoid leaking the critical section. */
273274
if (!IS_ENABLED(CONFIG_NEED_SRCU_NMI_SAFE))

0 commit comments

Comments
 (0)