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 /include/trace/ftrace.h | |
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 'include/trace/ftrace.h')
-rw-r--r-- | include/trace/ftrace.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h index 7dcdfd824aa..ba28b644f41 100644 --- a/include/trace/ftrace.h +++ b/include/trace/ftrace.h | |||
@@ -406,18 +406,18 @@ static inline notrace int ftrace_get_offsets_##call( \ | |||
406 | #undef DEFINE_EVENT | 406 | #undef DEFINE_EVENT |
407 | #define DEFINE_EVENT(template, name, proto, args) \ | 407 | #define DEFINE_EVENT(template, name, proto, args) \ |
408 | \ | 408 | \ |
409 | static void perf_trace_##name(proto); \ | 409 | static void perf_trace_##name(void *, proto); \ |
410 | \ | 410 | \ |
411 | static notrace int \ | 411 | static notrace int \ |
412 | perf_trace_enable_##name(struct ftrace_event_call *unused) \ | 412 | perf_trace_enable_##name(struct ftrace_event_call *unused) \ |
413 | { \ | 413 | { \ |
414 | return register_trace_##name(perf_trace_##name); \ | 414 | return register_trace_##name(perf_trace_##name, NULL); \ |
415 | } \ | 415 | } \ |
416 | \ | 416 | \ |
417 | static notrace void \ | 417 | static notrace void \ |
418 | perf_trace_disable_##name(struct ftrace_event_call *unused) \ | 418 | perf_trace_disable_##name(struct ftrace_event_call *unused) \ |
419 | { \ | 419 | { \ |
420 | unregister_trace_##name(perf_trace_##name); \ | 420 | unregister_trace_##name(perf_trace_##name, NULL); \ |
421 | } | 421 | } |
422 | 422 | ||
423 | #undef DEFINE_EVENT_PRINT | 423 | #undef DEFINE_EVENT_PRINT |
@@ -578,7 +578,7 @@ ftrace_raw_event_id_##call(struct ftrace_event_call *event_call, \ | |||
578 | #undef DEFINE_EVENT | 578 | #undef DEFINE_EVENT |
579 | #define DEFINE_EVENT(template, call, proto, args) \ | 579 | #define DEFINE_EVENT(template, call, proto, args) \ |
580 | \ | 580 | \ |
581 | static notrace void ftrace_raw_event_##call(proto) \ | 581 | static notrace void ftrace_raw_event_##call(void *__ignore, proto) \ |
582 | { \ | 582 | { \ |
583 | ftrace_raw_event_id_##template(&event_##call, args); \ | 583 | ftrace_raw_event_id_##template(&event_##call, args); \ |
584 | } \ | 584 | } \ |
@@ -586,13 +586,13 @@ static notrace void ftrace_raw_event_##call(proto) \ | |||
586 | static notrace int \ | 586 | static notrace int \ |
587 | ftrace_raw_reg_event_##call(struct ftrace_event_call *unused) \ | 587 | ftrace_raw_reg_event_##call(struct ftrace_event_call *unused) \ |
588 | { \ | 588 | { \ |
589 | return register_trace_##call(ftrace_raw_event_##call); \ | 589 | return register_trace_##call(ftrace_raw_event_##call, NULL); \ |
590 | } \ | 590 | } \ |
591 | \ | 591 | \ |
592 | static notrace void \ | 592 | static notrace void \ |
593 | ftrace_raw_unreg_event_##call(struct ftrace_event_call *unused) \ | 593 | ftrace_raw_unreg_event_##call(struct ftrace_event_call *unused) \ |
594 | { \ | 594 | { \ |
595 | unregister_trace_##call(ftrace_raw_event_##call); \ | 595 | unregister_trace_##call(ftrace_raw_event_##call, NULL); \ |
596 | } \ | 596 | } \ |
597 | \ | 597 | \ |
598 | static struct trace_event ftrace_event_type_##call = { \ | 598 | static struct trace_event ftrace_event_type_##call = { \ |
@@ -793,7 +793,7 @@ perf_trace_templ_##call(struct ftrace_event_call *event_call, \ | |||
793 | 793 | ||
794 | #undef DEFINE_EVENT | 794 | #undef DEFINE_EVENT |
795 | #define DEFINE_EVENT(template, call, proto, args) \ | 795 | #define DEFINE_EVENT(template, call, proto, args) \ |
796 | static notrace void perf_trace_##call(proto) \ | 796 | static notrace void perf_trace_##call(void *__ignore, proto) \ |
797 | { \ | 797 | { \ |
798 | struct ftrace_event_call *event_call = &event_##call; \ | 798 | struct ftrace_event_call *event_call = &event_##call; \ |
799 | \ | 799 | \ |