aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_output.c
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-04-22 18:46:14 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-05-14 14:20:32 -0400
commita9a5776380208a3e48a92d0c763ee1a3b486fb73 (patch)
tree5ecd41c3b373e2156f5bf748ae777e022296a30c /kernel/trace/trace_output.c
parent0405ab80aa94afb13bf9ac4a6fc9f2923d4b9114 (diff)
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>
Diffstat (limited to 'kernel/trace/trace_output.c')
-rw-r--r--kernel/trace/trace_output.c137
1 files changed, 92 insertions, 45 deletions
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 2404c129a8c9..fc9d4dbb089e 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -726,6 +726,9 @@ int register_ftrace_event(struct trace_event *event)
726 if (WARN_ON(!event)) 726 if (WARN_ON(!event))
727 goto out; 727 goto out;
728 728
729 if (WARN_ON(!event->funcs))
730 goto out;
731
729 INIT_LIST_HEAD(&event->list); 732 INIT_LIST_HEAD(&event->list);
730 733
731 if (!event->type) { 734 if (!event->type) {
@@ -758,14 +761,14 @@ int register_ftrace_event(struct trace_event *event)
758 goto out; 761 goto out;
759 } 762 }
760 763
761 if (event->trace == NULL) 764 if (event->funcs->trace == NULL)
762 event->trace = trace_nop_print; 765 event->funcs->trace = trace_nop_print;
763 if (event->raw == NULL) 766 if (event->funcs->raw == NULL)
764 event->raw = trace_nop_print; 767 event->funcs->raw = trace_nop_print;
765 if (event->hex == NULL) 768 if (event->funcs->hex == NULL)
766 event->hex = trace_nop_print; 769 event->funcs->hex = trace_nop_print;
767 if (event->binary == NULL) 770 if (event->funcs->binary == NULL)
768 event->binary = trace_nop_print; 771 event->funcs->binary = trace_nop_print;
769 772
770 key = event->type & (EVENT_HASHSIZE - 1); 773 key = event->type & (EVENT_HASHSIZE - 1);
771 774
@@ -807,13 +810,15 @@ EXPORT_SYMBOL_GPL(unregister_ftrace_event);
807 * Standard events 810 * Standard events
808 */ 811 */
809 812
810enum print_line_t trace_nop_print(struct trace_iterator *iter, int flags) 813enum print_line_t trace_nop_print(struct trace_iterator *iter, int flags,
814 struct trace_event *event)
811{ 815{
812 return TRACE_TYPE_HANDLED; 816 return TRACE_TYPE_HANDLED;
813} 817}
814 818
815/* TRACE_FN */ 819/* TRACE_FN */
816static enum print_line_t trace_fn_trace(struct trace_iterator *iter, int flags) 820static enum print_line_t trace_fn_trace(struct trace_iterator *iter, int flags,
821 struct trace_event *event)
817{ 822{
818 struct ftrace_entry *field; 823 struct ftrace_entry *field;
819 struct trace_seq *s = &iter->seq; 824 struct trace_seq *s = &iter->seq;
@@ -840,7 +845,8 @@ static enum print_line_t trace_fn_trace(struct trace_iterator *iter, int flags)
840 return TRACE_TYPE_PARTIAL_LINE; 845 return TRACE_TYPE_PARTIAL_LINE;
841} 846}
842 847
843static enum print_line_t trace_fn_raw(struct trace_iterator *iter, int flags) 848static enum print_line_t trace_fn_raw(struct trace_iterator *iter, int flags,
849 struct trace_event *event)
844{ 850{
845 struct ftrace_entry *field; 851 struct ftrace_entry *field;
846 852
@@ -854,7 +860,8 @@ static enum print_line_t trace_fn_raw(struct trace_iterator *iter, int flags)
854 return TRACE_TYPE_HANDLED; 860 return TRACE_TYPE_HANDLED;
855} 861}
856 862
857static enum print_line_t trace_fn_hex(struct trace_iterator *iter, int flags) 863static enum print_line_t trace_fn_hex(struct trace_iterator *iter, int flags,
864 struct trace_event *event)
858{ 865{
859 struct ftrace_entry *field; 866 struct ftrace_entry *field;
860 struct trace_seq *s = &iter->seq; 867 struct trace_seq *s = &iter->seq;
@@ -867,7 +874,8 @@ static enum print_line_t trace_fn_hex(struct trace_iterator *iter, int flags)
867 return TRACE_TYPE_HANDLED; 874 return TRACE_TYPE_HANDLED;
868} 875}
869 876
870static enum print_line_t trace_fn_bin(struct trace_iterator *iter, int flags) 877static enum print_line_t trace_fn_bin(struct trace_iterator *iter, int flags,
878 struct trace_event *event)
871{ 879{
872 struct ftrace_entry *field; 880 struct ftrace_entry *field;
873 struct trace_seq *s = &iter->seq; 881 struct trace_seq *s = &iter->seq;
@@ -880,14 +888,18 @@ static enum print_line_t trace_fn_bin(struct trace_iterator *iter, int flags)
880 return TRACE_TYPE_HANDLED; 888 return TRACE_TYPE_HANDLED;
881} 889}
882 890
883static struct trace_event trace_fn_event = { 891static struct trace_event_functions trace_fn_funcs = {
884 .type = TRACE_FN,
885 .trace = trace_fn_trace, 892 .trace = trace_fn_trace,
886 .raw = trace_fn_raw, 893 .raw = trace_fn_raw,
887 .hex = trace_fn_hex, 894 .hex = trace_fn_hex,
888 .binary = trace_fn_bin, 895 .binary = trace_fn_bin,
889}; 896};
890 897
898static struct trace_event trace_fn_event = {
899 .type = TRACE_FN,
900 .funcs = &trace_fn_funcs,
901};
902
891/* TRACE_CTX an TRACE_WAKE */ 903/* TRACE_CTX an TRACE_WAKE */
892static enum print_line_t trace_ctxwake_print(struct trace_iterator *iter, 904static enum print_line_t trace_ctxwake_print(struct trace_iterator *iter,
893 char *delim) 905 char *delim)
@@ -916,13 +928,14 @@ static enum print_line_t trace_ctxwake_print(struct trace_iterator *iter,
916 return TRACE_TYPE_HANDLED; 928 return TRACE_TYPE_HANDLED;
917} 929}
918 930
919static enum print_line_t trace_ctx_print(struct trace_iterator *iter, int flags) 931static enum print_line_t trace_ctx_print(struct trace_iterator *iter, int flags,
932 struct trace_event *event)
920{ 933{
921 return trace_ctxwake_print(iter, "==>"); 934 return trace_ctxwake_print(iter, "==>");
922} 935}
923 936
924static enum print_line_t trace_wake_print(struct trace_iterator *iter, 937static enum print_line_t trace_wake_print(struct trace_iterator *iter,
925 int flags) 938 int flags, struct trace_event *event)
926{ 939{
927 return trace_ctxwake_print(iter, " +"); 940 return trace_ctxwake_print(iter, " +");
928} 941}
@@ -950,12 +963,14 @@ static int trace_ctxwake_raw(struct trace_iterator *iter, char S)
950 return TRACE_TYPE_HANDLED; 963 return TRACE_TYPE_HANDLED;
951} 964}
952 965
953static enum print_line_t trace_ctx_raw(struct trace_iterator *iter, int flags) 966static enum print_line_t trace_ctx_raw(struct trace_iterator *iter, int flags,
967 struct trace_event *event)
954{ 968{
955 return trace_ctxwake_raw(iter, 0); 969 return trace_ctxwake_raw(iter, 0);
956} 970}
957 971
958static enum print_line_t trace_wake_raw(struct trace_iterator *iter, int flags) 972static enum print_line_t trace_wake_raw(struct trace_iterator *iter, int flags,
973 struct trace_event *event)
959{ 974{
960 return trace_ctxwake_raw(iter, '+'); 975 return trace_ctxwake_raw(iter, '+');
961} 976}
@@ -984,18 +999,20 @@ static int trace_ctxwake_hex(struct trace_iterator *iter, char S)
984 return TRACE_TYPE_HANDLED; 999 return TRACE_TYPE_HANDLED;
985} 1000}
986 1001
987static enum print_line_t trace_ctx_hex(struct trace_iterator *iter, int flags) 1002static enum print_line_t trace_ctx_hex(struct trace_iterator *iter, int flags,
1003 struct trace_event *event)
988{ 1004{
989 return trace_ctxwake_hex(iter, 0); 1005 return trace_ctxwake_hex(iter, 0);
990} 1006}
991 1007
992static enum print_line_t trace_wake_hex(struct trace_iterator *iter, int flags) 1008static enum print_line_t trace_wake_hex(struct trace_iterator *iter, int flags,
1009 struct trace_event *event)
993{ 1010{
994 return trace_ctxwake_hex(iter, '+'); 1011 return trace_ctxwake_hex(iter, '+');
995} 1012}
996 1013
997static enum print_line_t trace_ctxwake_bin(struct trace_iterator *iter, 1014static enum print_line_t trace_ctxwake_bin(struct trace_iterator *iter,
998 int flags) 1015 int flags, struct trace_event *event)
999{ 1016{
1000 struct ctx_switch_entry *field; 1017 struct ctx_switch_entry *field;
1001 struct trace_seq *s = &iter->seq; 1018 struct trace_seq *s = &iter->seq;
@@ -1012,25 +1029,33 @@ static enum print_line_t trace_ctxwake_bin(struct trace_iterator *iter,
1012 return TRACE_TYPE_HANDLED; 1029 return TRACE_TYPE_HANDLED;
1013} 1030}
1014 1031
1015static struct trace_event trace_ctx_event = { 1032static struct trace_event_functions trace_ctx_funcs = {
1016 .type = TRACE_CTX,
1017 .trace = trace_ctx_print, 1033 .trace = trace_ctx_print,
1018 .raw = trace_ctx_raw, 1034 .raw = trace_ctx_raw,
1019 .hex = trace_ctx_hex, 1035 .hex = trace_ctx_hex,
1020 .binary = trace_ctxwake_bin, 1036 .binary = trace_ctxwake_bin,
1021}; 1037};
1022 1038
1023static struct trace_event trace_wake_event = { 1039static struct trace_event trace_ctx_event = {
1024 .type = TRACE_WAKE, 1040 .type = TRACE_CTX,
1041 .funcs = &trace_ctx_funcs,
1042};
1043
1044static struct trace_event_functions trace_wake_funcs = {
1025 .trace = trace_wake_print, 1045 .trace = trace_wake_print,
1026 .raw = trace_wake_raw, 1046 .raw = trace_wake_raw,
1027 .hex = trace_wake_hex, 1047 .hex = trace_wake_hex,
1028 .binary = trace_ctxwake_bin, 1048 .binary = trace_ctxwake_bin,
1029}; 1049};
1030 1050
1051static struct trace_event trace_wake_event = {
1052 .type = TRACE_WAKE,
1053 .funcs = &trace_wake_funcs,
1054};
1055
1031/* TRACE_SPECIAL */ 1056/* TRACE_SPECIAL */
1032static enum print_line_t trace_special_print(struct trace_iterator *iter, 1057static enum print_line_t trace_special_print(struct trace_iterator *iter,
1033 int flags) 1058 int flags, struct trace_event *event)
1034{ 1059{
1035 struct special_entry *field; 1060 struct special_entry *field;
1036 1061
@@ -1046,7 +1071,7 @@ static enum print_line_t trace_special_print(struct trace_iterator *iter,
1046} 1071}
1047 1072
1048static enum print_line_t trace_special_hex(struct trace_iterator *iter, 1073static enum print_line_t trace_special_hex(struct trace_iterator *iter,
1049 int flags) 1074 int flags, struct trace_event *event)
1050{ 1075{
1051 struct special_entry *field; 1076 struct special_entry *field;
1052 struct trace_seq *s = &iter->seq; 1077 struct trace_seq *s = &iter->seq;
@@ -1061,7 +1086,7 @@ static enum print_line_t trace_special_hex(struct trace_iterator *iter,
1061} 1086}
1062 1087
1063static enum print_line_t trace_special_bin(struct trace_iterator *iter, 1088static enum print_line_t trace_special_bin(struct trace_iterator *iter,
1064 int flags) 1089 int flags, struct trace_event *event)
1065{ 1090{
1066 struct special_entry *field; 1091 struct special_entry *field;
1067 struct trace_seq *s = &iter->seq; 1092 struct trace_seq *s = &iter->seq;
@@ -1075,18 +1100,22 @@ static enum print_line_t trace_special_bin(struct trace_iterator *iter,
1075 return TRACE_TYPE_HANDLED; 1100 return TRACE_TYPE_HANDLED;
1076} 1101}
1077 1102
1078static struct trace_event trace_special_event = { 1103static struct trace_event_functions trace_special_funcs = {
1079 .type = TRACE_SPECIAL,
1080 .trace = trace_special_print, 1104 .trace = trace_special_print,
1081 .raw = trace_special_print, 1105 .raw = trace_special_print,
1082 .hex = trace_special_hex, 1106 .hex = trace_special_hex,
1083 .binary = trace_special_bin, 1107 .binary = trace_special_bin,
1084}; 1108};
1085 1109
1110static struct trace_event trace_special_event = {
1111 .type = TRACE_SPECIAL,
1112 .funcs = &trace_special_funcs,
1113};
1114
1086/* TRACE_STACK */ 1115/* TRACE_STACK */
1087 1116
1088static enum print_line_t trace_stack_print(struct trace_iterator *iter, 1117static enum print_line_t trace_stack_print(struct trace_iterator *iter,
1089 int flags) 1118 int flags, struct trace_event *event)
1090{ 1119{
1091 struct stack_entry *field; 1120 struct stack_entry *field;
1092 struct trace_seq *s = &iter->seq; 1121 struct trace_seq *s = &iter->seq;
@@ -1114,17 +1143,21 @@ static enum print_line_t trace_stack_print(struct trace_iterator *iter,
1114 return TRACE_TYPE_PARTIAL_LINE; 1143 return TRACE_TYPE_PARTIAL_LINE;
1115} 1144}
1116 1145
1117static struct trace_event trace_stack_event = { 1146static struct trace_event_functions trace_stack_funcs = {
1118 .type = TRACE_STACK,
1119 .trace = trace_stack_print, 1147 .trace = trace_stack_print,
1120 .raw = trace_special_print, 1148 .raw = trace_special_print,
1121 .hex = trace_special_hex, 1149 .hex = trace_special_hex,
1122 .binary = trace_special_bin, 1150 .binary = trace_special_bin,
1123}; 1151};
1124 1152
1153static struct trace_event trace_stack_event = {
1154 .type = TRACE_STACK,
1155 .funcs = &trace_stack_funcs,
1156};
1157
1125/* TRACE_USER_STACK */ 1158/* TRACE_USER_STACK */
1126static enum print_line_t trace_user_stack_print(struct trace_iterator *iter, 1159static 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 struct userstack_entry *field; 1162 struct userstack_entry *field;
1130 struct trace_seq *s = &iter->seq; 1163 struct trace_seq *s = &iter->seq;
@@ -1143,17 +1176,22 @@ static enum print_line_t trace_user_stack_print(struct trace_iterator *iter,
1143 return TRACE_TYPE_PARTIAL_LINE; 1176 return TRACE_TYPE_PARTIAL_LINE;
1144} 1177}
1145 1178
1146static struct trace_event trace_user_stack_event = { 1179static struct trace_event_functions trace_user_stack_funcs = {
1147 .type = TRACE_USER_STACK,
1148 .trace = trace_user_stack_print, 1180 .trace = trace_user_stack_print,
1149 .raw = trace_special_print, 1181 .raw = trace_special_print,
1150 .hex = trace_special_hex, 1182 .hex = trace_special_hex,
1151 .binary = trace_special_bin, 1183 .binary = trace_special_bin,
1152}; 1184};
1153 1185
1186static struct trace_event trace_user_stack_event = {
1187 .type = TRACE_USER_STACK,
1188 .funcs = &trace_user_stack_funcs,
1189};
1190
1154/* TRACE_BPRINT */ 1191/* TRACE_BPRINT */
1155static enum print_line_t 1192static enum print_line_t
1156trace_bprint_print(struct trace_iterator *iter, int flags) 1193trace_bprint_print(struct trace_iterator *iter, int flags,
1194 struct trace_event *event)
1157{ 1195{
1158 struct trace_entry *entry = iter->ent; 1196 struct trace_entry *entry = iter->ent;
1159 struct trace_seq *s = &iter->seq; 1197 struct trace_seq *s = &iter->seq;
@@ -1178,7 +1216,8 @@ trace_bprint_print(struct trace_iterator *iter, int flags)
1178 1216
1179 1217
1180static enum print_line_t 1218static enum print_line_t
1181trace_bprint_raw(struct trace_iterator *iter, int flags) 1219trace_bprint_raw(struct trace_iterator *iter, int flags,
1220 struct trace_event *event)
1182{ 1221{
1183 struct bprint_entry *field; 1222 struct bprint_entry *field;
1184 struct trace_seq *s = &iter->seq; 1223 struct trace_seq *s = &iter->seq;
@@ -1197,16 +1236,19 @@ trace_bprint_raw(struct trace_iterator *iter, int flags)
1197 return TRACE_TYPE_PARTIAL_LINE; 1236 return TRACE_TYPE_PARTIAL_LINE;
1198} 1237}
1199 1238
1239static struct trace_event_functions trace_bprint_funcs = {
1240 .trace = trace_bprint_print,
1241 .raw = trace_bprint_raw,
1242};
1200 1243
1201static struct trace_event trace_bprint_event = { 1244static struct trace_event trace_bprint_event = {
1202 .type = TRACE_BPRINT, 1245 .type = TRACE_BPRINT,
1203 .trace = trace_bprint_print, 1246 .funcs = &trace_bprint_funcs,
1204 .raw = trace_bprint_raw,
1205}; 1247};
1206 1248
1207/* TRACE_PRINT */ 1249/* TRACE_PRINT */
1208static enum print_line_t trace_print_print(struct trace_iterator *iter, 1250static enum print_line_t trace_print_print(struct trace_iterator *iter,
1209 int flags) 1251 int flags, struct trace_event *event)
1210{ 1252{
1211 struct print_entry *field; 1253 struct print_entry *field;
1212 struct trace_seq *s = &iter->seq; 1254 struct trace_seq *s = &iter->seq;
@@ -1225,7 +1267,8 @@ static enum print_line_t trace_print_print(struct trace_iterator *iter,
1225 return TRACE_TYPE_PARTIAL_LINE; 1267 return TRACE_TYPE_PARTIAL_LINE;
1226} 1268}
1227 1269
1228static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags) 1270static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags,
1271 struct trace_event *event)
1229{ 1272{
1230 struct print_entry *field; 1273 struct print_entry *field;
1231 1274
@@ -1240,12 +1283,16 @@ static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags)
1240 return TRACE_TYPE_PARTIAL_LINE; 1283 return TRACE_TYPE_PARTIAL_LINE;
1241} 1284}
1242 1285
1243static struct trace_event trace_print_event = { 1286static struct trace_event_functions trace_print_funcs = {
1244 .type = TRACE_PRINT,
1245 .trace = trace_print_print, 1287 .trace = trace_print_print,
1246 .raw = trace_print_raw, 1288 .raw = trace_print_raw,
1247}; 1289};
1248 1290
1291static struct trace_event trace_print_event = {
1292 .type = TRACE_PRINT,
1293 .funcs = &trace_print_funcs,
1294};
1295
1249 1296
1250static struct trace_event *events[] __initdata = { 1297static struct trace_event *events[] __initdata = {
1251 &trace_fn_event, 1298 &trace_fn_event,