diff options
author | Tom Zanussi <tzanussi@gmail.com> | 2009-03-31 01:48:49 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-04-13 18:00:50 -0400 |
commit | e1112b4d96859367a93468027c9635e2ac04eb3f (patch) | |
tree | 5170980ea71ee4bb5d0196880b58dbc997211b65 /kernel/trace/trace_export.c | |
parent | 66de7792c02693b49671afe58c771fde3b092fc7 (diff) |
tracing/filters: add run-time field descriptions to TRACE_EVENT_FORMAT events
This patch adds run-time field descriptions to all the event formats
exported using TRACE_EVENT_FORMAT. It also hooks up all the tracers
that use them (i.e. the tracers in the 'ftrace subsystem') so they can
also have their output filtered by the event-filtering mechanism.
When I was testing this, there were a couple of things that fooled me
into thinking the filters weren't working, when actually they were -
I'll mention them here so others don't make the same mistakes (and file
bug reports. ;-)
One is that some of the tracers trace multiple events e.g. the
sched_switch tracer uses the context_switch and wakeup events, and if
you don't set filters on all of the traced events, the unfiltered output
from the events without filters on them can make it look like the
filtering as a whole isn't working properly, when actually it is doing
what it was asked to do - it just wasn't asked to do the right thing.
The other is that for the really high-volume tracers e.g. the function
tracer, the volume of filtered events can be so high that it pushes the
unfiltered events out of the ring buffer before they can be read so e.g.
cat'ing the trace file repeatedly shows either no output, or once in
awhile some output but that isn't there the next time you read the
trace, which isn't what you normally expect when reading the trace file.
If you read from the trace_pipe file though, you can catch them before
they disappear.
Changes from v1:
As suggested by Frederic Weisbecker:
- get rid of externs in functions
- added unlikely() to filter_check_discard()
Signed-off-by: Tom Zanussi <tzanussi@gmail.com>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace_export.c')
-rw-r--r-- | kernel/trace/trace_export.c | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c index 07a22c33ebf3..f4e46616c48e 100644 --- a/kernel/trace/trace_export.c +++ b/kernel/trace/trace_export.c | |||
@@ -30,7 +30,7 @@ | |||
30 | 30 | ||
31 | 31 | ||
32 | #undef TRACE_FIELD_SPECIAL | 32 | #undef TRACE_FIELD_SPECIAL |
33 | #define TRACE_FIELD_SPECIAL(type_item, item, cmd) \ | 33 | #define TRACE_FIELD_SPECIAL(type_item, item, len, cmd) \ |
34 | ret = trace_seq_printf(s, "\tfield special:" #type_item ";\t" \ | 34 | ret = trace_seq_printf(s, "\tfield special:" #type_item ";\t" \ |
35 | "offset:%u;\tsize:%u;\n", \ | 35 | "offset:%u;\tsize:%u;\n", \ |
36 | (unsigned int)offsetof(typeof(field), item), \ | 36 | (unsigned int)offsetof(typeof(field), item), \ |
@@ -85,18 +85,69 @@ ftrace_format_##call(struct trace_seq *s) \ | |||
85 | #define TRACE_ENTRY entry | 85 | #define TRACE_ENTRY entry |
86 | 86 | ||
87 | #undef TRACE_FIELD_SPECIAL | 87 | #undef TRACE_FIELD_SPECIAL |
88 | #define TRACE_FIELD_SPECIAL(type_item, item, cmd) \ | 88 | #define TRACE_FIELD_SPECIAL(type_item, item, len, cmd) \ |
89 | cmd; | 89 | cmd; |
90 | 90 | ||
91 | #undef TRACE_EVENT_FORMAT | 91 | #undef TRACE_EVENT_FORMAT |
92 | #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ | 92 | #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ |
93 | int ftrace_define_fields_##call(void); \ | ||
94 | static int ftrace_raw_init_event_##call(void); \ | ||
93 | \ | 95 | \ |
94 | static struct ftrace_event_call __used \ | 96 | struct ftrace_event_call __used \ |
95 | __attribute__((__aligned__(4))) \ | 97 | __attribute__((__aligned__(4))) \ |
96 | __attribute__((section("_ftrace_events"))) event_##call = { \ | 98 | __attribute__((section("_ftrace_events"))) event_##call = { \ |
97 | .name = #call, \ | 99 | .name = #call, \ |
98 | .id = proto, \ | 100 | .id = proto, \ |
99 | .system = __stringify(TRACE_SYSTEM), \ | 101 | .system = __stringify(TRACE_SYSTEM), \ |
102 | .raw_init = ftrace_raw_init_event_##call, \ | ||
100 | .show_format = ftrace_format_##call, \ | 103 | .show_format = ftrace_format_##call, \ |
104 | .define_fields = ftrace_define_fields_##call, \ | ||
105 | }; \ | ||
106 | static int ftrace_raw_init_event_##call(void) \ | ||
107 | { \ | ||
108 | INIT_LIST_HEAD(&event_##call.fields); \ | ||
109 | return 0; \ | ||
110 | } \ | ||
111 | |||
112 | #include "trace_event_types.h" | ||
113 | |||
114 | #undef TRACE_FIELD | ||
115 | #define TRACE_FIELD(type, item, assign) \ | ||
116 | ret = trace_define_field(event_call, #type, #item, \ | ||
117 | offsetof(typeof(field), item), \ | ||
118 | sizeof(field.item)); \ | ||
119 | if (ret) \ | ||
120 | return ret; | ||
121 | |||
122 | #undef TRACE_FIELD_SPECIAL | ||
123 | #define TRACE_FIELD_SPECIAL(type, item, len, cmd) \ | ||
124 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ | ||
125 | offsetof(typeof(field), item), \ | ||
126 | sizeof(field.item)); \ | ||
127 | if (ret) \ | ||
128 | return ret; | ||
129 | |||
130 | #undef TRACE_FIELD_ZERO_CHAR | ||
131 | #define TRACE_FIELD_ZERO_CHAR(item) | ||
132 | |||
133 | #undef TRACE_EVENT_FORMAT | ||
134 | #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ | ||
135 | int \ | ||
136 | ftrace_define_fields_##call(void) \ | ||
137 | { \ | ||
138 | struct ftrace_event_call *event_call = &event_##call; \ | ||
139 | struct args field; \ | ||
140 | int ret; \ | ||
141 | \ | ||
142 | __common_field(unsigned char, type); \ | ||
143 | __common_field(unsigned char, flags); \ | ||
144 | __common_field(unsigned char, preempt_count); \ | ||
145 | __common_field(int, pid); \ | ||
146 | __common_field(int, tgid); \ | ||
147 | \ | ||
148 | tstruct; \ | ||
149 | \ | ||
150 | return ret; \ | ||
101 | } | 151 | } |
152 | |||
102 | #include "trace_event_types.h" | 153 | #include "trace_event_types.h" |