Commit a9a5776380208a3e48a92d0c763ee1a3b486fb73

Authored by Steven Rostedt
Committed by Steven Rostedt
1 parent 0405ab80aa

tracing: Allow events to share their print functions

Multiple events may use the same method to print their data.
Instead of having all events have a pointer to their print funtions,
the trace_event structure now points to a trace_event_functions structure
that will hold the way to print ouf the event.

The event itself is now passed to the print function to let the print
function know what kind of event it should print.

This opens the door to consolidating the way several events print
their output.

   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

This change slightly increases the size but is needed for the next change.

v3: Fix the branch tracer events to handle this change.

v2: Fix the new function graph tracer event calls to handle this change.

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>

Showing 13 changed files with 192 additions and 92 deletions Side-by-side Diff

include/linux/ftrace_event.h
... ... @@ -70,16 +70,23 @@
70 70 };
71 71  
72 72  
  73 +struct trace_event;
  74 +
73 75 typedef enum print_line_t (*trace_print_func)(struct trace_iterator *iter,
74   - int flags);
75   -struct trace_event {
76   - struct hlist_node node;
77   - struct list_head list;
78   - int type;
  76 + int flags, struct trace_event *event);
  77 +
  78 +struct trace_event_functions {
79 79 trace_print_func trace;
80 80 trace_print_func raw;
81 81 trace_print_func hex;
82 82 trace_print_func binary;
  83 +};
  84 +
  85 +struct trace_event {
  86 + struct hlist_node node;
  87 + struct list_head list;
  88 + int type;
  89 + struct trace_event_functions *funcs;
83 90 };
84 91  
85 92 extern int register_ftrace_event(struct trace_event *event);
include/linux/syscalls.h
... ... @@ -125,9 +125,12 @@
125 125 static struct syscall_metadata __syscall_meta_##sname; \
126 126 static struct ftrace_event_call \
127 127 __attribute__((__aligned__(4))) event_enter_##sname; \
128   - static struct trace_event enter_syscall_print_##sname = { \
  128 + static struct trace_event_functions enter_syscall_print_funcs_##sname = { \
129 129 .trace = print_syscall_enter, \
130 130 }; \
  131 + static struct trace_event enter_syscall_print_##sname = { \
  132 + .funcs = &enter_syscall_print_funcs_##sname, \
  133 + }; \
131 134 static struct ftrace_event_call __used \
132 135 __attribute__((__aligned__(4))) \
133 136 __attribute__((section("_ftrace_events"))) \
134 137  
... ... @@ -142,8 +145,11 @@
142 145 static struct syscall_metadata __syscall_meta_##sname; \
143 146 static struct ftrace_event_call \
144 147 __attribute__((__aligned__(4))) event_exit_##sname; \
145   - static struct trace_event exit_syscall_print_##sname = { \
  148 + static struct trace_event_functions exit_syscall_print_funcs_##sname = { \
146 149 .trace = print_syscall_exit, \
  150 + }; \
  151 + static struct trace_event exit_syscall_print_##sname = { \
  152 + .funcs = &exit_syscall_print_funcs_##sname, \
147 153 }; \
148 154 static struct ftrace_event_call __used \
149 155 __attribute__((__aligned__(4))) \
include/trace/ftrace.h
... ... @@ -239,7 +239,8 @@
239 239 #undef DEFINE_EVENT
240 240 #define DEFINE_EVENT(template, name, proto, args) \
241 241 static notrace enum print_line_t \
242   -ftrace_raw_output_##name(struct trace_iterator *iter, int flags) \
  242 +ftrace_raw_output_##name(struct trace_iterator *iter, int flags, \
  243 + struct trace_event *event) \
243 244 { \
244 245 return ftrace_raw_output_id_##template(event_##name.id, \
245 246 #name, iter, flags); \
... ... @@ -248,7 +249,8 @@
248 249 #undef DEFINE_EVENT_PRINT
249 250 #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
250 251 static notrace enum print_line_t \
251   -ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
  252 +ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \
  253 + struct trace_event *event) \
252 254 { \
253 255 struct trace_seq *s = &iter->seq; \
254 256 struct ftrace_raw_##template *field; \
255 257  
... ... @@ -531,11 +533,12 @@
531 533  
532 534 #undef DEFINE_EVENT
533 535 #define DEFINE_EVENT(template, call, proto, args) \
534   - \
535   -static struct trace_event ftrace_event_type_##call = { \
  536 +static struct trace_event_functions ftrace_event_type_funcs_##call = { \
536 537 .trace = ftrace_raw_output_##call, \
537 538 }; \
538   - \
  539 +static struct trace_event ftrace_event_type_##call = { \
  540 + .funcs = &ftrace_event_type_funcs_##call, \
  541 +}; \
539 542 static inline void ftrace_test_probe_##call(void) \
540 543 { \
541 544 check_trace_callback_type_##call(ftrace_raw_event_##template); \
include/trace/syscall.h
... ... @@ -42,8 +42,10 @@
42 42 extern void unreg_event_syscall_exit(struct ftrace_event_call *call);
43 43 extern int
44 44 ftrace_format_syscall(struct ftrace_event_call *call, struct trace_seq *s);
45   -enum print_line_t print_syscall_enter(struct trace_iterator *iter, int flags);
46   -enum print_line_t print_syscall_exit(struct trace_iterator *iter, int flags);
  45 +enum print_line_t print_syscall_enter(struct trace_iterator *iter, int flags,
  46 + struct trace_event *event);
  47 +enum print_line_t print_syscall_exit(struct trace_iterator *iter, int flags,
  48 + struct trace_event *event);
47 49 #endif
48 50  
49 51 #ifdef CONFIG_PERF_EVENTS
kernel/trace/blktrace.c
... ... @@ -1336,7 +1336,7 @@
1336 1336 }
1337 1337  
1338 1338 static enum print_line_t blk_trace_event_print(struct trace_iterator *iter,
1339   - int flags)
  1339 + int flags, struct trace_event *event)
1340 1340 {
1341 1341 return print_one_line(iter, false);
1342 1342 }
... ... @@ -1358,7 +1358,8 @@
1358 1358 }
1359 1359  
1360 1360 static enum print_line_t
1361   -blk_trace_event_print_binary(struct trace_iterator *iter, int flags)
  1361 +blk_trace_event_print_binary(struct trace_iterator *iter, int flags,
  1362 + struct trace_event *event)
1362 1363 {
1363 1364 return blk_trace_synthesize_old_trace(iter) ?
1364 1365 TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
1365 1366  
... ... @@ -1396,10 +1397,14 @@
1396 1397 .set_flag = blk_tracer_set_flag,
1397 1398 };
1398 1399  
1399   -static struct trace_event trace_blk_event = {
1400   - .type = TRACE_BLK,
  1400 +static struct trace_event_functions trace_blk_event_funcs = {
1401 1401 .trace = blk_trace_event_print,
1402 1402 .binary = blk_trace_event_print_binary,
  1403 +};
  1404 +
  1405 +static struct trace_event trace_blk_event = {
  1406 + .type = TRACE_BLK,
  1407 + .funcs = &trace_blk_event_funcs,
1403 1408 };
1404 1409  
1405 1410 static int __init init_blk_tracer(void)
kernel/trace/kmemtrace.c
... ... @@ -243,7 +243,8 @@
243 243 };
244 244  
245 245 static enum print_line_t
246   -kmemtrace_print_alloc(struct trace_iterator *iter, int flags)
  246 +kmemtrace_print_alloc(struct trace_iterator *iter, int flags,
  247 + struct trace_event *event)
247 248 {
248 249 struct trace_seq *s = &iter->seq;
249 250 struct kmemtrace_alloc_entry *entry;
... ... @@ -263,7 +264,8 @@
263 264 }
264 265  
265 266 static enum print_line_t
266   -kmemtrace_print_free(struct trace_iterator *iter, int flags)
  267 +kmemtrace_print_free(struct trace_iterator *iter, int flags,
  268 + struct trace_event *event)
267 269 {
268 270 struct trace_seq *s = &iter->seq;
269 271 struct kmemtrace_free_entry *entry;
... ... @@ -281,7 +283,8 @@
281 283 }
282 284  
283 285 static enum print_line_t
284   -kmemtrace_print_alloc_user(struct trace_iterator *iter, int flags)
  286 +kmemtrace_print_alloc_user(struct trace_iterator *iter, int flags,
  287 + struct trace_event *event)
285 288 {
286 289 struct trace_seq *s = &iter->seq;
287 290 struct kmemtrace_alloc_entry *entry;
... ... @@ -315,7 +318,8 @@
315 318 }
316 319  
317 320 static enum print_line_t
318   -kmemtrace_print_free_user(struct trace_iterator *iter, int flags)
  321 +kmemtrace_print_free_user(struct trace_iterator *iter, int flags,
  322 + struct trace_event *event)
319 323 {
320 324 struct trace_seq *s = &iter->seq;
321 325 struct kmemtrace_free_entry *entry;
322 326  
323 327  
... ... @@ -469,16 +473,24 @@
469 473 }
470 474 }
471 475  
472   -static struct trace_event kmem_trace_alloc = {
473   - .type = TRACE_KMEM_ALLOC,
  476 +static struct trace_event_functions kmem_trace_alloc_funcs = {
474 477 .trace = kmemtrace_print_alloc,
475 478 .binary = kmemtrace_print_alloc_user,
476 479 };
477 480  
478   -static struct trace_event kmem_trace_free = {
479   - .type = TRACE_KMEM_FREE,
  481 +static struct trace_event kmem_trace_alloc = {
  482 + .type = TRACE_KMEM_ALLOC,
  483 + .funcs = &kmem_trace_alloc_funcs,
  484 +};
  485 +
  486 +static struct trace_event_functions kmem_trace_free_funcs = {
480 487 .trace = kmemtrace_print_free,
481 488 .binary = kmemtrace_print_free_user,
  489 +};
  490 +
  491 +static struct trace_event kmem_trace_free = {
  492 + .type = TRACE_KMEM_FREE,
  493 + .funcs = &kmem_trace_free_funcs,
482 494 };
483 495  
484 496 static struct tracer kmem_tracer __read_mostly = {
kernel/trace/trace.c
... ... @@ -1936,7 +1936,7 @@
1936 1936 }
1937 1937  
1938 1938 if (event)
1939   - return event->trace(iter, sym_flags);
  1939 + return event->funcs->trace(iter, sym_flags, event);
1940 1940  
1941 1941 if (!trace_seq_printf(s, "Unknown type %d\n", entry->type))
1942 1942 goto partial;
... ... @@ -1962,7 +1962,7 @@
1962 1962  
1963 1963 event = ftrace_find_event(entry->type);
1964 1964 if (event)
1965   - return event->raw(iter, 0);
  1965 + return event->funcs->raw(iter, 0, event);
1966 1966  
1967 1967 if (!trace_seq_printf(s, "%d ?\n", entry->type))
1968 1968 goto partial;
... ... @@ -1989,7 +1989,7 @@
1989 1989  
1990 1990 event = ftrace_find_event(entry->type);
1991 1991 if (event) {
1992   - enum print_line_t ret = event->hex(iter, 0);
  1992 + enum print_line_t ret = event->funcs->hex(iter, 0, event);
1993 1993 if (ret != TRACE_TYPE_HANDLED)
1994 1994 return ret;
1995 1995 }
... ... @@ -2014,7 +2014,8 @@
2014 2014 }
2015 2015  
2016 2016 event = ftrace_find_event(entry->type);
2017   - return event ? event->binary(iter, 0) : TRACE_TYPE_HANDLED;
  2017 + return event ? event->funcs->binary(iter, 0, event) :
  2018 + TRACE_TYPE_HANDLED;
2018 2019 }
2019 2020  
2020 2021 int trace_empty(struct trace_iterator *iter)
kernel/trace/trace_branch.c
... ... @@ -143,7 +143,7 @@
143 143 }
144 144  
145 145 static enum print_line_t trace_branch_print(struct trace_iterator *iter,
146   - int flags)
  146 + int flags, struct trace_event *event)
147 147 {
148 148 struct trace_branch *field;
149 149  
150 150  
... ... @@ -167,9 +167,13 @@
167 167 " |\n");
168 168 }
169 169  
  170 +static struct trace_event_functions trace_branch_funcs = {
  171 + .trace = trace_branch_print,
  172 +};
  173 +
170 174 static struct trace_event trace_branch_event = {
171 175 .type = TRACE_BRANCH,
172   - .trace = trace_branch_print,
  176 + .funcs = &trace_branch_funcs,
173 177 };
174 178  
175 179 static struct tracer branch_trace __read_mostly =
kernel/trace/trace_functions_graph.c
... ... @@ -1025,7 +1025,7 @@
1025 1025 if (!event)
1026 1026 return TRACE_TYPE_UNHANDLED;
1027 1027  
1028   - ret = event->trace(iter, sym_flags);
  1028 + ret = event->funcs->trace(iter, sym_flags, event);
1029 1029 if (ret != TRACE_TYPE_HANDLED)
1030 1030 return ret;
1031 1031 }
... ... @@ -1112,7 +1112,8 @@
1112 1112 }
1113 1113  
1114 1114 static enum print_line_t
1115   -print_graph_function_event(struct trace_iterator *iter, int flags)
  1115 +print_graph_function_event(struct trace_iterator *iter, int flags,
  1116 + struct trace_event *event)
1116 1117 {
1117 1118 return print_graph_function(iter);
1118 1119 }
1119 1120  
1120 1121  
... ... @@ -1225,14 +1226,18 @@
1225 1226 }
1226 1227 }
1227 1228  
  1229 +static struct trace_event_functions graph_functions = {
  1230 + .trace = print_graph_function_event,
  1231 +};
  1232 +
1228 1233 static struct trace_event graph_trace_entry_event = {
1229 1234 .type = TRACE_GRAPH_ENT,
1230   - .trace = print_graph_function_event,
  1235 + .funcs = &graph_functions,
1231 1236 };
1232 1237  
1233 1238 static struct trace_event graph_trace_ret_event = {
1234 1239 .type = TRACE_GRAPH_RET,
1235   - .trace = print_graph_function_event,
  1240 + .funcs = &graph_functions
1236 1241 };
1237 1242  
1238 1243 static struct tracer graph_trace __read_mostly = {
kernel/trace/trace_kprobe.c
... ... @@ -1011,16 +1011,15 @@
1011 1011  
1012 1012 /* Event entry printers */
1013 1013 enum print_line_t
1014   -print_kprobe_event(struct trace_iterator *iter, int flags)
  1014 +print_kprobe_event(struct trace_iterator *iter, int flags,
  1015 + struct trace_event *event)
1015 1016 {
1016 1017 struct kprobe_trace_entry *field;
1017 1018 struct trace_seq *s = &iter->seq;
1018   - struct trace_event *event;
1019 1019 struct trace_probe *tp;
1020 1020 int i;
1021 1021  
1022 1022 field = (struct kprobe_trace_entry *)iter->ent;
1023   - event = ftrace_find_event(field->ent.type);
1024 1023 tp = container_of(event, struct trace_probe, event);
1025 1024  
1026 1025 if (!trace_seq_printf(s, "%s: (", tp->call.name))
1027 1026  
1028 1027  
... ... @@ -1046,16 +1045,15 @@
1046 1045 }
1047 1046  
1048 1047 enum print_line_t
1049   -print_kretprobe_event(struct trace_iterator *iter, int flags)
  1048 +print_kretprobe_event(struct trace_iterator *iter, int flags,
  1049 + struct trace_event *event)
1050 1050 {
1051 1051 struct kretprobe_trace_entry *field;
1052 1052 struct trace_seq *s = &iter->seq;
1053   - struct trace_event *event;
1054 1053 struct trace_probe *tp;
1055 1054 int i;
1056 1055  
1057 1056 field = (struct kretprobe_trace_entry *)iter->ent;
1058   - event = ftrace_find_event(field->ent.type);
1059 1057 tp = container_of(event, struct trace_probe, event);
1060 1058  
1061 1059 if (!trace_seq_printf(s, "%s: (", tp->call.name))
... ... @@ -1351,6 +1349,14 @@
1351 1349 return 0; /* We don't tweek kernel, so just return 0 */
1352 1350 }
1353 1351  
  1352 +static struct trace_event_functions kretprobe_funcs = {
  1353 + .trace = print_kretprobe_event
  1354 +};
  1355 +
  1356 +static struct trace_event_functions kprobe_funcs = {
  1357 + .trace = print_kprobe_event
  1358 +};
  1359 +
1354 1360 static int register_probe_event(struct trace_probe *tp)
1355 1361 {
1356 1362 struct ftrace_event_call *call = &tp->call;
1357 1363  
... ... @@ -1358,13 +1364,13 @@
1358 1364  
1359 1365 /* Initialize ftrace_event_call */
1360 1366 if (probe_is_return(tp)) {
1361   - tp->event.trace = print_kretprobe_event;
  1367 + tp->event.funcs = &kretprobe_funcs;
1362 1368 INIT_LIST_HEAD(&call->class->fields);
1363 1369 call->class->raw_init = probe_event_raw_init;
1364 1370 call->class->define_fields = kretprobe_event_define_fields;
1365 1371 } else {
1366 1372 INIT_LIST_HEAD(&call->class->fields);
1367   - tp->event.trace = print_kprobe_event;
  1373 + tp->event.funcs = &kprobe_funcs;
1368 1374 call->class->raw_init = probe_event_raw_init;
1369 1375 call->class->define_fields = kprobe_event_define_fields;
1370 1376 }
kernel/trace/trace_output.c
... ... @@ -726,6 +726,9 @@
726 726 if (WARN_ON(!event))
727 727 goto out;
728 728  
  729 + if (WARN_ON(!event->funcs))
  730 + goto out;
  731 +
729 732 INIT_LIST_HEAD(&event->list);
730 733  
731 734 if (!event->type) {
... ... @@ -758,14 +761,14 @@
758 761 goto out;
759 762 }
760 763  
761   - if (event->trace == NULL)
762   - event->trace = trace_nop_print;
763   - if (event->raw == NULL)
764   - event->raw = trace_nop_print;
765   - if (event->hex == NULL)
766   - event->hex = trace_nop_print;
767   - if (event->binary == NULL)
768   - event->binary = trace_nop_print;
  764 + if (event->funcs->trace == NULL)
  765 + event->funcs->trace = trace_nop_print;
  766 + if (event->funcs->raw == NULL)
  767 + event->funcs->raw = trace_nop_print;
  768 + if (event->funcs->hex == NULL)
  769 + event->funcs->hex = trace_nop_print;
  770 + if (event->funcs->binary == NULL)
  771 + event->funcs->binary = trace_nop_print;
769 772  
770 773 key = event->type & (EVENT_HASHSIZE - 1);
771 774  
772 775  
... ... @@ -807,13 +810,15 @@
807 810 * Standard events
808 811 */
809 812  
810   -enum print_line_t trace_nop_print(struct trace_iterator *iter, int flags)
  813 +enum print_line_t trace_nop_print(struct trace_iterator *iter, int flags,
  814 + struct trace_event *event)
811 815 {
812 816 return TRACE_TYPE_HANDLED;
813 817 }
814 818  
815 819 /* TRACE_FN */
816   -static enum print_line_t trace_fn_trace(struct trace_iterator *iter, int flags)
  820 +static enum print_line_t trace_fn_trace(struct trace_iterator *iter, int flags,
  821 + struct trace_event *event)
817 822 {
818 823 struct ftrace_entry *field;
819 824 struct trace_seq *s = &iter->seq;
... ... @@ -840,7 +845,8 @@
840 845 return TRACE_TYPE_PARTIAL_LINE;
841 846 }
842 847  
843   -static enum print_line_t trace_fn_raw(struct trace_iterator *iter, int flags)
  848 +static enum print_line_t trace_fn_raw(struct trace_iterator *iter, int flags,
  849 + struct trace_event *event)
844 850 {
845 851 struct ftrace_entry *field;
846 852  
... ... @@ -854,7 +860,8 @@
854 860 return TRACE_TYPE_HANDLED;
855 861 }
856 862  
857   -static enum print_line_t trace_fn_hex(struct trace_iterator *iter, int flags)
  863 +static enum print_line_t trace_fn_hex(struct trace_iterator *iter, int flags,
  864 + struct trace_event *event)
858 865 {
859 866 struct ftrace_entry *field;
860 867 struct trace_seq *s = &iter->seq;
... ... @@ -867,7 +874,8 @@
867 874 return TRACE_TYPE_HANDLED;
868 875 }
869 876  
870   -static enum print_line_t trace_fn_bin(struct trace_iterator *iter, int flags)
  877 +static enum print_line_t trace_fn_bin(struct trace_iterator *iter, int flags,
  878 + struct trace_event *event)
871 879 {
872 880 struct ftrace_entry *field;
873 881 struct trace_seq *s = &iter->seq;
874 882  
... ... @@ -880,14 +888,18 @@
880 888 return TRACE_TYPE_HANDLED;
881 889 }
882 890  
883   -static struct trace_event trace_fn_event = {
884   - .type = TRACE_FN,
  891 +static struct trace_event_functions trace_fn_funcs = {
885 892 .trace = trace_fn_trace,
886 893 .raw = trace_fn_raw,
887 894 .hex = trace_fn_hex,
888 895 .binary = trace_fn_bin,
889 896 };
890 897  
  898 +static struct trace_event trace_fn_event = {
  899 + .type = TRACE_FN,
  900 + .funcs = &trace_fn_funcs,
  901 +};
  902 +
891 903 /* TRACE_CTX an TRACE_WAKE */
892 904 static enum print_line_t trace_ctxwake_print(struct trace_iterator *iter,
893 905 char *delim)
894 906  
... ... @@ -916,13 +928,14 @@
916 928 return TRACE_TYPE_HANDLED;
917 929 }
918 930  
919   -static enum print_line_t trace_ctx_print(struct trace_iterator *iter, int flags)
  931 +static enum print_line_t trace_ctx_print(struct trace_iterator *iter, int flags,
  932 + struct trace_event *event)
920 933 {
921 934 return trace_ctxwake_print(iter, "==>");
922 935 }
923 936  
924 937 static enum print_line_t trace_wake_print(struct trace_iterator *iter,
925   - int flags)
  938 + int flags, struct trace_event *event)
926 939 {
927 940 return trace_ctxwake_print(iter, " +");
928 941 }
929 942  
... ... @@ -950,12 +963,14 @@
950 963 return TRACE_TYPE_HANDLED;
951 964 }
952 965  
953   -static enum print_line_t trace_ctx_raw(struct trace_iterator *iter, int flags)
  966 +static enum print_line_t trace_ctx_raw(struct trace_iterator *iter, int flags,
  967 + struct trace_event *event)
954 968 {
955 969 return trace_ctxwake_raw(iter, 0);
956 970 }
957 971  
958   -static enum print_line_t trace_wake_raw(struct trace_iterator *iter, int flags)
  972 +static enum print_line_t trace_wake_raw(struct trace_iterator *iter, int flags,
  973 + struct trace_event *event)
959 974 {
960 975 return trace_ctxwake_raw(iter, '+');
961 976 }
962 977  
963 978  
... ... @@ -984,18 +999,20 @@
984 999 return TRACE_TYPE_HANDLED;
985 1000 }
986 1001  
987   -static enum print_line_t trace_ctx_hex(struct trace_iterator *iter, int flags)
  1002 +static enum print_line_t trace_ctx_hex(struct trace_iterator *iter, int flags,
  1003 + struct trace_event *event)
988 1004 {
989 1005 return trace_ctxwake_hex(iter, 0);
990 1006 }
991 1007  
992   -static enum print_line_t trace_wake_hex(struct trace_iterator *iter, int flags)
  1008 +static enum print_line_t trace_wake_hex(struct trace_iterator *iter, int flags,
  1009 + struct trace_event *event)
993 1010 {
994 1011 return trace_ctxwake_hex(iter, '+');
995 1012 }
996 1013  
997 1014 static enum print_line_t trace_ctxwake_bin(struct trace_iterator *iter,
998   - int flags)
  1015 + int flags, struct trace_event *event)
999 1016 {
1000 1017 struct ctx_switch_entry *field;
1001 1018 struct trace_seq *s = &iter->seq;
1002 1019  
1003 1020  
1004 1021  
... ... @@ -1012,25 +1029,33 @@
1012 1029 return TRACE_TYPE_HANDLED;
1013 1030 }
1014 1031  
1015   -static struct trace_event trace_ctx_event = {
1016   - .type = TRACE_CTX,
  1032 +static struct trace_event_functions trace_ctx_funcs = {
1017 1033 .trace = trace_ctx_print,
1018 1034 .raw = trace_ctx_raw,
1019 1035 .hex = trace_ctx_hex,
1020 1036 .binary = trace_ctxwake_bin,
1021 1037 };
1022 1038  
1023   -static struct trace_event trace_wake_event = {
1024   - .type = TRACE_WAKE,
  1039 +static struct trace_event trace_ctx_event = {
  1040 + .type = TRACE_CTX,
  1041 + .funcs = &trace_ctx_funcs,
  1042 +};
  1043 +
  1044 +static struct trace_event_functions trace_wake_funcs = {
1025 1045 .trace = trace_wake_print,
1026 1046 .raw = trace_wake_raw,
1027 1047 .hex = trace_wake_hex,
1028 1048 .binary = trace_ctxwake_bin,
1029 1049 };
1030 1050  
  1051 +static struct trace_event trace_wake_event = {
  1052 + .type = TRACE_WAKE,
  1053 + .funcs = &trace_wake_funcs,
  1054 +};
  1055 +
1031 1056 /* TRACE_SPECIAL */
1032 1057 static enum print_line_t trace_special_print(struct trace_iterator *iter,
1033   - int flags)
  1058 + int flags, struct trace_event *event)
1034 1059 {
1035 1060 struct special_entry *field;
1036 1061  
... ... @@ -1046,7 +1071,7 @@
1046 1071 }
1047 1072  
1048 1073 static enum print_line_t trace_special_hex(struct trace_iterator *iter,
1049   - int flags)
  1074 + int flags, struct trace_event *event)
1050 1075 {
1051 1076 struct special_entry *field;
1052 1077 struct trace_seq *s = &iter->seq;
... ... @@ -1061,7 +1086,7 @@
1061 1086 }
1062 1087  
1063 1088 static enum print_line_t trace_special_bin(struct trace_iterator *iter,
1064   - int flags)
  1089 + int flags, struct trace_event *event)
1065 1090 {
1066 1091 struct special_entry *field;
1067 1092 struct trace_seq *s = &iter->seq;
1068 1093  
1069 1094  
... ... @@ -1075,18 +1100,22 @@
1075 1100 return TRACE_TYPE_HANDLED;
1076 1101 }
1077 1102  
1078   -static struct trace_event trace_special_event = {
1079   - .type = TRACE_SPECIAL,
  1103 +static struct trace_event_functions trace_special_funcs = {
1080 1104 .trace = trace_special_print,
1081 1105 .raw = trace_special_print,
1082 1106 .hex = trace_special_hex,
1083 1107 .binary = trace_special_bin,
1084 1108 };
1085 1109  
  1110 +static struct trace_event trace_special_event = {
  1111 + .type = TRACE_SPECIAL,
  1112 + .funcs = &trace_special_funcs,
  1113 +};
  1114 +
1086 1115 /* TRACE_STACK */
1087 1116  
1088 1117 static enum print_line_t trace_stack_print(struct trace_iterator *iter,
1089   - int flags)
  1118 + int flags, struct trace_event *event)
1090 1119 {
1091 1120 struct stack_entry *field;
1092 1121 struct trace_seq *s = &iter->seq;
1093 1122  
1094 1123  
... ... @@ -1114,17 +1143,21 @@
1114 1143 return TRACE_TYPE_PARTIAL_LINE;
1115 1144 }
1116 1145  
1117   -static struct trace_event trace_stack_event = {
1118   - .type = TRACE_STACK,
  1146 +static struct trace_event_functions trace_stack_funcs = {
1119 1147 .trace = trace_stack_print,
1120 1148 .raw = trace_special_print,
1121 1149 .hex = trace_special_hex,
1122 1150 .binary = trace_special_bin,
1123 1151 };
1124 1152  
  1153 +static struct trace_event trace_stack_event = {
  1154 + .type = TRACE_STACK,
  1155 + .funcs = &trace_stack_funcs,
  1156 +};
  1157 +
1125 1158 /* TRACE_USER_STACK */
1126 1159 static enum print_line_t trace_user_stack_print(struct trace_iterator *iter,
1127   - int flags)
  1160 + int flags, struct trace_event *event)
1128 1161 {
1129 1162 struct userstack_entry *field;
1130 1163 struct trace_seq *s = &iter->seq;
1131 1164  
1132 1165  
... ... @@ -1143,17 +1176,22 @@
1143 1176 return TRACE_TYPE_PARTIAL_LINE;
1144 1177 }
1145 1178  
1146   -static struct trace_event trace_user_stack_event = {
1147   - .type = TRACE_USER_STACK,
  1179 +static struct trace_event_functions trace_user_stack_funcs = {
1148 1180 .trace = trace_user_stack_print,
1149 1181 .raw = trace_special_print,
1150 1182 .hex = trace_special_hex,
1151 1183 .binary = trace_special_bin,
1152 1184 };
1153 1185  
  1186 +static struct trace_event trace_user_stack_event = {
  1187 + .type = TRACE_USER_STACK,
  1188 + .funcs = &trace_user_stack_funcs,
  1189 +};
  1190 +
1154 1191 /* TRACE_BPRINT */
1155 1192 static enum print_line_t
1156   -trace_bprint_print(struct trace_iterator *iter, int flags)
  1193 +trace_bprint_print(struct trace_iterator *iter, int flags,
  1194 + struct trace_event *event)
1157 1195 {
1158 1196 struct trace_entry *entry = iter->ent;
1159 1197 struct trace_seq *s = &iter->seq;
... ... @@ -1178,7 +1216,8 @@
1178 1216  
1179 1217  
1180 1218 static enum print_line_t
1181   -trace_bprint_raw(struct trace_iterator *iter, int flags)
  1219 +trace_bprint_raw(struct trace_iterator *iter, int flags,
  1220 + struct trace_event *event)
1182 1221 {
1183 1222 struct bprint_entry *field;
1184 1223 struct trace_seq *s = &iter->seq;
1185 1224  
1186 1225  
... ... @@ -1197,16 +1236,19 @@
1197 1236 return TRACE_TYPE_PARTIAL_LINE;
1198 1237 }
1199 1238  
  1239 +static struct trace_event_functions trace_bprint_funcs = {
  1240 + .trace = trace_bprint_print,
  1241 + .raw = trace_bprint_raw,
  1242 +};
1200 1243  
1201 1244 static struct trace_event trace_bprint_event = {
1202 1245 .type = TRACE_BPRINT,
1203   - .trace = trace_bprint_print,
1204   - .raw = trace_bprint_raw,
  1246 + .funcs = &trace_bprint_funcs,
1205 1247 };
1206 1248  
1207 1249 /* TRACE_PRINT */
1208 1250 static enum print_line_t trace_print_print(struct trace_iterator *iter,
1209   - int flags)
  1251 + int flags, struct trace_event *event)
1210 1252 {
1211 1253 struct print_entry *field;
1212 1254 struct trace_seq *s = &iter->seq;
... ... @@ -1225,7 +1267,8 @@
1225 1267 return TRACE_TYPE_PARTIAL_LINE;
1226 1268 }
1227 1269  
1228   -static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags)
  1270 +static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags,
  1271 + struct trace_event *event)
1229 1272 {
1230 1273 struct print_entry *field;
1231 1274  
1232 1275  
... ... @@ -1240,10 +1283,14 @@
1240 1283 return TRACE_TYPE_PARTIAL_LINE;
1241 1284 }
1242 1285  
1243   -static struct trace_event trace_print_event = {
1244   - .type = TRACE_PRINT,
  1286 +static struct trace_event_functions trace_print_funcs = {
1245 1287 .trace = trace_print_print,
1246 1288 .raw = trace_print_raw,
  1289 +};
  1290 +
  1291 +static struct trace_event trace_print_event = {
  1292 + .type = TRACE_PRINT,
  1293 + .funcs = &trace_print_funcs,
1247 1294 };
1248 1295  
1249 1296  
kernel/trace/trace_output.h
... ... @@ -25,7 +25,7 @@
25 25 extern struct trace_event *ftrace_find_event(int type);
26 26  
27 27 extern enum print_line_t trace_nop_print(struct trace_iterator *iter,
28   - int flags);
  28 + int flags, struct trace_event *event);
29 29 extern int
30 30 trace_print_lat_fmt(struct trace_seq *s, struct trace_entry *entry);
31 31  
kernel/trace/trace_syscalls.c
... ... @@ -93,7 +93,8 @@
93 93 }
94 94  
95 95 enum print_line_t
96   -print_syscall_enter(struct trace_iterator *iter, int flags)
  96 +print_syscall_enter(struct trace_iterator *iter, int flags,
  97 + struct trace_event *event)
97 98 {
98 99 struct trace_seq *s = &iter->seq;
99 100 struct trace_entry *ent = iter->ent;
... ... @@ -145,7 +146,8 @@
145 146 }
146 147  
147 148 enum print_line_t
148   -print_syscall_exit(struct trace_iterator *iter, int flags)
  149 +print_syscall_exit(struct trace_iterator *iter, int flags,
  150 + struct trace_event *event)
149 151 {
150 152 struct trace_seq *s = &iter->seq;
151 153 struct trace_entry *ent = iter->ent;