aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorTom Zanussi <tzanussi@gmail.com>2009-03-31 01:48:49 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-13 18:00:50 -0400
commite1112b4d96859367a93468027c9635e2ac04eb3f (patch)
tree5170980ea71ee4bb5d0196880b58dbc997211b65 /kernel
parent66de7792c02693b49671afe58c771fde3b092fc7 (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')
-rw-r--r--kernel/trace/kmemtrace.c6
-rw-r--r--kernel/trace/trace.c25
-rw-r--r--kernel/trace/trace.h20
-rw-r--r--kernel/trace/trace_branch.c3
-rw-r--r--kernel/trace/trace_event_types.h6
-rw-r--r--kernel/trace/trace_events.c7
-rw-r--r--kernel/trace/trace_events_filter.c4
-rw-r--r--kernel/trace/trace_events_stage_2.h7
-rw-r--r--kernel/trace/trace_export.c57
-rw-r--r--kernel/trace/trace_hw_branches.c2
-rw-r--r--kernel/trace/trace_power.c4
11 files changed, 127 insertions, 14 deletions
diff --git a/kernel/trace/kmemtrace.c b/kernel/trace/kmemtrace.c
index 7a0aa0e260db..9419ad10541b 100644
--- a/kernel/trace/kmemtrace.c
+++ b/kernel/trace/kmemtrace.c
@@ -42,6 +42,7 @@ static inline void kmemtrace_alloc(enum kmemtrace_type_id type_id,
42 gfp_t gfp_flags, 42 gfp_t gfp_flags,
43 int node) 43 int node)
44{ 44{
45 struct ftrace_event_call *call = &event_kmem_alloc;
45 struct trace_array *tr = kmemtrace_array; 46 struct trace_array *tr = kmemtrace_array;
46 struct kmemtrace_alloc_entry *entry; 47 struct kmemtrace_alloc_entry *entry;
47 struct ring_buffer_event *event; 48 struct ring_buffer_event *event;
@@ -62,6 +63,8 @@ static inline void kmemtrace_alloc(enum kmemtrace_type_id type_id,
62 entry->gfp_flags = gfp_flags; 63 entry->gfp_flags = gfp_flags;
63 entry->node = node; 64 entry->node = node;
64 65
66 filter_check_discard(call, entry, event);
67
65 ring_buffer_unlock_commit(tr->buffer, event); 68 ring_buffer_unlock_commit(tr->buffer, event);
66 69
67 trace_wake_up(); 70 trace_wake_up();
@@ -71,6 +74,7 @@ static inline void kmemtrace_free(enum kmemtrace_type_id type_id,
71 unsigned long call_site, 74 unsigned long call_site,
72 const void *ptr) 75 const void *ptr)
73{ 76{
77 struct ftrace_event_call *call = &event_kmem_free;
74 struct trace_array *tr = kmemtrace_array; 78 struct trace_array *tr = kmemtrace_array;
75 struct kmemtrace_free_entry *entry; 79 struct kmemtrace_free_entry *entry;
76 struct ring_buffer_event *event; 80 struct ring_buffer_event *event;
@@ -86,6 +90,8 @@ static inline void kmemtrace_free(enum kmemtrace_type_id type_id,
86 entry->call_site = call_site; 90 entry->call_site = call_site;
87 entry->ptr = ptr; 91 entry->ptr = ptr;
88 92
93 filter_check_discard(call, entry, event);
94
89 ring_buffer_unlock_commit(tr->buffer, event); 95 ring_buffer_unlock_commit(tr->buffer, event);
90 96
91 trace_wake_up(); 97 trace_wake_up();
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 4865459f609f..962e6179994a 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -898,6 +898,7 @@ trace_function(struct trace_array *tr,
898 unsigned long ip, unsigned long parent_ip, unsigned long flags, 898 unsigned long ip, unsigned long parent_ip, unsigned long flags,
899 int pc) 899 int pc)
900{ 900{
901 struct ftrace_event_call *call = &event_function;
901 struct ring_buffer_event *event; 902 struct ring_buffer_event *event;
902 struct ftrace_entry *entry; 903 struct ftrace_entry *entry;
903 904
@@ -912,6 +913,9 @@ trace_function(struct trace_array *tr,
912 entry = ring_buffer_event_data(event); 913 entry = ring_buffer_event_data(event);
913 entry->ip = ip; 914 entry->ip = ip;
914 entry->parent_ip = parent_ip; 915 entry->parent_ip = parent_ip;
916
917 filter_check_discard(call, entry, event);
918
915 ring_buffer_unlock_commit(tr->buffer, event); 919 ring_buffer_unlock_commit(tr->buffer, event);
916} 920}
917 921
@@ -921,6 +925,7 @@ static int __trace_graph_entry(struct trace_array *tr,
921 unsigned long flags, 925 unsigned long flags,
922 int pc) 926 int pc)
923{ 927{
928 struct ftrace_event_call *call = &event_funcgraph_entry;
924 struct ring_buffer_event *event; 929 struct ring_buffer_event *event;
925 struct ftrace_graph_ent_entry *entry; 930 struct ftrace_graph_ent_entry *entry;
926 931
@@ -933,6 +938,7 @@ static int __trace_graph_entry(struct trace_array *tr,
933 return 0; 938 return 0;
934 entry = ring_buffer_event_data(event); 939 entry = ring_buffer_event_data(event);
935 entry->graph_ent = *trace; 940 entry->graph_ent = *trace;
941 filter_check_discard(call, entry, event);
936 ring_buffer_unlock_commit(global_trace.buffer, event); 942 ring_buffer_unlock_commit(global_trace.buffer, event);
937 943
938 return 1; 944 return 1;
@@ -943,6 +949,7 @@ static void __trace_graph_return(struct trace_array *tr,
943 unsigned long flags, 949 unsigned long flags,
944 int pc) 950 int pc)
945{ 951{
952 struct ftrace_event_call *call = &event_funcgraph_exit;
946 struct ring_buffer_event *event; 953 struct ring_buffer_event *event;
947 struct ftrace_graph_ret_entry *entry; 954 struct ftrace_graph_ret_entry *entry;
948 955
@@ -955,6 +962,7 @@ static void __trace_graph_return(struct trace_array *tr,
955 return; 962 return;
956 entry = ring_buffer_event_data(event); 963 entry = ring_buffer_event_data(event);
957 entry->ret = *trace; 964 entry->ret = *trace;
965 filter_check_discard(call, entry, event);
958 ring_buffer_unlock_commit(global_trace.buffer, event); 966 ring_buffer_unlock_commit(global_trace.buffer, event);
959} 967}
960#endif 968#endif
@@ -973,6 +981,7 @@ static void __ftrace_trace_stack(struct trace_array *tr,
973 int skip, int pc) 981 int skip, int pc)
974{ 982{
975#ifdef CONFIG_STACKTRACE 983#ifdef CONFIG_STACKTRACE
984 struct ftrace_event_call *call = &event_kernel_stack;
976 struct ring_buffer_event *event; 985 struct ring_buffer_event *event;
977 struct stack_entry *entry; 986 struct stack_entry *entry;
978 struct stack_trace trace; 987 struct stack_trace trace;
@@ -990,6 +999,7 @@ static void __ftrace_trace_stack(struct trace_array *tr,
990 trace.entries = entry->caller; 999 trace.entries = entry->caller;
991 1000
992 save_stack_trace(&trace); 1001 save_stack_trace(&trace);
1002 filter_check_discard(call, entry, event);
993 ring_buffer_unlock_commit(tr->buffer, event); 1003 ring_buffer_unlock_commit(tr->buffer, event);
994#endif 1004#endif
995} 1005}
@@ -1015,6 +1025,7 @@ static void ftrace_trace_userstack(struct trace_array *tr,
1015 unsigned long flags, int pc) 1025 unsigned long flags, int pc)
1016{ 1026{
1017#ifdef CONFIG_STACKTRACE 1027#ifdef CONFIG_STACKTRACE
1028 struct ftrace_event_call *call = &event_user_stack;
1018 struct ring_buffer_event *event; 1029 struct ring_buffer_event *event;
1019 struct userstack_entry *entry; 1030 struct userstack_entry *entry;
1020 struct stack_trace trace; 1031 struct stack_trace trace;
@@ -1036,6 +1047,7 @@ static void ftrace_trace_userstack(struct trace_array *tr,
1036 trace.entries = entry->caller; 1047 trace.entries = entry->caller;
1037 1048
1038 save_stack_trace_user(&trace); 1049 save_stack_trace_user(&trace);
1050 filter_check_discard(call, entry, event);
1039 ring_buffer_unlock_commit(tr->buffer, event); 1051 ring_buffer_unlock_commit(tr->buffer, event);
1040#endif 1052#endif
1041} 1053}
@@ -1052,6 +1064,7 @@ ftrace_trace_special(void *__tr,
1052 unsigned long arg1, unsigned long arg2, unsigned long arg3, 1064 unsigned long arg1, unsigned long arg2, unsigned long arg3,
1053 int pc) 1065 int pc)
1054{ 1066{
1067 struct ftrace_event_call *call = &event_special;
1055 struct ring_buffer_event *event; 1068 struct ring_buffer_event *event;
1056 struct trace_array *tr = __tr; 1069 struct trace_array *tr = __tr;
1057 struct special_entry *entry; 1070 struct special_entry *entry;
@@ -1064,6 +1077,7 @@ ftrace_trace_special(void *__tr,
1064 entry->arg1 = arg1; 1077 entry->arg1 = arg1;
1065 entry->arg2 = arg2; 1078 entry->arg2 = arg2;
1066 entry->arg3 = arg3; 1079 entry->arg3 = arg3;
1080 filter_check_discard(call, entry, event);
1067 trace_buffer_unlock_commit(tr, event, 0, pc); 1081 trace_buffer_unlock_commit(tr, event, 0, pc);
1068} 1082}
1069 1083
@@ -1080,6 +1094,7 @@ tracing_sched_switch_trace(struct trace_array *tr,
1080 struct task_struct *next, 1094 struct task_struct *next,
1081 unsigned long flags, int pc) 1095 unsigned long flags, int pc)
1082{ 1096{
1097 struct ftrace_event_call *call = &event_context_switch;
1083 struct ring_buffer_event *event; 1098 struct ring_buffer_event *event;
1084 struct ctx_switch_entry *entry; 1099 struct ctx_switch_entry *entry;
1085 1100
@@ -1095,6 +1110,9 @@ tracing_sched_switch_trace(struct trace_array *tr,
1095 entry->next_prio = next->prio; 1110 entry->next_prio = next->prio;
1096 entry->next_state = next->state; 1111 entry->next_state = next->state;
1097 entry->next_cpu = task_cpu(next); 1112 entry->next_cpu = task_cpu(next);
1113
1114 filter_check_discard(call, entry, event);
1115
1098 trace_buffer_unlock_commit(tr, event, flags, pc); 1116 trace_buffer_unlock_commit(tr, event, flags, pc);
1099} 1117}
1100 1118
@@ -1104,6 +1122,7 @@ tracing_sched_wakeup_trace(struct trace_array *tr,
1104 struct task_struct *curr, 1122 struct task_struct *curr,
1105 unsigned long flags, int pc) 1123 unsigned long flags, int pc)
1106{ 1124{
1125 struct ftrace_event_call *call = &event_wakeup;
1107 struct ring_buffer_event *event; 1126 struct ring_buffer_event *event;
1108 struct ctx_switch_entry *entry; 1127 struct ctx_switch_entry *entry;
1109 1128
@@ -1120,6 +1139,8 @@ tracing_sched_wakeup_trace(struct trace_array *tr,
1120 entry->next_state = wakee->state; 1139 entry->next_state = wakee->state;
1121 entry->next_cpu = task_cpu(wakee); 1140 entry->next_cpu = task_cpu(wakee);
1122 1141
1142 filter_check_discard(call, entry, event);
1143
1123 ring_buffer_unlock_commit(tr->buffer, event); 1144 ring_buffer_unlock_commit(tr->buffer, event);
1124 ftrace_trace_stack(tr, flags, 6, pc); 1145 ftrace_trace_stack(tr, flags, 6, pc);
1125 ftrace_trace_userstack(tr, flags, pc); 1146 ftrace_trace_userstack(tr, flags, pc);
@@ -1221,6 +1242,7 @@ int trace_vbprintk(unsigned long ip, const char *fmt, va_list args)
1221 (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED; 1242 (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
1222 static u32 trace_buf[TRACE_BUF_SIZE]; 1243 static u32 trace_buf[TRACE_BUF_SIZE];
1223 1244
1245 struct ftrace_event_call *call = &event_bprint;
1224 struct ring_buffer_event *event; 1246 struct ring_buffer_event *event;
1225 struct trace_array *tr = &global_trace; 1247 struct trace_array *tr = &global_trace;
1226 struct trace_array_cpu *data; 1248 struct trace_array_cpu *data;
@@ -1260,6 +1282,7 @@ int trace_vbprintk(unsigned long ip, const char *fmt, va_list args)
1260 entry->fmt = fmt; 1282 entry->fmt = fmt;
1261 1283
1262 memcpy(entry->buf, trace_buf, sizeof(u32) * len); 1284 memcpy(entry->buf, trace_buf, sizeof(u32) * len);
1285 filter_check_discard(call, entry, event);
1263 ring_buffer_unlock_commit(tr->buffer, event); 1286 ring_buffer_unlock_commit(tr->buffer, event);
1264 1287
1265out_unlock: 1288out_unlock:
@@ -1279,6 +1302,7 @@ int trace_vprintk(unsigned long ip, const char *fmt, va_list args)
1279 static raw_spinlock_t trace_buf_lock = __RAW_SPIN_LOCK_UNLOCKED; 1302 static raw_spinlock_t trace_buf_lock = __RAW_SPIN_LOCK_UNLOCKED;
1280 static char trace_buf[TRACE_BUF_SIZE]; 1303 static char trace_buf[TRACE_BUF_SIZE];
1281 1304
1305 struct ftrace_event_call *call = &event_print;
1282 struct ring_buffer_event *event; 1306 struct ring_buffer_event *event;
1283 struct trace_array *tr = &global_trace; 1307 struct trace_array *tr = &global_trace;
1284 struct trace_array_cpu *data; 1308 struct trace_array_cpu *data;
@@ -1314,6 +1338,7 @@ int trace_vprintk(unsigned long ip, const char *fmt, va_list args)
1314 1338
1315 memcpy(&entry->buf, trace_buf, len); 1339 memcpy(&entry->buf, trace_buf, len);
1316 entry->buf[len] = 0; 1340 entry->buf[len] = 0;
1341 filter_check_discard(call, entry, event);
1317 ring_buffer_unlock_commit(tr->buffer, event); 1342 ring_buffer_unlock_commit(tr->buffer, event);
1318 1343
1319 out_unlock: 1344 out_unlock:
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 34b94c3f40ad..e7737281953f 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -866,6 +866,21 @@ extern void filter_free_subsystem_preds(struct event_subsystem *system);
866extern int filter_add_subsystem_pred(struct event_subsystem *system, 866extern int filter_add_subsystem_pred(struct event_subsystem *system,
867 struct filter_pred *pred); 867 struct filter_pred *pred);
868 868
869static inline void
870filter_check_discard(struct ftrace_event_call *call, void *rec,
871 struct ring_buffer_event *event)
872{
873 if (unlikely(call->preds) && !filter_match_preds(call, rec))
874 ring_buffer_event_discard(event);
875}
876
877#define __common_field(type, item) \
878 ret = trace_define_field(event_call, #type, "common_" #item, \
879 offsetof(typeof(field.ent), item), \
880 sizeof(field.ent.item)); \
881 if (ret) \
882 return ret;
883
869void event_trace_printk(unsigned long ip, const char *fmt, ...); 884void event_trace_printk(unsigned long ip, const char *fmt, ...);
870extern struct ftrace_event_call __start_ftrace_events[]; 885extern struct ftrace_event_call __start_ftrace_events[];
871extern struct ftrace_event_call __stop_ftrace_events[]; 886extern struct ftrace_event_call __stop_ftrace_events[];
@@ -897,4 +912,9 @@ do { \
897 __trace_printk(ip, fmt, ##args); \ 912 __trace_printk(ip, fmt, ##args); \
898} while (0) 913} while (0)
899 914
915#undef TRACE_EVENT_FORMAT
916#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
917 extern struct ftrace_event_call event_##call;
918#include "trace_event_types.h"
919
900#endif /* _LINUX_KERNEL_TRACE_H */ 920#endif /* _LINUX_KERNEL_TRACE_H */
diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c
index e6e32912ffb8..c95c25d838ef 100644
--- a/kernel/trace/trace_branch.c
+++ b/kernel/trace/trace_branch.c
@@ -30,6 +30,7 @@ static struct trace_array *branch_tracer;
30static void 30static void
31probe_likely_condition(struct ftrace_branch_data *f, int val, int expect) 31probe_likely_condition(struct ftrace_branch_data *f, int val, int expect)
32{ 32{
33 struct ftrace_event_call *call = &event_branch;
33 struct trace_array *tr = branch_tracer; 34 struct trace_array *tr = branch_tracer;
34 struct ring_buffer_event *event; 35 struct ring_buffer_event *event;
35 struct trace_branch *entry; 36 struct trace_branch *entry;
@@ -73,6 +74,8 @@ probe_likely_condition(struct ftrace_branch_data *f, int val, int expect)
73 entry->line = f->line; 74 entry->line = f->line;
74 entry->correct = val == expect; 75 entry->correct = val == expect;
75 76
77 filter_check_discard(call, entry, event);
78
76 ring_buffer_unlock_commit(tr->buffer, event); 79 ring_buffer_unlock_commit(tr->buffer, event);
77 80
78 out: 81 out:
diff --git a/kernel/trace/trace_event_types.h b/kernel/trace/trace_event_types.h
index fd78bee71dd7..95b147aac229 100644
--- a/kernel/trace/trace_event_types.h
+++ b/kernel/trace/trace_event_types.h
@@ -122,8 +122,10 @@ TRACE_EVENT_FORMAT(print, TRACE_PRINT, print_entry, ignore,
122TRACE_EVENT_FORMAT(branch, TRACE_BRANCH, trace_branch, ignore, 122TRACE_EVENT_FORMAT(branch, TRACE_BRANCH, trace_branch, ignore,
123 TRACE_STRUCT( 123 TRACE_STRUCT(
124 TRACE_FIELD(unsigned int, line, line) 124 TRACE_FIELD(unsigned int, line, line)
125 TRACE_FIELD_SPECIAL(char func[TRACE_FUNC_SIZE+1], func, func) 125 TRACE_FIELD_SPECIAL(char func[TRACE_FUNC_SIZE+1], func,
126 TRACE_FIELD_SPECIAL(char file[TRACE_FUNC_SIZE+1], file, file) 126 TRACE_FUNC_SIZE+1, func)
127 TRACE_FIELD_SPECIAL(char file[TRACE_FUNC_SIZE+1], file,
128 TRACE_FUNC_SIZE+1, file)
127 TRACE_FIELD(char, correct, correct) 129 TRACE_FIELD(char, correct, correct)
128 ), 130 ),
129 TP_RAW_FMT("%u:%s:%s (%u)") 131 TP_RAW_FMT("%u:%s:%s (%u)")
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 64ec4d278ffb..be9299a53e2a 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -680,6 +680,7 @@ static struct dentry *
680event_subsystem_dir(const char *name, struct dentry *d_events) 680event_subsystem_dir(const char *name, struct dentry *d_events)
681{ 681{
682 struct event_subsystem *system; 682 struct event_subsystem *system;
683 struct dentry *entry;
683 684
684 /* First see if we did not already create this dir */ 685 /* First see if we did not already create this dir */
685 list_for_each_entry(system, &event_subsystems, list) { 686 list_for_each_entry(system, &event_subsystems, list) {
@@ -708,6 +709,12 @@ event_subsystem_dir(const char *name, struct dentry *d_events)
708 709
709 system->preds = NULL; 710 system->preds = NULL;
710 711
712 entry = debugfs_create_file("filter", 0644, system->entry, system,
713 &ftrace_subsystem_filter_fops);
714 if (!entry)
715 pr_warning("Could not create debugfs "
716 "'%s/filter' entry\n", name);
717
711 return system->entry; 718 return system->entry;
712} 719}
713 720
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 026be412f356..470ad9487ecc 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -185,7 +185,7 @@ void filter_free_subsystem_preds(struct event_subsystem *system)
185 } 185 }
186 186
187 events_for_each(call) { 187 events_for_each(call) {
188 if (!call->name || !call->regfunc) 188 if (!call->define_fields)
189 continue; 189 continue;
190 190
191 if (!strcmp(call->system, system->name)) 191 if (!strcmp(call->system, system->name))
@@ -324,7 +324,7 @@ int filter_add_subsystem_pred(struct event_subsystem *system,
324 events_for_each(call) { 324 events_for_each(call) {
325 int err; 325 int err;
326 326
327 if (!call->name || !call->regfunc) 327 if (!call->define_fields)
328 continue; 328 continue;
329 329
330 if (strcmp(call->system, system->name)) 330 if (strcmp(call->system, system->name))
diff --git a/kernel/trace/trace_events_stage_2.h b/kernel/trace/trace_events_stage_2.h
index 30743f7d4110..1c94b87c7180 100644
--- a/kernel/trace/trace_events_stage_2.h
+++ b/kernel/trace/trace_events_stage_2.h
@@ -146,13 +146,6 @@ ftrace_format_##call(struct trace_seq *s) \
146 if (ret) \ 146 if (ret) \
147 return ret; 147 return ret;
148 148
149#define __common_field(type, item) \
150 ret = trace_define_field(event_call, #type, "common_" #item, \
151 offsetof(typeof(field.ent), item), \
152 sizeof(field.ent.item)); \
153 if (ret) \
154 return ret;
155
156#undef TRACE_EVENT 149#undef TRACE_EVENT
157#define TRACE_EVENT(call, proto, args, tstruct, func, print) \ 150#define TRACE_EVENT(call, proto, args, tstruct, func, print) \
158int \ 151int \
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) \
93int ftrace_define_fields_##call(void); \
94static int ftrace_raw_init_event_##call(void); \
93 \ 95 \
94static struct ftrace_event_call __used \ 96struct 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}; \
106static 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) \
135int \
136ftrace_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"
diff --git a/kernel/trace/trace_hw_branches.c b/kernel/trace/trace_hw_branches.c
index 7bfdf4c2347f..e6b275b22ac0 100644
--- a/kernel/trace/trace_hw_branches.c
+++ b/kernel/trace/trace_hw_branches.c
@@ -168,6 +168,7 @@ static enum print_line_t bts_trace_print_line(struct trace_iterator *iter)
168 168
169void trace_hw_branch(u64 from, u64 to) 169void trace_hw_branch(u64 from, u64 to)
170{ 170{
171 struct ftrace_event_call *call = &event_hw_branch;
171 struct trace_array *tr = hw_branch_trace; 172 struct trace_array *tr = hw_branch_trace;
172 struct ring_buffer_event *event; 173 struct ring_buffer_event *event;
173 struct hw_branch_entry *entry; 174 struct hw_branch_entry *entry;
@@ -194,6 +195,7 @@ void trace_hw_branch(u64 from, u64 to)
194 entry->ent.type = TRACE_HW_BRANCHES; 195 entry->ent.type = TRACE_HW_BRANCHES;
195 entry->from = from; 196 entry->from = from;
196 entry->to = to; 197 entry->to = to;
198 filter_check_discard(call, entry, event);
197 trace_buffer_unlock_commit(tr, event, 0, 0); 199 trace_buffer_unlock_commit(tr, event, 0, 0);
198 200
199 out: 201 out:
diff --git a/kernel/trace/trace_power.c b/kernel/trace/trace_power.c
index bae791ebcc51..8ce7d7d62c07 100644
--- a/kernel/trace/trace_power.c
+++ b/kernel/trace/trace_power.c
@@ -36,6 +36,7 @@ static void probe_power_start(struct power_trace *it, unsigned int type,
36 36
37static void probe_power_end(struct power_trace *it) 37static void probe_power_end(struct power_trace *it)
38{ 38{
39 struct ftrace_event_call *call = &event_power;
39 struct ring_buffer_event *event; 40 struct ring_buffer_event *event;
40 struct trace_power *entry; 41 struct trace_power *entry;
41 struct trace_array_cpu *data; 42 struct trace_array_cpu *data;
@@ -54,6 +55,7 @@ static void probe_power_end(struct power_trace *it)
54 goto out; 55 goto out;
55 entry = ring_buffer_event_data(event); 56 entry = ring_buffer_event_data(event);
56 entry->state_data = *it; 57 entry->state_data = *it;
58 filter_check_discard(call, entry, event);
57 trace_buffer_unlock_commit(tr, event, 0, 0); 59 trace_buffer_unlock_commit(tr, event, 0, 0);
58 out: 60 out:
59 preempt_enable(); 61 preempt_enable();
@@ -62,6 +64,7 @@ static void probe_power_end(struct power_trace *it)
62static void probe_power_mark(struct power_trace *it, unsigned int type, 64static void probe_power_mark(struct power_trace *it, unsigned int type,
63 unsigned int level) 65 unsigned int level)
64{ 66{
67 struct ftrace_event_call *call = &event_power;
65 struct ring_buffer_event *event; 68 struct ring_buffer_event *event;
66 struct trace_power *entry; 69 struct trace_power *entry;
67 struct trace_array_cpu *data; 70 struct trace_array_cpu *data;
@@ -84,6 +87,7 @@ static void probe_power_mark(struct power_trace *it, unsigned int type,
84 goto out; 87 goto out;
85 entry = ring_buffer_event_data(event); 88 entry = ring_buffer_event_data(event);
86 entry->state_data = *it; 89 entry->state_data = *it;
90 filter_check_discard(call, entry, event);
87 trace_buffer_unlock_commit(tr, event, 0, 0); 91 trace_buffer_unlock_commit(tr, event, 0, 0);
88 out: 92 out:
89 preempt_enable(); 93 preempt_enable();