Tracepoint: register/unregister struct tracepoint
Mathieu Desnoyers
reviewerRFC PATCH v5 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.
Changes since v4:
- Split tracepoints_mutex into two locks: tp_modlist_mutex, which protects the tracepoint list of modules, and a tracepoint_mutex, which protects the tracepoints per se. tracepoint_mutex nests inside tp_modlist_mutex.
- Introduce a tracepoint module notifier, to ensure consistency between iteration on tracepoints with for_each_tracepoint() and module coming and going notifications. This consistency is ensured by holding tp_modlist_mutex when calling the notifier and when iterating on the tracepoint module list.
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 | 44 ++-- include/trace/ftrace.h | 2 + kernel/trace/trace_events.c | 8 +- kernel/tracepoint.c | 556 +++++++++++++++++++----------------------- 5 files changed, 281 insertions(+), 330 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 +23 -21
74 lines not on this page · raw message
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 +251 -305
745 lines not on this page · raw message
Signature · 1 line
1.7.10.4