Skip to content

Commit 4a8840a

Browse files
jpoimboerostedt
authored andcommitted
tracepoints: Use new static branch API
The old static key API is deprecated. Switch to the new one. Cc: Masami Hiramatsu <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Alice Ryhl <[email protected]> Link: https://lore.kernel.org/7a08dae3c5eddb14b13864923c1b58ac1f4af83c.1728414936.git.jpoimboe@kernel.org Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 49e4154 commit 4a8840a

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

include/linux/tracepoint-defs.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct tracepoint_func {
3131

3232
struct tracepoint {
3333
const char *name; /* Tracepoint name */
34-
struct static_key key;
34+
struct static_key_false key;
3535
struct static_call_key *static_call_key;
3636
void *static_call_tramp;
3737
void *iterator;
@@ -83,7 +83,7 @@ struct bpf_raw_event_map {
8383

8484
#ifdef CONFIG_TRACEPOINTS
8585
# define tracepoint_enabled(tp) \
86-
static_key_false(&(__tracepoint_##tp).key)
86+
static_branch_unlikely(&(__tracepoint_##tp).key)
8787
#else
8888
# define tracepoint_enabled(tracepoint) false
8989
#endif

include/linux/tracepoint.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
248248
#define __DECLARE_TRACE_RCU(name, proto, args, cond) \
249249
static inline void trace_##name##_rcuidle(proto) \
250250
{ \
251-
if (static_key_false(&__tracepoint_##name.key)) \
251+
if (static_branch_unlikely(&__tracepoint_##name.key)) \
252252
__DO_TRACE(name, \
253253
TP_ARGS(args), \
254254
TP_CONDITION(cond), 1); \
@@ -274,7 +274,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
274274
extern struct tracepoint __tracepoint_##name; \
275275
static inline void trace_##name(proto) \
276276
{ \
277-
if (static_key_false(&__tracepoint_##name.key)) \
277+
if (static_branch_unlikely(&__tracepoint_##name.key)) \
278278
__DO_TRACE(name, \
279279
TP_ARGS(args), \
280280
TP_CONDITION(cond), 0); \
@@ -311,7 +311,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
311311
static inline bool \
312312
trace_##name##_enabled(void) \
313313
{ \
314-
return static_key_false(&__tracepoint_##name.key); \
314+
return static_branch_unlikely(&__tracepoint_##name.key);\
315315
}
316316

317317
/*
@@ -328,7 +328,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
328328
struct tracepoint __tracepoint_##_name __used \
329329
__section("__tracepoints") = { \
330330
.name = __tpstrtab_##_name, \
331-
.key = STATIC_KEY_INIT_FALSE, \
331+
.key = STATIC_KEY_FALSE_INIT, \
332332
.static_call_key = &STATIC_CALL_KEY(tp_func_##_name), \
333333
.static_call_tramp = STATIC_CALL_TRAMP_ADDR(tp_func_##_name), \
334334
.iterator = &__traceiter_##_name, \

kernel/trace/trace_events_hist.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ static inline void trace_synth(struct synth_event *event, u64 *var_ref_vals,
822822
{
823823
struct tracepoint *tp = event->tp;
824824

825-
if (unlikely(atomic_read(&tp->key.enabled) > 0)) {
825+
if (unlikely(static_key_enabled(&tp->key))) {
826826
struct tracepoint_func *probe_func_ptr;
827827
synth_probe_func_t probe_func;
828828
void *__data;

kernel/trace/trace_events_user.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,7 @@ static void update_enable_bit_for(struct user_event *user)
16761676
struct tracepoint *tp = &user->tracepoint;
16771677
char status = 0;
16781678

1679-
if (atomic_read(&tp->key.enabled) > 0) {
1679+
if (static_key_enabled(&tp->key)) {
16801680
struct tracepoint_func *probe_func_ptr;
16811681
user_event_func_t probe_func;
16821682

@@ -2280,7 +2280,7 @@ static ssize_t user_events_write_core(struct file *file, struct iov_iter *i)
22802280
* It's possible key.enabled disables after this check, however
22812281
* we don't mind if a few events are included in this condition.
22822282
*/
2283-
if (likely(atomic_read(&tp->key.enabled) > 0)) {
2283+
if (likely(static_key_enabled(&tp->key))) {
22842284
struct tracepoint_func *probe_func_ptr;
22852285
user_event_func_t probe_func;
22862286
struct iov_iter copy;

kernel/tracepoint.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ static int tracepoint_add_func(struct tracepoint *tp,
358358
tracepoint_update_call(tp, tp_funcs);
359359
/* Both iterator and static call handle NULL tp->funcs */
360360
rcu_assign_pointer(tp->funcs, tp_funcs);
361-
static_key_enable(&tp->key);
361+
static_branch_enable(&tp->key);
362362
break;
363363
case TP_FUNC_2: /* 1->2 */
364364
/* Set iterator static call */
@@ -414,7 +414,7 @@ static int tracepoint_remove_func(struct tracepoint *tp,
414414
if (tp->unregfunc && static_key_enabled(&tp->key))
415415
tp->unregfunc();
416416

417-
static_key_disable(&tp->key);
417+
static_branch_disable(&tp->key);
418418
/* Set iterator static call */
419419
tracepoint_update_call(tp, tp_funcs);
420420
/* Both iterator and static call handle NULL tp->funcs */

0 commit comments

Comments
 (0)