aboutsummaryrefslogtreecommitdiffstats
path: root/include/trace/ftrace.h
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-11-18 20:36:26 -0500
committerSteven Rostedt <rostedt@goodmis.org>2009-11-24 18:23:53 -0500
commite5bc9721684e9412f3e0465222f317c362a8ab47 (patch)
tree380e76f64fd58e1f68715514e4b37734f3098fb3 /include/trace/ftrace.h
parentff038f5c37c2070829004a0678372766c2b32180 (diff)
tracing: Create new DEFINE_EVENT_PRINT
After creating the TRACE_EVENT_TEMPLATE I started to look at other trace points to see what duplication was made. I noticed that there are several trace points where they are almost identical except for the name and the output format. Since TRACE_EVENT_TEMPLATE was successful in bringing down the size of trace events, I added a DEFINE_EVENT_PRINT. DEFINE_EVENT_PRINT is used just like DEFINE_EVENT is. That is, the DEFINE_EVENT_PRINT also uses a TRACE_EVENT_TEMPLATE, but it allows the developer to overwrite the print format. If there are two or more TRACE_EVENTS that are identical except for the name and print, then they can be converted to use a TRACE_EVENT_TEMPLATE. Since the TRACE_EVENT_TEMPLATE already does the print output, the first trace event would have its print format held in the TRACE_EVENT_TEMPLATE and be defined with a DEFINE_EVENT. The rest will use the DEFINE_EVENT_PRINT and override the print format. Converting the sched trace points to both DEFINE_EVENT and DEFINE_EVENT_PRINT. Five were converted to DEFINE_EVENT and two were converted to DEFINE_EVENT_PRINT. I was able to get the following: $ size kernel/sched.o-* text data bss dec hex filename 79299 6776 2520 88595 15a13 kernel/sched.o-notrace 101941 11896 2584 116421 1c6c5 kernel/sched.o-templ 104779 11896 2584 119259 1d1db kernel/sched.o-trace sched.o-notrace is the scheduler compiled with no trace points. sched.o-templ is with the use of DEFINE_EVENT and DEFINE_EVENT_PRINT sched.o-trace is the current trace events. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'include/trace/ftrace.h')
-rw-r--r--include/trace/ftrace.h123
1 files changed, 119 insertions, 4 deletions
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 2969f65d8002..b0461772bc8d 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -67,6 +67,10 @@
67#define DEFINE_EVENT(template, name, proto, args) \ 67#define DEFINE_EVENT(template, name, proto, args) \
68 static struct ftrace_event_call event_##name 68 static struct ftrace_event_call event_##name
69 69
70#undef DEFINE_EVENT_PRINT
71#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
72 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
73
70#undef __cpparg 74#undef __cpparg
71#define __cpparg(arg...) arg 75#define __cpparg(arg...) arg
72 76
@@ -120,6 +124,10 @@
120#undef DEFINE_EVENT 124#undef DEFINE_EVENT
121#define DEFINE_EVENT(template, name, proto, args) 125#define DEFINE_EVENT(template, name, proto, args)
122 126
127#undef DEFINE_EVENT_PRINT
128#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
129 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
130
123#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) 131#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
124 132
125/* 133/*
@@ -198,15 +206,28 @@
198#undef TRACE_EVENT_TEMPLATE 206#undef TRACE_EVENT_TEMPLATE
199#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, func, print) \ 207#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, func, print) \
200static int \ 208static int \
201ftrace_format_##call(struct ftrace_event_call *unused, \ 209ftrace_format_setup_##call(struct ftrace_event_call *unused, \
202 struct trace_seq *s) \ 210 struct trace_seq *s) \
203{ \ 211{ \
204 struct ftrace_raw_##call field __attribute__((unused)); \ 212 struct ftrace_raw_##call field __attribute__((unused)); \
205 int ret = 0; \ 213 int ret = 0; \
206 \ 214 \
207 tstruct; \ 215 tstruct; \
208 \ 216 \
209 trace_seq_printf(s, "\nprint fmt: " print); \ 217 return ret; \
218} \
219 \
220static int \
221ftrace_format_##call(struct ftrace_event_call *unused, \
222 struct trace_seq *s) \
223{ \
224 int ret = 0; \
225 \
226 ret = ftrace_format_setup_##call(unused, s); \
227 if (!ret) \
228 return ret; \
229 \
230 ret = trace_seq_printf(s, "\nprint fmt: " print); \
210 \ 231 \
211 return ret; \ 232 return ret; \
212} 233}
@@ -214,6 +235,23 @@ ftrace_format_##call(struct ftrace_event_call *unused, \
214#undef DEFINE_EVENT 235#undef DEFINE_EVENT
215#define DEFINE_EVENT(template, name, proto, args) 236#define DEFINE_EVENT(template, name, proto, args)
216 237
238#undef DEFINE_EVENT_PRINT
239#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
240static int \
241ftrace_format_##name(struct ftrace_event_call *unused, \
242 struct trace_seq *s) \
243{ \
244 int ret = 0; \
245 \
246 ret = ftrace_format_setup_##template(unused, s); \
247 if (!ret) \
248 return ret; \
249 \
250 trace_seq_printf(s, "\nprint fmt: " print); \
251 \
252 return ret; \
253}
254
217#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) 255#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
218 256
219/* 257/*
@@ -325,6 +363,38 @@ ftrace_raw_output_##name(struct trace_iterator *iter, int flags) \
325 #name, iter, flags); \ 363 #name, iter, flags); \
326} 364}
327 365
366#undef DEFINE_EVENT_PRINT
367#define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
368static enum print_line_t \
369ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
370{ \
371 struct trace_seq *s = &iter->seq; \
372 struct ftrace_raw_##template *field; \
373 struct trace_entry *entry; \
374 struct trace_seq *p; \
375 int ret; \
376 \
377 entry = iter->ent; \
378 \
379 if (entry->type != event_##call.id) { \
380 WARN_ON_ONCE(1); \
381 return TRACE_TYPE_UNHANDLED; \
382 } \
383 \
384 field = (typeof(field))entry; \
385 \
386 p = &get_cpu_var(ftrace_event_seq); \
387 trace_seq_init(p); \
388 ret = trace_seq_printf(s, "%s: ", #call); \
389 if (ret) \
390 ret = trace_seq_printf(s, print); \
391 put_cpu(); \
392 if (!ret) \
393 return TRACE_TYPE_PARTIAL_LINE; \
394 \
395 return TRACE_TYPE_HANDLED; \
396}
397
328#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) 398#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
329 399
330#undef __field_ext 400#undef __field_ext
@@ -378,6 +448,10 @@ ftrace_define_fields_##call(struct ftrace_event_call *event_call) \
378#undef DEFINE_EVENT 448#undef DEFINE_EVENT
379#define DEFINE_EVENT(template, name, proto, args) 449#define DEFINE_EVENT(template, name, proto, args)
380 450
451#undef DEFINE_EVENT_PRINT
452#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
453 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
454
381#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) 455#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
382 456
383/* 457/*
@@ -422,6 +496,10 @@ static inline int ftrace_get_offsets_##call( \
422#undef DEFINE_EVENT 496#undef DEFINE_EVENT
423#define DEFINE_EVENT(template, name, proto, args) 497#define DEFINE_EVENT(template, name, proto, args)
424 498
499#undef DEFINE_EVENT_PRINT
500#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
501 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
502
425#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) 503#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
426 504
427#ifdef CONFIG_EVENT_PROFILE 505#ifdef CONFIG_EVENT_PROFILE
@@ -461,6 +539,10 @@ static void ftrace_profile_disable_##name(struct ftrace_event_call *unused)\
461 unregister_trace_##name(ftrace_profile_##name); \ 539 unregister_trace_##name(ftrace_profile_##name); \
462} 540}
463 541
542#undef DEFINE_EVENT_PRINT
543#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
544 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
545
464#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) 546#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
465 547
466#endif 548#endif
@@ -674,7 +756,19 @@ static int ftrace_raw_init_event_##call(struct ftrace_event_call *unused)\
674 event_##call.id = id; \ 756 event_##call.id = id; \
675 INIT_LIST_HEAD(&event_##call.fields); \ 757 INIT_LIST_HEAD(&event_##call.fields); \
676 return 0; \ 758 return 0; \
677} \ 759}
760
761#undef DEFINE_EVENT_PRINT
762#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
763 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
764
765#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
766
767#undef TRACE_EVENT_TEMPLATE
768#define TRACE_EVENT_TEMPLATE(call, proto, args, tstruct, assign, print)
769
770#undef DEFINE_EVENT
771#define DEFINE_EVENT(template, call, proto, args) \
678 \ 772 \
679static struct ftrace_event_call __used \ 773static struct ftrace_event_call __used \
680__attribute__((__aligned__(4))) \ 774__attribute__((__aligned__(4))) \
@@ -690,6 +784,23 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
690 _TRACE_PROFILE_INIT(call) \ 784 _TRACE_PROFILE_INIT(call) \
691} 785}
692 786
787#undef DEFINE_EVENT_PRINT
788#define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
789 \
790static struct ftrace_event_call __used \
791__attribute__((__aligned__(4))) \
792__attribute__((section("_ftrace_events"))) event_##call = { \
793 .name = #call, \
794 .system = __stringify(TRACE_SYSTEM), \
795 .event = &ftrace_event_type_##call, \
796 .raw_init = ftrace_raw_init_event_##call, \
797 .regfunc = ftrace_raw_reg_event_##call, \
798 .unregfunc = ftrace_raw_unreg_event_##call, \
799 .show_format = ftrace_format_##call, \
800 .define_fields = ftrace_define_fields_##template, \
801 _TRACE_PROFILE_INIT(call) \
802}
803
693#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) 804#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
694 805
695/* 806/*
@@ -854,6 +965,10 @@ static void ftrace_profile_##call(proto) \
854 ftrace_profile_templ_##template(event_call, args); \ 965 ftrace_profile_templ_##template(event_call, args); \
855} 966}
856 967
968#undef DEFINE_EVENT_PRINT
969#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
970 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
971
857#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) 972#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
858#endif /* CONFIG_EVENT_PROFILE */ 973#endif /* CONFIG_EVENT_PROFILE */
859 974