From: Vineeth Pillai (Google) Date: Mon, 23 Mar 2026 16:00:20 +0000 (-0400) Subject: tracepoint: Add trace_call__##name() API X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=677a3d82b6407522d922705209c311e043a17813;p=thirdparty%2Fkernel%2Flinux.git tracepoint: Add trace_call__##name() API Add trace_call__##name() as a companion to trace_##name(). When a caller already guards a tracepoint with an explicit enabled check: if (trace_foo_enabled() && cond) trace_foo(args); trace_foo() internally repeats the static_branch_unlikely() test, which the compiler cannot fold since static branches are patched binary instructions. This results in two static-branch evaluations for every guarded call site. trace_call__##name() calls __do_trace_##name() directly, skipping the redundant static-branch re-check. This avoids leaking the internal __do_trace_##name() symbol into call sites while still eliminating the double evaluation: if (trace_foo_enabled() && cond) trace_invoke_foo(args); /* calls __do_trace_foo() directly */ Three locations are updated: - __DECLARE_TRACE: invoke form omits static_branch_unlikely, retains the LOCKDEP RCU-watching assertion. - __DECLARE_TRACE_SYSCALL: same, plus retains might_fault(). - !TRACEPOINTS_ENABLED stub: empty no-op so callers compile cleanly when tracepoints are compiled out. Cc: Dmitry Ilvokhin Cc: Mathieu Desnoyers Cc: Ingo Molnar Cc: Jens Axboe Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Marcelo Ricardo Leitner Cc: Xin Long Cc: Jon Maloy Cc: Aaron Conole Cc: Eelco Chaudron Cc: Ilya Maximets Cc: Jiri Pirko Cc: Oded Gabbay Cc: Koby Elbaz Cc: "Rafael J. Wysocki" Cc: Viresh Kumar Cc: "Gautham R. Shenoy" Cc: Huang Rui Cc: Mario Limonciello Cc: Len Brown Cc: Srinivas Pandruvada Cc: MyungJoo Ham Cc: Kyungmin Park Cc: Chanwoo Choi Cc: Christian König Cc: Sumit Semwal Cc: Eddie James Cc: Andrew Jeffery Cc: Joel Stanley Cc: David Airlie Cc: Simona Vetter Cc: Alex Deucher Cc: Danilo Krummrich Cc: Matthew Brost Cc: Philipp Stanner Cc: Harry Wentland Cc: Leo Li Cc: Jiri Kosina Cc: Benjamin Tissoires Cc: Wolfram Sang Cc: Mark Brown Cc: Michael Hennerich Cc: Nuno Sá Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: Chris Mason Cc: David Sterba Cc: Thomas Gleixner Cc: Andrew Morton Cc: SeongJae Park Cc: Borislav Petkov Cc: Dave Hansen Link: https://patch.msgid.link/20260323160052.17528-2-vineeth@bitbyteword.org Suggested-by: Steven Rostedt Suggested-by: Peter Zijlstra Acked-by: Masami Hiramatsu (Google) Signed-off-by: Vineeth Pillai (Google) Assisted-by: Claude:claude-sonnet-4-6 Signed-off-by: Steven Rostedt (Google) --- diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index 22ca1c8b54f32..ed969705341f1 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h @@ -294,6 +294,10 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) WARN_ONCE(!rcu_is_watching(), \ "RCU not watching for tracepoint"); \ } \ + } \ + static inline void trace_call__##name(proto) \ + { \ + __do_trace_##name(args); \ } #define __DECLARE_TRACE_SYSCALL(name, proto, args, data_proto) \ @@ -313,6 +317,11 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) WARN_ONCE(!rcu_is_watching(), \ "RCU not watching for tracepoint"); \ } \ + } \ + static inline void trace_call__##name(proto) \ + { \ + might_fault(); \ + __do_trace_##name(args); \ } /* @@ -398,6 +407,8 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) #define __DECLARE_TRACE_COMMON(name, proto, args, data_proto) \ static inline void trace_##name(proto) \ { } \ + static inline void trace_call__##name(proto) \ + { } \ static inline int \ register_trace_##name(void (*probe)(data_proto), \ void *data) \