diff options
author | Josh Stone <jistone@redhat.com> | 2009-08-24 17:43:13 -0400 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2009-08-25 18:36:41 -0400 |
commit | 97419875865859fd2403e66266c02ce028e2f5ab (patch) | |
tree | 7df6e6df767e9c8ff538a50bcae17638a1c8da99 /include/linux | |
parent | 3d27d8cb34fc156beb86de2338ca4029873a5cc6 (diff) |
tracing: Move tracepoint callbacks from declaration to definition
It's not strictly correct for the tracepoint reg/unreg callbacks to
occur when a client is hooking up, because the actual tracepoint may not
be present yet. This happens to be fine for syscall, since that's in
the core kernel, but it would cause problems for tracepoints defined in
a module that hasn't been loaded yet. It also means the reg/unreg has
to be EXPORTed for any modules to use the tracepoint (as in SystemTap).
This patch removes DECLARE_TRACE_WITH_CALLBACK, and instead introduces
DEFINE_TRACE_FN which stores the callbacks in struct tracepoint. The
callbacks are used now when the active state of the tracepoint changes
in set_tracepoint & disable_tracepoint.
This also introduces TRACE_EVENT_FN, so ftrace events can also provide
registration callbacks if needed.
Signed-off-by: Josh Stone <jistone@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Jiaying Zhang <jiayingz@google.com>
Cc: Martin Bligh <mbligh@google.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
LKML-Reference: <1251150194-1713-4-git-send-email-jistone@redhat.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/tracepoint.h | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index 5984ed04c03b..846a4ae501eb 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h | |||
@@ -23,6 +23,8 @@ struct tracepoint; | |||
23 | struct tracepoint { | 23 | struct tracepoint { |
24 | const char *name; /* Tracepoint name */ | 24 | const char *name; /* Tracepoint name */ |
25 | int state; /* State. */ | 25 | int state; /* State. */ |
26 | void (*regfunc)(void); | ||
27 | void (*unregfunc)(void); | ||
26 | void **funcs; | 28 | void **funcs; |
27 | } __attribute__((aligned(32))); /* | 29 | } __attribute__((aligned(32))); /* |
28 | * Aligned on 32 bytes because it is | 30 | * Aligned on 32 bytes because it is |
@@ -60,10 +62,8 @@ struct tracepoint { | |||
60 | * Make sure the alignment of the structure in the __tracepoints section will | 62 | * Make sure the alignment of the structure in the __tracepoints section will |
61 | * not add unwanted padding between the beginning of the section and the | 63 | * not add unwanted padding between the beginning of the section and the |
62 | * structure. Force alignment to the same alignment as the section start. | 64 | * structure. Force alignment to the same alignment as the section start. |
63 | * An optional set of (un)registration functions can be passed to perform any | ||
64 | * additional (un)registration work. | ||
65 | */ | 65 | */ |
66 | #define DECLARE_TRACE_WITH_CALLBACK(name, proto, args, reg, unreg) \ | 66 | #define DECLARE_TRACE(name, proto, args) \ |
67 | extern struct tracepoint __tracepoint_##name; \ | 67 | extern struct tracepoint __tracepoint_##name; \ |
68 | static inline void trace_##name(proto) \ | 68 | static inline void trace_##name(proto) \ |
69 | { \ | 69 | { \ |
@@ -73,36 +73,23 @@ struct tracepoint { | |||
73 | } \ | 73 | } \ |
74 | static inline int register_trace_##name(void (*probe)(proto)) \ | 74 | static inline int register_trace_##name(void (*probe)(proto)) \ |
75 | { \ | 75 | { \ |
76 | int ret; \ | 76 | return tracepoint_probe_register(#name, (void *)probe); \ |
77 | void (*func)(void) = reg; \ | ||
78 | \ | ||
79 | ret = tracepoint_probe_register(#name, (void *)probe); \ | ||
80 | if (func && !ret) \ | ||
81 | func(); \ | ||
82 | return ret; \ | ||
83 | } \ | 77 | } \ |
84 | static inline int unregister_trace_##name(void (*probe)(proto)) \ | 78 | static inline int unregister_trace_##name(void (*probe)(proto)) \ |
85 | { \ | 79 | { \ |
86 | int ret; \ | 80 | return tracepoint_probe_unregister(#name, (void *)probe);\ |
87 | void (*func)(void) = unreg; \ | ||
88 | \ | ||
89 | ret = tracepoint_probe_unregister(#name, (void *)probe);\ | ||
90 | if (func && !ret) \ | ||
91 | func(); \ | ||
92 | return ret; \ | ||
93 | } | 81 | } |
94 | 82 | ||
95 | 83 | ||
96 | #define DECLARE_TRACE(name, proto, args) \ | 84 | #define DEFINE_TRACE_FN(name, reg, unreg) \ |
97 | DECLARE_TRACE_WITH_CALLBACK(name, TP_PROTO(proto), TP_ARGS(args),\ | ||
98 | NULL, NULL); | ||
99 | |||
100 | #define DEFINE_TRACE(name) \ | ||
101 | static const char __tpstrtab_##name[] \ | 85 | static const char __tpstrtab_##name[] \ |
102 | __attribute__((section("__tracepoints_strings"))) = #name; \ | 86 | __attribute__((section("__tracepoints_strings"))) = #name; \ |
103 | struct tracepoint __tracepoint_##name \ | 87 | struct tracepoint __tracepoint_##name \ |
104 | __attribute__((section("__tracepoints"), aligned(32))) = \ | 88 | __attribute__((section("__tracepoints"), aligned(32))) = \ |
105 | { __tpstrtab_##name, 0, NULL } | 89 | { __tpstrtab_##name, 0, reg, unreg, NULL } |
90 | |||
91 | #define DEFINE_TRACE(name) \ | ||
92 | DEFINE_TRACE_FN(name, NULL, NULL); | ||
106 | 93 | ||
107 | #define EXPORT_TRACEPOINT_SYMBOL_GPL(name) \ | 94 | #define EXPORT_TRACEPOINT_SYMBOL_GPL(name) \ |
108 | EXPORT_SYMBOL_GPL(__tracepoint_##name) | 95 | EXPORT_SYMBOL_GPL(__tracepoint_##name) |
@@ -113,7 +100,7 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin, | |||
113 | struct tracepoint *end); | 100 | struct tracepoint *end); |
114 | 101 | ||
115 | #else /* !CONFIG_TRACEPOINTS */ | 102 | #else /* !CONFIG_TRACEPOINTS */ |
116 | #define DECLARE_TRACE_WITH_CALLBACK(name, proto, args, reg, unreg) \ | 103 | #define DECLARE_TRACE(name, proto, args) \ |
117 | static inline void _do_trace_##name(struct tracepoint *tp, proto) \ | 104 | static inline void _do_trace_##name(struct tracepoint *tp, proto) \ |
118 | { } \ | 105 | { } \ |
119 | static inline void trace_##name(proto) \ | 106 | static inline void trace_##name(proto) \ |
@@ -127,10 +114,7 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin, | |||
127 | return -ENOSYS; \ | 114 | return -ENOSYS; \ |
128 | } | 115 | } |
129 | 116 | ||
130 | #define DECLARE_TRACE(name, proto, args) \ | 117 | #define DEFINE_TRACE_FN(name, reg, unreg) |
131 | DECLARE_TRACE_WITH_CALLBACK(name, TP_PROTO(proto), TP_ARGS(args),\ | ||
132 | NULL, NULL); | ||
133 | |||
134 | #define DEFINE_TRACE(name) | 118 | #define DEFINE_TRACE(name) |
135 | #define EXPORT_TRACEPOINT_SYMBOL_GPL(name) | 119 | #define EXPORT_TRACEPOINT_SYMBOL_GPL(name) |
136 | #define EXPORT_TRACEPOINT_SYMBOL(name) | 120 | #define EXPORT_TRACEPOINT_SYMBOL(name) |
@@ -282,10 +266,16 @@ static inline void tracepoint_synchronize_unregister(void) | |||
282 | * can also by used by generic instrumentation like SystemTap), and | 266 | * can also by used by generic instrumentation like SystemTap), and |
283 | * it is also used to expose a structured trace record in | 267 | * it is also used to expose a structured trace record in |
284 | * /sys/kernel/debug/tracing/events/. | 268 | * /sys/kernel/debug/tracing/events/. |
269 | * | ||
270 | * A set of (un)registration functions can be passed to the variant | ||
271 | * TRACE_EVENT_FN to perform any (un)registration work. | ||
285 | */ | 272 | */ |
286 | 273 | ||
287 | #define TRACE_EVENT(name, proto, args, struct, assign, print) \ | 274 | #define TRACE_EVENT(name, proto, args, struct, assign, print) \ |
288 | DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)) | 275 | DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)) |
276 | #define TRACE_EVENT_FN(name, proto, args, struct, \ | ||
277 | assign, print, reg, unreg) \ | ||
278 | DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)) | ||
289 | #endif | 279 | #endif |
290 | 280 | ||
291 | #endif | 281 | #endif |