Skip to content

Commit cff6d93

Browse files
Darksonnrostedt
authored andcommitted
tracepoint: Reduce duplication of __DO_TRACE_CALL
The logic for invoking __DO_TRACE_CALL was extracted to a static inline function called __rust_do_trace_##name so that Rust can call it directly. This logic does not include the static branch, to avoid a function call when the tracepoint is disabled. Since the C code needs to perform the same logic after checking the static key, this logic is currently duplicated. Thus, remove this duplication by having C call the static inline function too. Cc: Masami Hiramatsu <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Alice Ryhl <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 9e49ca7 commit cff6d93

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

include/linux/tracepoint.h

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
218218
#define __DEFINE_RUST_DO_TRACE(name, proto, args) \
219219
notrace void rust_do_trace_##name(proto) \
220220
{ \
221-
__rust_do_trace_##name(args); \
221+
__do_trace_##name(args); \
222222
}
223223

224224
/*
@@ -268,7 +268,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
268268

269269
#define __DECLARE_TRACE(name, proto, args, cond, data_proto) \
270270
__DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), PARAMS(data_proto)) \
271-
static inline void __rust_do_trace_##name(proto) \
271+
static inline void __do_trace_##name(proto) \
272272
{ \
273273
if (cond) { \
274274
guard(preempt_notrace)(); \
@@ -277,12 +277,8 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
277277
} \
278278
static inline void trace_##name(proto) \
279279
{ \
280-
if (static_branch_unlikely(&__tracepoint_##name.key)) { \
281-
if (cond) { \
282-
guard(preempt_notrace)(); \
283-
__DO_TRACE_CALL(name, TP_ARGS(args)); \
284-
} \
285-
} \
280+
if (static_branch_unlikely(&__tracepoint_##name.key)) \
281+
__do_trace_##name(args); \
286282
if (IS_ENABLED(CONFIG_LOCKDEP) && (cond)) { \
287283
WARN_ONCE(!rcu_is_watching(), \
288284
"RCU not watching for tracepoint"); \
@@ -291,18 +287,16 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
291287

292288
#define __DECLARE_TRACE_SYSCALL(name, proto, args, data_proto) \
293289
__DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), PARAMS(data_proto)) \
294-
static inline void __rust_do_trace_##name(proto) \
290+
static inline void __do_trace_##name(proto) \
295291
{ \
296292
guard(rcu_tasks_trace)(); \
297293
__DO_TRACE_CALL(name, TP_ARGS(args)); \
298294
} \
299295
static inline void trace_##name(proto) \
300296
{ \
301297
might_fault(); \
302-
if (static_branch_unlikely(&__tracepoint_##name.key)) { \
303-
guard(rcu_tasks_trace)(); \
304-
__DO_TRACE_CALL(name, TP_ARGS(args)); \
305-
} \
298+
if (static_branch_unlikely(&__tracepoint_##name.key)) \
299+
__do_trace_##name(args); \
306300
if (IS_ENABLED(CONFIG_LOCKDEP)) { \
307301
WARN_ONCE(!rcu_is_watching(), \
308302
"RCU not watching for tracepoint"); \

0 commit comments

Comments
 (0)