Skip to contentSkip to conversation

Tracepoint API simplification/cleanup

RFC PATCH Superseded Mathieu Desnoyers 2 participants 5 messages Mar 18, 2014 – Mar 19, 2014

Subsystems (2)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Mathieu Desnoyers

author reviewer
#0 lore raw

v5 cover Tracepoint API simplification/cleanup

Hi,

Here is a respin of v5 of the tracepoint register/unregister API simplification, along with the 2 other cleanup patches that comes before.

Feedback is welcome,

Thanks!

Mathieu

Mathieu Desnoyers (3):
Tracepoint cleanup: remove unused API functions Tracepoint API doc update: data argument
Tracepoint: register/unregister struct tracepoint

 include/linux/ftrace_event.h |    1 +
 include/linux/tracepoint.h   |   62 ++--
 include/trace/ftrace.h       |    2 +
 kernel/trace/trace_events.c  |    8 +-
 kernel/tracepoint.c          |  707 ++++++++++++++----------------------------
 5 files changed, 268 insertions(+), 512 deletions(-)
Signature · 1 line
1.7.10.4
author reviewer
#1 lore raw

RFC PATCH v5 1/3 Tracepoint cleanup: remove unused API functions

After the following commit:

commit b75ef8b44b1cb95f5a26484b0e2fe37a63b12b44

Author: Mathieu Desnoyers <[email protected]>
Date:   Wed Aug 10 15:18:39 2011 -0400

Tracepoint: Dissociate from module mutex

The following functions became unnecessary:

- tracepoint_probe_register_noupdate,
- tracepoint_probe_unregister_noupdate,
- tracepoint_probe_update_all.

In fact, none of the in-kernel tracers, nor LTTng, nor SystemTAP use them. Remove those.

Moreover, the functions:

- tracepoint_iter_start,
- tracepoint_iter_next,
- tracepoint_iter_stop,
- tracepoint_iter_reset.

are unused by in-kernel tracers, LTTng and SystemTAP. Remove those too.

CC Steven Rostedt <[email protected]>
CC Ingo Molnar <[email protected]>
CC Frederic Weisbecker <[email protected]>
CC Andrew Morton <[email protected]>
CC Frank Ch. Eigler <[email protected]>
CC Johannes Berg <[email protected]>
---
 include/linux/tracepoint.h |   18 -----
 kernel/tracepoint.c        |  179 --------------------------------------------
 2 files changed, 197 deletions(-)
include/linux/tracepoint.h +0 -18
index 7159a0a..812b255 100644
@@ -48,12 +48,6 @@ extern int tracepoint_probe_register(const char *name, void *probe, void *data);
 extern int
 tracepoint_probe_unregister(const char *name, void *probe, void *data);
 
-extern int tracepoint_probe_register_noupdate(const char *name, void *probe,
-					      void *data);
-extern int tracepoint_probe_unregister_noupdate(const char *name, void *probe,
-						void *data);
-extern void tracepoint_probe_update_all(void);
-
 #ifdef CONFIG_MODULES
 struct tp_module {
 	struct list_head list;
@@ -68,18 +62,6 @@ static inline bool trace_module_has_bad_taint(struct module *mod)
 }
 #endif /* CONFIG_MODULES */
 
-struct tracepoint_iter {
-#ifdef CONFIG_MODULES
-	struct tp_module *module;
-#endif /* CONFIG_MODULES */
-	struct tracepoint * const *tracepoint;
-};
-
-extern void tracepoint_iter_start(struct tracepoint_iter *iter);
-extern void tracepoint_iter_next(struct tracepoint_iter *iter);
-extern void tracepoint_iter_stop(struct tracepoint_iter *iter);
-extern void tracepoint_iter_reset(struct tracepoint_iter *iter);
-
 /*
  * tracepoint_synchronize_unregister must be called between the last tracepoint
  * probe unregistration and the end of module exit to make sure there is no
kernel/tracepoint.c +0 -179

185 lines not on this page · raw message

Signature · 1 line
1.7.10.4
maintainer
#2 lore raw

Re: [RFC PATCH v5 1/3] Tracepoint cleanup: remove unused API functions

Quoted 17 lines · On Tue, 18 Mar 2014 10:05:44 -0400 Mathieu Desnoyers…

After the following commit:

commit b75ef8b44b1cb95f5a26484b0e2fe37a63b12b44

Author: Mathieu Desnoyers <[email protected]>
Date:   Wed Aug 10 15:18:39 2011 -0400

Tracepoint: Dissociate from module mutex

The following functions became unnecessary:

- tracepoint_probe_register_noupdate,
- tracepoint_probe_unregister_noupdate,
- tracepoint_probe_update_all.

In fact, none of the in-kernel tracers, nor LTTng, nor SystemTAP use them. Remove those.

Quoted 9 lines

Moreover, the functions:

- tracepoint_iter_start,
- tracepoint_iter_next,
- tracepoint_iter_stop,
- tracepoint_iter_reset.

are unused by in-kernel tracers, LTTng and SystemTAP. Remove those too.

New warning caused by this patch:

tracepoint.c:446:13: warning: 'tracepoint_add_old_probes' defined but not used [-Wunused-function]

    struct tp_probes, probes[0]);

-- Steve

author reviewer
#3 lore raw

RFC PATCH v5 2/3 Tracepoint API doc update: data argument

In reply to Mathieu Desnoyers

Describe the @data argument (probe private data).

Fixes 38516ab59fbc "tracing: Let tracepoints have data passed to tracepoint callbacks"
CC Steven Rostedt <[email protected]>
CC Ingo Molnar <[email protected]>
CC Frederic Weisbecker <[email protected]>
CC Andrew Morton <[email protected]>
---
 kernel/tracepoint.c |    2 ++
 1 file changed, 2 insertions(+)
kernel/tracepoint.c +2 -0
index 0faf2a4..cc6c8b6 100644
@@ -373,6 +373,7 @@ tracepoint_add_probe(const char *name, void *probe, void *data)
  * tracepoint_probe_register -  Connect a probe to a tracepoint
  * @name: tracepoint name
  * @probe: probe handler
+ * @data: probe private data
  *
  * Returns 0 if ok, error value on error.
  * The probe address must at least be aligned on the architecture pointer size.
@@ -415,6 +416,7 @@ tracepoint_remove_probe(const char *name, void *probe, void *data)
  * tracepoint_probe_unregister -  Disconnect a probe from a tracepoint
  * @name: tracepoint name
  * @probe: probe function pointer
+ * @data: probe private data
  *
  * We do not need to call a synchronize_sched to make sure the probes have
  * finished running before doing a module unload, because the module unload
Signature · 1 line
1.7.10.4
author reviewer
#4 lore raw

RFC PATCH v5 3/3 Tracepoint: register/unregister struct tracepoint

In reply to Mathieu Desnoyers

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.

CC Steven Rostedt <[email protected]>
CC Ingo Molnar <[email protected]>
CC Frederic Weisbecker <[email protected]>
CC Andrew Morton <[email protected]>
CC Frank Ch. Eigler <[email protected]>
CC Johannes Berg <[email protected]>
---
 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
index 4e4cc28..1592c1c 100644
@@ -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
index 1a8b28d..415b986 100644
@@ -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
index f3989ce..0e39692 100644
@@ -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