Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tracepoints: Use new static branch API

The old static key API is deprecated. Switch to the new one.

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/7a08dae3c5eddb14b13864923c1b58ac1f4af83c.1728414936.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

authored by

Josh Poimboeuf and committed by
Steven Rostedt (Google)
4a8840af 49e4154f

+11 -11
+2 -2
include/linux/tracepoint-defs.h
··· 31 31 32 32 struct tracepoint { 33 33 const char *name; /* Tracepoint name */ 34 - struct static_key key; 34 + struct static_key_false key; 35 35 struct static_call_key *static_call_key; 36 36 void *static_call_tramp; 37 37 void *iterator; ··· 83 83 84 84 #ifdef CONFIG_TRACEPOINTS 85 85 # define tracepoint_enabled(tp) \ 86 - static_key_false(&(__tracepoint_##tp).key) 86 + static_branch_unlikely(&(__tracepoint_##tp).key) 87 87 #else 88 88 # define tracepoint_enabled(tracepoint) false 89 89 #endif
+4 -4
include/linux/tracepoint.h
··· 248 248 #define __DECLARE_TRACE_RCU(name, proto, args, cond) \ 249 249 static inline void trace_##name##_rcuidle(proto) \ 250 250 { \ 251 - if (static_key_false(&__tracepoint_##name.key)) \ 251 + if (static_branch_unlikely(&__tracepoint_##name.key)) \ 252 252 __DO_TRACE(name, \ 253 253 TP_ARGS(args), \ 254 254 TP_CONDITION(cond), 1); \ ··· 274 274 extern struct tracepoint __tracepoint_##name; \ 275 275 static inline void trace_##name(proto) \ 276 276 { \ 277 - if (static_key_false(&__tracepoint_##name.key)) \ 277 + if (static_branch_unlikely(&__tracepoint_##name.key)) \ 278 278 __DO_TRACE(name, \ 279 279 TP_ARGS(args), \ 280 280 TP_CONDITION(cond), 0); \ ··· 311 311 static inline bool \ 312 312 trace_##name##_enabled(void) \ 313 313 { \ 314 - return static_key_false(&__tracepoint_##name.key); \ 314 + return static_branch_unlikely(&__tracepoint_##name.key);\ 315 315 } 316 316 317 317 /* ··· 328 328 struct tracepoint __tracepoint_##_name __used \ 329 329 __section("__tracepoints") = { \ 330 330 .name = __tpstrtab_##_name, \ 331 - .key = STATIC_KEY_INIT_FALSE, \ 331 + .key = STATIC_KEY_FALSE_INIT, \ 332 332 .static_call_key = &STATIC_CALL_KEY(tp_func_##_name), \ 333 333 .static_call_tramp = STATIC_CALL_TRAMP_ADDR(tp_func_##_name), \ 334 334 .iterator = &__traceiter_##_name, \
+1 -1
kernel/trace/trace_events_hist.c
··· 822 822 { 823 823 struct tracepoint *tp = event->tp; 824 824 825 - if (unlikely(atomic_read(&tp->key.enabled) > 0)) { 825 + if (unlikely(static_key_enabled(&tp->key))) { 826 826 struct tracepoint_func *probe_func_ptr; 827 827 synth_probe_func_t probe_func; 828 828 void *__data;
+2 -2
kernel/trace/trace_events_user.c
··· 1676 1676 struct tracepoint *tp = &user->tracepoint; 1677 1677 char status = 0; 1678 1678 1679 - if (atomic_read(&tp->key.enabled) > 0) { 1679 + if (static_key_enabled(&tp->key)) { 1680 1680 struct tracepoint_func *probe_func_ptr; 1681 1681 user_event_func_t probe_func; 1682 1682 ··· 2280 2280 * It's possible key.enabled disables after this check, however 2281 2281 * we don't mind if a few events are included in this condition. 2282 2282 */ 2283 - if (likely(atomic_read(&tp->key.enabled) > 0)) { 2283 + if (likely(static_key_enabled(&tp->key))) { 2284 2284 struct tracepoint_func *probe_func_ptr; 2285 2285 user_event_func_t probe_func; 2286 2286 struct iov_iter copy;
+2 -2
kernel/tracepoint.c
··· 358 358 tracepoint_update_call(tp, tp_funcs); 359 359 /* Both iterator and static call handle NULL tp->funcs */ 360 360 rcu_assign_pointer(tp->funcs, tp_funcs); 361 - static_key_enable(&tp->key); 361 + static_branch_enable(&tp->key); 362 362 break; 363 363 case TP_FUNC_2: /* 1->2 */ 364 364 /* Set iterator static call */ ··· 414 414 if (tp->unregfunc && static_key_enabled(&tp->key)) 415 415 tp->unregfunc(); 416 416 417 - static_key_disable(&tp->key); 417 + static_branch_disable(&tp->key); 418 418 /* Set iterator static call */ 419 419 tracepoint_update_call(tp, tp_funcs); 420 420 /* Both iterator and static call handle NULL tp->funcs */