diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-04-20 17:04:50 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-05-14 09:50:34 -0400 |
commit | 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e (patch) | |
tree | 904476d7780a27001281b9cb93c7959128f9a1d7 /kernel/trace/trace_sched_wakeup.c | |
parent | 53da59aa6dd881fd0bbdd058a8a299d90ce9dd1d (diff) |
tracing: Let tracepoints have data passed to tracepoint callbacks
This patch adds data to be passed to tracepoint callbacks.
The created functions from DECLARE_TRACE() now need a mandatory data
parameter. For example:
DECLARE_TRACE(mytracepoint, int value, value)
Will create the register function:
int register_trace_mytracepoint((void(*)(void *data, int value))probe,
void *data);
As the first argument, all callbacks (probes) must take a (void *data)
parameter. So a callback for the above tracepoint will look like:
void myprobe(void *data, int value)
{
}
The callback may choose to ignore the data parameter.
This change allows callbacks to register a private data pointer along
with the function probe.
void mycallback(void *data, int value);
register_trace_mytracepoint(mycallback, mydata);
Then the mycallback() will receive the "mydata" as the first parameter
before the args.
A more detailed example:
DECLARE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
/* In the C file */
DEFINE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
[...]
trace_mytracepoint(status);
/* In a file registering this tracepoint */
int my_callback(void *data, int status)
{
struct my_struct my_data = data;
[...]
}
[...]
my_data = kmalloc(sizeof(*my_data), GFP_KERNEL);
init_my_data(my_data);
register_trace_mytracepoint(my_callback, my_data);
The same callback can also be registered to the same tracepoint as long
as the data registered is different. Note, the data must also be used
to unregister the callback:
unregister_trace_mytracepoint(my_callback, my_data);
Because of the data parameter, tracepoints declared this way can not have
no args. That is:
DECLARE_TRACE(mytracepoint, TP_PROTO(void), TP_ARGS());
will cause an error.
If no arguments are needed, a new macro can be used instead:
DECLARE_TRACE_NOARGS(mytracepoint);
Since there are no arguments, the proto and args fields are left out.
This is part of a series to make the tracepoint footprint smaller:
text data bss dec hex filename
4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
4914025 1088868 861512 6864405 68be15 vmlinux.class
4918492 1084612 861512 6864616 68bee8 vmlinux.tracepoint
Again, this patch also increases the size of the kernel, but
lays the ground work for decreasing it.
v5: Fixed net/core/drop_monitor.c to handle these updates.
v4: Moved the DECLARE_TRACE() DECLARE_TRACE_NOARGS out of the
#ifdef CONFIG_TRACE_POINTS, since the two are the same in both
cases. The __DECLARE_TRACE() is what changes.
Thanks to Frederic Weisbecker for pointing this out.
v3: Made all register_* functions require data to be passed and
all callbacks to take a void * parameter as its first argument.
This makes the calling functions comply with C standards.
Also added more comments to the modifications of DECLARE_TRACE().
v2: Made the DECLARE_TRACE() have the ability to pass arguments
and added a new DECLARE_TRACE_NOARGS() for tracepoints that
do not need any arguments.
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace_sched_wakeup.c')
-rw-r--r-- | kernel/trace/trace_sched_wakeup.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c index 8052446ceeaa..0e73bc2ef8c5 100644 --- a/kernel/trace/trace_sched_wakeup.c +++ b/kernel/trace/trace_sched_wakeup.c | |||
@@ -98,7 +98,8 @@ static int report_latency(cycle_t delta) | |||
98 | return 1; | 98 | return 1; |
99 | } | 99 | } |
100 | 100 | ||
101 | static void probe_wakeup_migrate_task(struct task_struct *task, int cpu) | 101 | static void |
102 | probe_wakeup_migrate_task(void *ignore, struct task_struct *task, int cpu) | ||
102 | { | 103 | { |
103 | if (task != wakeup_task) | 104 | if (task != wakeup_task) |
104 | return; | 105 | return; |
@@ -107,7 +108,8 @@ static void probe_wakeup_migrate_task(struct task_struct *task, int cpu) | |||
107 | } | 108 | } |
108 | 109 | ||
109 | static void notrace | 110 | static void notrace |
110 | probe_wakeup_sched_switch(struct task_struct *prev, struct task_struct *next) | 111 | probe_wakeup_sched_switch(void *ignore, |
112 | struct task_struct *prev, struct task_struct *next) | ||
111 | { | 113 | { |
112 | struct trace_array_cpu *data; | 114 | struct trace_array_cpu *data; |
113 | cycle_t T0, T1, delta; | 115 | cycle_t T0, T1, delta; |
@@ -199,7 +201,7 @@ static void wakeup_reset(struct trace_array *tr) | |||
199 | } | 201 | } |
200 | 202 | ||
201 | static void | 203 | static void |
202 | probe_wakeup(struct task_struct *p, int success) | 204 | probe_wakeup(void *ignore, struct task_struct *p, int success) |
203 | { | 205 | { |
204 | struct trace_array_cpu *data; | 206 | struct trace_array_cpu *data; |
205 | int cpu = smp_processor_id(); | 207 | int cpu = smp_processor_id(); |
@@ -263,28 +265,28 @@ static void start_wakeup_tracer(struct trace_array *tr) | |||
263 | { | 265 | { |
264 | int ret; | 266 | int ret; |
265 | 267 | ||
266 | ret = register_trace_sched_wakeup(probe_wakeup); | 268 | ret = register_trace_sched_wakeup(probe_wakeup, NULL); |
267 | if (ret) { | 269 | if (ret) { |
268 | pr_info("wakeup trace: Couldn't activate tracepoint" | 270 | pr_info("wakeup trace: Couldn't activate tracepoint" |
269 | " probe to kernel_sched_wakeup\n"); | 271 | " probe to kernel_sched_wakeup\n"); |
270 | return; | 272 | return; |
271 | } | 273 | } |
272 | 274 | ||
273 | ret = register_trace_sched_wakeup_new(probe_wakeup); | 275 | ret = register_trace_sched_wakeup_new(probe_wakeup, NULL); |
274 | if (ret) { | 276 | if (ret) { |
275 | pr_info("wakeup trace: Couldn't activate tracepoint" | 277 | pr_info("wakeup trace: Couldn't activate tracepoint" |
276 | " probe to kernel_sched_wakeup_new\n"); | 278 | " probe to kernel_sched_wakeup_new\n"); |
277 | goto fail_deprobe; | 279 | goto fail_deprobe; |
278 | } | 280 | } |
279 | 281 | ||
280 | ret = register_trace_sched_switch(probe_wakeup_sched_switch); | 282 | ret = register_trace_sched_switch(probe_wakeup_sched_switch, NULL); |
281 | if (ret) { | 283 | if (ret) { |
282 | pr_info("sched trace: Couldn't activate tracepoint" | 284 | pr_info("sched trace: Couldn't activate tracepoint" |
283 | " probe to kernel_sched_switch\n"); | 285 | " probe to kernel_sched_switch\n"); |
284 | goto fail_deprobe_wake_new; | 286 | goto fail_deprobe_wake_new; |
285 | } | 287 | } |
286 | 288 | ||
287 | ret = register_trace_sched_migrate_task(probe_wakeup_migrate_task); | 289 | ret = register_trace_sched_migrate_task(probe_wakeup_migrate_task, NULL); |
288 | if (ret) { | 290 | if (ret) { |
289 | pr_info("wakeup trace: Couldn't activate tracepoint" | 291 | pr_info("wakeup trace: Couldn't activate tracepoint" |
290 | " probe to kernel_sched_migrate_task\n"); | 292 | " probe to kernel_sched_migrate_task\n"); |
@@ -311,19 +313,19 @@ static void start_wakeup_tracer(struct trace_array *tr) | |||
311 | 313 | ||
312 | return; | 314 | return; |
313 | fail_deprobe_wake_new: | 315 | fail_deprobe_wake_new: |
314 | unregister_trace_sched_wakeup_new(probe_wakeup); | 316 | unregister_trace_sched_wakeup_new(probe_wakeup, NULL); |
315 | fail_deprobe: | 317 | fail_deprobe: |
316 | unregister_trace_sched_wakeup(probe_wakeup); | 318 | unregister_trace_sched_wakeup(probe_wakeup, NULL); |
317 | } | 319 | } |
318 | 320 | ||
319 | static void stop_wakeup_tracer(struct trace_array *tr) | 321 | static void stop_wakeup_tracer(struct trace_array *tr) |
320 | { | 322 | { |
321 | tracer_enabled = 0; | 323 | tracer_enabled = 0; |
322 | unregister_ftrace_function(&trace_ops); | 324 | unregister_ftrace_function(&trace_ops); |
323 | unregister_trace_sched_switch(probe_wakeup_sched_switch); | 325 | unregister_trace_sched_switch(probe_wakeup_sched_switch, NULL); |
324 | unregister_trace_sched_wakeup_new(probe_wakeup); | 326 | unregister_trace_sched_wakeup_new(probe_wakeup, NULL); |
325 | unregister_trace_sched_wakeup(probe_wakeup); | 327 | unregister_trace_sched_wakeup(probe_wakeup, NULL); |
326 | unregister_trace_sched_migrate_task(probe_wakeup_migrate_task); | 328 | unregister_trace_sched_migrate_task(probe_wakeup_migrate_task, NULL); |
327 | } | 329 | } |
328 | 330 | ||
329 | static int __wakeup_tracer_init(struct trace_array *tr) | 331 | static int __wakeup_tracer_init(struct trace_array *tr) |