Tracepoint: register/unregister struct tracepoint
Mathieu Desnoyers
reviewerRFC PATCH v4 1/1 Tracepoint: register/unregister struct tracepoint
Register/unregister tracepoint probes with struct tracepoint pointer rather than tracepoint name.
This change, which vastly simplifies tracepoint.c, has been proposed by Steven Rostedt.
Quoted 1 line
From this point on, the tracers need to pass a struct tracepoint pointer
to probe register/unregister. A probe can now only be connected to a tracepoint that exists. Moreover, tracers are responsible for unregistering the probe before the module containing its associated tracepoint is unloaded.
Changes since v1:
- Adapt ftrace/perf callers,
- Update tracepoint.h macro,
- Build tested.
Changes since v2:
- Introduce for_each_tracepoint() iterator to allow listing the currently loaded tracepoints, for modules using coming/going notifiers to track tracepoints.
Changes since v3:
- Introduce module coming and going notifiers each with their own priority to ensure that other coming notifiers are called after, and coming notifiers are called before the tracepoint notifiers.
- Fix: move for_each_tracepoint() outside of the CONFIG_MODULE ifdef.
Still needs testing.
This patch applies on top of 1b39437c61f562f82d6a4e3218470339a44620f7, after applying:
- "Tracepoint cleanup: remove unused API functions"
- "Tracepoint API doc update: data argument"
--- include/linux/ftrace_event.h | 1 + include/linux/tracepoint.h | 23 +- include/trace/ftrace.h | 2 + kernel/trace/trace_events.c | 8 +- kernel/tracepoint.c | 528 ++++++++++++++++++------------------------ 5 files changed, 246 insertions(+), 316 deletions(-)
include/linux/ftrace_event.h +1 -0
@@ -230,6 +230,7 @@ struct ftrace_event_call {struct list_head list;struct ftrace_event_class *class;char *name; +struct tracepoint *tp;struct trace_event event;const char *print_fmt;struct event_filter *filter;
include/linux/tracepoint.h +14 -9
@@ -37,16 +37,21 @@ struct tracepoint {/* * Connect a probe to a tracepoint. -* Internal API, should not be used directly. */ -extern int tracepoint_probe_register (const char *name,void *probe,void *data); +extern int tracepoint_probe_register (struct tracepoint *tp,void *probe, +void *data);/* * Disconnect a probe from a tracepoint. -* Internal API, should not be used directly. */ -extern int -tracepoint_probe_unregister (const char *name,void *probe,void *data); +extern int tracepoint_probe_unregister (struct tracepoint *tp,void *probe, +void *data); + +/* +* Tracepoint iterator. +*/ +void for_each_tracepoint (void (*fct)(struct tracepoint *tp,void *priv), +void *priv);#ifdef CONFIG_MODULES struct tp_module {
@@ -160,14 +165,14 @@ static inline void tracepoint_synchronize_unregister(void) static inline int \ register_trace_##name(void (*probe)(data_proto), void *data) \ { \ - return tracepoint_probe_register(#name, (void *)probe, \ - data); \ + return tracepoint_probe_register(&__tracepoint_##name, \ + (void *)probe, data); \ } \ static inline int \ unregister_trace_##name(void (*probe)(data_proto), void *data) \ { \ - return tracepoint_probe_unregister(#name, (void *)probe, \ - data); \ + return tracepoint_probe_unregister(&__tracepoint_##name,\ + (void *)probe, data); \ } \ static inline void \ check_trace_callback_type_##name(void (*cb)(data_proto)) \
include/trace/ftrace.h +2 -0
@@ -625,6 +625,7 @@ static struct ftrace_event_class __used __refdata event_class_##call = { \ \ static struct ftrace_event_call __used event_##call = { \ .name = #call, \ + .tp = &__tracepoint_##call, \ .class = &event_class_##template, \ .event.funcs = &ftrace_event_type_funcs_##template, \ .print_fmt = print_fmt_##template, \
@@ -639,6 +640,7 @@ static const char print_fmt_##call[] = print; \ \ static struct ftrace_event_call __used event_##call = { \ .name = #call, \ + .tp = &__tracepoint_##call, \ .class = &event_class_##template, \ .event.funcs = &ftrace_event_type_funcs_##call, \ .print_fmt = print_fmt_##call, \
kernel/trace/trace_events.c +4 -4
@@ -201,22 +201,22 @@ int ftrace_event_reg(struct ftrace_event_call *call,switch (type) {case TRACE_REG_REGISTER : -return tracepoint_probe_register (call->name, +return tracepoint_probe_register (call->tp, call->class->probe, file);case TRACE_REG_UNREGISTER : -tracepoint_probe_unregister (call->name, +tracepoint_probe_unregister (call->tp, call->class->probe, file);return 0 ;#ifdef CONFIG_PERF_EVENTS case TRACE_REG_PERF_REGISTER : -return tracepoint_probe_register (call->name, +return tracepoint_probe_register (call->tp, call->class->perf_probe, call);case TRACE_REG_PERF_UNREGISTER : -tracepoint_probe_unregister (call->name, +tracepoint_probe_unregister (call->tp, call->class->perf_probe, call);return 0 ;
kernel/tracepoint.c +225 -303
709 lines not on this page · raw message
Signature · 1 line
1.7.10.4