diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-04-23 10:00:22 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-05-14 14:20:34 -0400 |
commit | 80decc70afc57c87eee9d6b836aec2ecacba3457 (patch) | |
tree | 3aec4c67a5518a9c4e60a6914c5dbb9eb82e952f /include | |
parent | a9a5776380208a3e48a92d0c763ee1a3b486fb73 (diff) |
tracing: Move print functions into event class
Currently, every event has its own trace_event structure. This is
fine since the structure is needed anyway. But the print function
structure (trace_event_functions) is now separate. Since the output
of the trace event is done by the class (with the exception of events
defined by DEFINE_EVENT_PRINT), it makes sense to have the class
define the print functions that all events in the class can use.
This makes a bigger deal with the syscall events since all syscall events
use the same class. The savings here is another 30K.
text data bss dec hex filename
4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
4900382 1048964 861512 6810858 67ecea vmlinux.init
4900446 1049028 861512 6810986 67ed6a vmlinux.preprint
4895024 1023812 861512 6780348 6775bc vmlinux.print
To accomplish this, and to let the class know what event is being
printed, the event structure is embedded in the ftrace_event_call
structure. This should not be an issues since the event structure
was created for each event anyway.
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/ftrace_event.h | 2 | ||||
-rw-r--r-- | include/linux/syscalls.h | 18 | ||||
-rw-r--r-- | include/trace/ftrace.h | 45 |
3 files changed, 24 insertions, 41 deletions
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h index 4f77932b0983..b1a007d6e8fd 100644 --- a/include/linux/ftrace_event.h +++ b/include/linux/ftrace_event.h | |||
@@ -148,7 +148,7 @@ struct ftrace_event_call { | |||
148 | struct ftrace_event_class *class; | 148 | struct ftrace_event_class *class; |
149 | char *name; | 149 | char *name; |
150 | struct dentry *dir; | 150 | struct dentry *dir; |
151 | struct trace_event *event; | 151 | struct trace_event event; |
152 | int enabled; | 152 | int enabled; |
153 | int id; | 153 | int id; |
154 | const char *print_fmt; | 154 | const char *print_fmt; |
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index f7256770a20f..a1a86a53bc73 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h | |||
@@ -120,24 +120,20 @@ struct perf_event_attr; | |||
120 | 120 | ||
121 | extern struct ftrace_event_class event_class_syscall_enter; | 121 | extern struct ftrace_event_class event_class_syscall_enter; |
122 | extern struct ftrace_event_class event_class_syscall_exit; | 122 | extern struct ftrace_event_class event_class_syscall_exit; |
123 | extern struct trace_event_functions enter_syscall_print_funcs; | ||
124 | extern struct trace_event_functions exit_syscall_print_funcs; | ||
123 | 125 | ||
124 | #define SYSCALL_TRACE_ENTER_EVENT(sname) \ | 126 | #define SYSCALL_TRACE_ENTER_EVENT(sname) \ |
125 | static struct syscall_metadata __syscall_meta_##sname; \ | 127 | static struct syscall_metadata __syscall_meta_##sname; \ |
126 | static struct ftrace_event_call \ | 128 | static struct ftrace_event_call \ |
127 | __attribute__((__aligned__(4))) event_enter_##sname; \ | 129 | __attribute__((__aligned__(4))) event_enter_##sname; \ |
128 | static struct trace_event_functions enter_syscall_print_funcs_##sname = { \ | ||
129 | .trace = print_syscall_enter, \ | ||
130 | }; \ | ||
131 | static struct trace_event enter_syscall_print_##sname = { \ | ||
132 | .funcs = &enter_syscall_print_funcs_##sname, \ | ||
133 | }; \ | ||
134 | static struct ftrace_event_call __used \ | 130 | static struct ftrace_event_call __used \ |
135 | __attribute__((__aligned__(4))) \ | 131 | __attribute__((__aligned__(4))) \ |
136 | __attribute__((section("_ftrace_events"))) \ | 132 | __attribute__((section("_ftrace_events"))) \ |
137 | event_enter_##sname = { \ | 133 | event_enter_##sname = { \ |
138 | .name = "sys_enter"#sname, \ | 134 | .name = "sys_enter"#sname, \ |
139 | .class = &event_class_syscall_enter, \ | 135 | .class = &event_class_syscall_enter, \ |
140 | .event = &enter_syscall_print_##sname, \ | 136 | .event.funcs = &enter_syscall_print_funcs, \ |
141 | .data = (void *)&__syscall_meta_##sname,\ | 137 | .data = (void *)&__syscall_meta_##sname,\ |
142 | } | 138 | } |
143 | 139 | ||
@@ -145,19 +141,13 @@ extern struct ftrace_event_class event_class_syscall_exit; | |||
145 | static struct syscall_metadata __syscall_meta_##sname; \ | 141 | static struct syscall_metadata __syscall_meta_##sname; \ |
146 | static struct ftrace_event_call \ | 142 | static struct ftrace_event_call \ |
147 | __attribute__((__aligned__(4))) event_exit_##sname; \ | 143 | __attribute__((__aligned__(4))) event_exit_##sname; \ |
148 | static struct trace_event_functions exit_syscall_print_funcs_##sname = { \ | ||
149 | .trace = print_syscall_exit, \ | ||
150 | }; \ | ||
151 | static struct trace_event exit_syscall_print_##sname = { \ | ||
152 | .funcs = &exit_syscall_print_funcs_##sname, \ | ||
153 | }; \ | ||
154 | static struct ftrace_event_call __used \ | 144 | static struct ftrace_event_call __used \ |
155 | __attribute__((__aligned__(4))) \ | 145 | __attribute__((__aligned__(4))) \ |
156 | __attribute__((section("_ftrace_events"))) \ | 146 | __attribute__((section("_ftrace_events"))) \ |
157 | event_exit_##sname = { \ | 147 | event_exit_##sname = { \ |
158 | .name = "sys_exit"#sname, \ | 148 | .name = "sys_exit"#sname, \ |
159 | .class = &event_class_syscall_exit, \ | 149 | .class = &event_class_syscall_exit, \ |
160 | .event = &exit_syscall_print_##sname, \ | 150 | .event.funcs = &exit_syscall_print_funcs, \ |
161 | .data = (void *)&__syscall_meta_##sname,\ | 151 | .data = (void *)&__syscall_meta_##sname,\ |
162 | } | 152 | } |
163 | 153 | ||
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h index 51ed7f3568a5..824141d5cf04 100644 --- a/include/trace/ftrace.h +++ b/include/trace/ftrace.h | |||
@@ -206,18 +206,22 @@ | |||
206 | #undef DECLARE_EVENT_CLASS | 206 | #undef DECLARE_EVENT_CLASS |
207 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ | 207 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ |
208 | static notrace enum print_line_t \ | 208 | static notrace enum print_line_t \ |
209 | ftrace_raw_output_id_##call(int event_id, const char *name, \ | 209 | ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \ |
210 | struct trace_iterator *iter, int flags) \ | 210 | struct trace_event *trace_event) \ |
211 | { \ | 211 | { \ |
212 | struct ftrace_event_call *event; \ | ||
212 | struct trace_seq *s = &iter->seq; \ | 213 | struct trace_seq *s = &iter->seq; \ |
213 | struct ftrace_raw_##call *field; \ | 214 | struct ftrace_raw_##call *field; \ |
214 | struct trace_entry *entry; \ | 215 | struct trace_entry *entry; \ |
215 | struct trace_seq *p; \ | 216 | struct trace_seq *p; \ |
216 | int ret; \ | 217 | int ret; \ |
217 | \ | 218 | \ |
219 | event = container_of(trace_event, struct ftrace_event_call, \ | ||
220 | event); \ | ||
221 | \ | ||
218 | entry = iter->ent; \ | 222 | entry = iter->ent; \ |
219 | \ | 223 | \ |
220 | if (entry->type != event_id) { \ | 224 | if (entry->type != event->id) { \ |
221 | WARN_ON_ONCE(1); \ | 225 | WARN_ON_ONCE(1); \ |
222 | return TRACE_TYPE_UNHANDLED; \ | 226 | return TRACE_TYPE_UNHANDLED; \ |
223 | } \ | 227 | } \ |
@@ -226,7 +230,7 @@ ftrace_raw_output_id_##call(int event_id, const char *name, \ | |||
226 | \ | 230 | \ |
227 | p = &get_cpu_var(ftrace_event_seq); \ | 231 | p = &get_cpu_var(ftrace_event_seq); \ |
228 | trace_seq_init(p); \ | 232 | trace_seq_init(p); \ |
229 | ret = trace_seq_printf(s, "%s: ", name); \ | 233 | ret = trace_seq_printf(s, "%s: ", event->name); \ |
230 | if (ret) \ | 234 | if (ret) \ |
231 | ret = trace_seq_printf(s, print); \ | 235 | ret = trace_seq_printf(s, print); \ |
232 | put_cpu(); \ | 236 | put_cpu(); \ |
@@ -234,17 +238,10 @@ ftrace_raw_output_id_##call(int event_id, const char *name, \ | |||
234 | return TRACE_TYPE_PARTIAL_LINE; \ | 238 | return TRACE_TYPE_PARTIAL_LINE; \ |
235 | \ | 239 | \ |
236 | return TRACE_TYPE_HANDLED; \ | 240 | return TRACE_TYPE_HANDLED; \ |
237 | } | 241 | } \ |
238 | 242 | static struct trace_event_functions ftrace_event_type_funcs_##call = { \ | |
239 | #undef DEFINE_EVENT | 243 | .trace = ftrace_raw_output_##call, \ |
240 | #define DEFINE_EVENT(template, name, proto, args) \ | 244 | }; |
241 | static notrace enum print_line_t \ | ||
242 | ftrace_raw_output_##name(struct trace_iterator *iter, int flags, \ | ||
243 | struct trace_event *event) \ | ||
244 | { \ | ||
245 | return ftrace_raw_output_id_##template(event_##name.id, \ | ||
246 | #name, iter, flags); \ | ||
247 | } | ||
248 | 245 | ||
249 | #undef DEFINE_EVENT_PRINT | 246 | #undef DEFINE_EVENT_PRINT |
250 | #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \ | 247 | #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \ |
@@ -277,7 +274,10 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \ | |||
277 | return TRACE_TYPE_PARTIAL_LINE; \ | 274 | return TRACE_TYPE_PARTIAL_LINE; \ |
278 | \ | 275 | \ |
279 | return TRACE_TYPE_HANDLED; \ | 276 | return TRACE_TYPE_HANDLED; \ |
280 | } | 277 | } \ |
278 | static struct trace_event_functions ftrace_event_type_funcs_##call = { \ | ||
279 | .trace = ftrace_raw_output_##call, \ | ||
280 | }; | ||
281 | 281 | ||
282 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | 282 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
283 | 283 | ||
@@ -533,20 +533,13 @@ ftrace_raw_event_##call(void *__data, proto) \ | |||
533 | 533 | ||
534 | #undef DEFINE_EVENT | 534 | #undef DEFINE_EVENT |
535 | #define DEFINE_EVENT(template, call, proto, args) \ | 535 | #define DEFINE_EVENT(template, call, proto, args) \ |
536 | static struct trace_event_functions ftrace_event_type_funcs_##call = { \ | ||
537 | .trace = ftrace_raw_output_##call, \ | ||
538 | }; \ | ||
539 | static struct trace_event ftrace_event_type_##call = { \ | ||
540 | .funcs = &ftrace_event_type_funcs_##call, \ | ||
541 | }; \ | ||
542 | static inline void ftrace_test_probe_##call(void) \ | 536 | static inline void ftrace_test_probe_##call(void) \ |
543 | { \ | 537 | { \ |
544 | check_trace_callback_type_##call(ftrace_raw_event_##template); \ | 538 | check_trace_callback_type_##call(ftrace_raw_event_##template); \ |
545 | } | 539 | } |
546 | 540 | ||
547 | #undef DEFINE_EVENT_PRINT | 541 | #undef DEFINE_EVENT_PRINT |
548 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ | 542 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) |
549 | DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) | ||
550 | 543 | ||
551 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | 544 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
552 | 545 | ||
@@ -582,7 +575,7 @@ __attribute__((__aligned__(4))) \ | |||
582 | __attribute__((section("_ftrace_events"))) event_##call = { \ | 575 | __attribute__((section("_ftrace_events"))) event_##call = { \ |
583 | .name = #call, \ | 576 | .name = #call, \ |
584 | .class = &event_class_##template, \ | 577 | .class = &event_class_##template, \ |
585 | .event = &ftrace_event_type_##call, \ | 578 | .event.funcs = &ftrace_event_type_funcs_##template, \ |
586 | .print_fmt = print_fmt_##template, \ | 579 | .print_fmt = print_fmt_##template, \ |
587 | }; | 580 | }; |
588 | 581 | ||
@@ -596,7 +589,7 @@ __attribute__((__aligned__(4))) \ | |||
596 | __attribute__((section("_ftrace_events"))) event_##call = { \ | 589 | __attribute__((section("_ftrace_events"))) event_##call = { \ |
597 | .name = #call, \ | 590 | .name = #call, \ |
598 | .class = &event_class_##template, \ | 591 | .class = &event_class_##template, \ |
599 | .event = &ftrace_event_type_##call, \ | 592 | .event.funcs = &ftrace_event_type_funcs_##call, \ |
600 | .print_fmt = print_fmt_##call, \ | 593 | .print_fmt = print_fmt_##call, \ |
601 | } | 594 | } |
602 | 595 | ||