diff options
author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2015-09-22 17:13:19 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2015-10-25 21:33:54 -0400 |
commit | 7904b5c4988e18b50056b5e71a3ffca752a8a451 (patch) | |
tree | 4319a3e6fe143e6404420f885275cb1f7c87a1a4 /include/linux/tracepoint.h | |
parent | 883a1e867e0fe7c2dc2e5844ef692f80177631d5 (diff) |
tracepoint: Give priority to probes of tracepoints
In order to guarantee that a probe will be called before other probes that
are attached to a tracepoint, there needs to be a mechanism to provide
priority of one probe over the others.
Adding a prio field to the struct tracepoint_func, which lets the probes be
sorted by the priority set in the structure. If no priority is specified,
then a priority of 10 is given (this is a macro, and perhaps may be changed
in the future).
Now probes may be added to affect other probes that are attached to a
tracepoint with a guaranteed order.
One use case would be to allow tracing of tracepoints be able to filter by
pid. A special (higher priority probe) may be added to the sched_switch
tracepoint and set the necessary flags of the other tracepoints to notify
them if they should be traced or not. In case a tracepoint is enabled at the
sched_switch tracepoint too, the order of the two are not random.
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'include/linux/tracepoint.h')
-rw-r--r-- | include/linux/tracepoint.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index afada369c5b7..6b79537a42b1 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h | |||
@@ -26,6 +26,7 @@ struct notifier_block; | |||
26 | struct tracepoint_func { | 26 | struct tracepoint_func { |
27 | void *func; | 27 | void *func; |
28 | void *data; | 28 | void *data; |
29 | int prio; | ||
29 | }; | 30 | }; |
30 | 31 | ||
31 | struct tracepoint { | 32 | struct tracepoint { |
@@ -42,9 +43,14 @@ struct trace_enum_map { | |||
42 | unsigned long enum_value; | 43 | unsigned long enum_value; |
43 | }; | 44 | }; |
44 | 45 | ||
46 | #define TRACEPOINT_DEFAULT_PRIO 10 | ||
47 | |||
45 | extern int | 48 | extern int |
46 | tracepoint_probe_register(struct tracepoint *tp, void *probe, void *data); | 49 | tracepoint_probe_register(struct tracepoint *tp, void *probe, void *data); |
47 | extern int | 50 | extern int |
51 | tracepoint_probe_register_prio(struct tracepoint *tp, void *probe, void *data, | ||
52 | int prio); | ||
53 | extern int | ||
48 | tracepoint_probe_unregister(struct tracepoint *tp, void *probe, void *data); | 54 | tracepoint_probe_unregister(struct tracepoint *tp, void *probe, void *data); |
49 | extern void | 55 | extern void |
50 | for_each_kernel_tracepoint(void (*fct)(struct tracepoint *tp, void *priv), | 56 | for_each_kernel_tracepoint(void (*fct)(struct tracepoint *tp, void *priv), |
@@ -207,6 +213,13 @@ extern void syscall_unregfunc(void); | |||
207 | (void *)probe, data); \ | 213 | (void *)probe, data); \ |
208 | } \ | 214 | } \ |
209 | static inline int \ | 215 | static inline int \ |
216 | register_trace_prio_##name(void (*probe)(data_proto), void *data,\ | ||
217 | int prio) \ | ||
218 | { \ | ||
219 | return tracepoint_probe_register_prio(&__tracepoint_##name, \ | ||
220 | (void *)probe, data, prio); \ | ||
221 | } \ | ||
222 | static inline int \ | ||
210 | unregister_trace_##name(void (*probe)(data_proto), void *data) \ | 223 | unregister_trace_##name(void (*probe)(data_proto), void *data) \ |
211 | { \ | 224 | { \ |
212 | return tracepoint_probe_unregister(&__tracepoint_##name,\ | 225 | return tracepoint_probe_unregister(&__tracepoint_##name,\ |