aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-02-15 09:51:53 -0500
committerSteven Rostedt <rostedt@goodmis.org>2012-02-21 11:08:29 -0500
commit02aa3162edaa166a01d193f80ccde890be8b55da (patch)
tree50f111c12472e5573b966d7fb076ba4b22c86669 /kernel
parentced39002f5ea736b716ae233fb68b26d59783912 (diff)
ftrace: Allow to specify filter field type for ftrace events
Adding FILTER_TRACE_FN event field type for function tracepoint event, so it can be properly recognized within filtering code. Currently all fields of ftrace subsystem events share the common field type FILTER_OTHER. Since the function trace fields need special care within the filtering code we need to recognize it properly, hence adding the FILTER_TRACE_FN event type. Adding filter parameter to the FTRACE_ENTRY macro, to specify the filter field type for the event. Link: http://lkml.kernel.org/r/1329317514-8131-7-git-send-email-jolsa@redhat.com Signed-off-by: Jiri Olsa <jolsa@redhat.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/trace.h23
-rw-r--r--kernel/trace/trace_entries.h48
-rw-r--r--kernel/trace/trace_events_filter.c7
-rw-r--r--kernel/trace/trace_export.c51
4 files changed, 82 insertions, 47 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 76a1c5094bbf..29f93cd434a5 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -56,21 +56,23 @@ enum trace_type {
56#define F_STRUCT(args...) args 56#define F_STRUCT(args...) args
57 57
58#undef FTRACE_ENTRY 58#undef FTRACE_ENTRY
59#define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \ 59#define FTRACE_ENTRY(name, struct_name, id, tstruct, print, filter) \
60 struct struct_name { \ 60 struct struct_name { \
61 struct trace_entry ent; \ 61 struct trace_entry ent; \
62 tstruct \ 62 tstruct \
63 } 63 }
64 64
65#undef TP_ARGS 65#undef TP_ARGS
66#define TP_ARGS(args...) args 66#define TP_ARGS(args...) args
67 67
68#undef FTRACE_ENTRY_DUP 68#undef FTRACE_ENTRY_DUP
69#define FTRACE_ENTRY_DUP(name, name_struct, id, tstruct, printk) 69#define FTRACE_ENTRY_DUP(name, name_struct, id, tstruct, printk, filter)
70 70
71#undef FTRACE_ENTRY_REG 71#undef FTRACE_ENTRY_REG
72#define FTRACE_ENTRY_REG(name, struct_name, id, tstruct, print, regfn) \ 72#define FTRACE_ENTRY_REG(name, struct_name, id, tstruct, print, \
73 FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) 73 filter, regfn) \
74 FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \
75 filter)
74 76
75#include "trace_entries.h" 77#include "trace_entries.h"
76 78
@@ -826,12 +828,13 @@ extern const char *__start___trace_bprintk_fmt[];
826extern const char *__stop___trace_bprintk_fmt[]; 828extern const char *__stop___trace_bprintk_fmt[];
827 829
828#undef FTRACE_ENTRY 830#undef FTRACE_ENTRY
829#define FTRACE_ENTRY(call, struct_name, id, tstruct, print) \ 831#define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \
830 extern struct ftrace_event_call \ 832 extern struct ftrace_event_call \
831 __attribute__((__aligned__(4))) event_##call; 833 __attribute__((__aligned__(4))) event_##call;
832#undef FTRACE_ENTRY_DUP 834#undef FTRACE_ENTRY_DUP
833#define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print) \ 835#define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print, filter) \
834 FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print)) 836 FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print), \
837 filter)
835#include "trace_entries.h" 838#include "trace_entries.h"
836 839
837#ifdef CONFIG_PERF_EVENTS 840#ifdef CONFIG_PERF_EVENTS
diff --git a/kernel/trace/trace_entries.h b/kernel/trace/trace_entries.h
index 47db7eda0531..d91eb0541b3a 100644
--- a/kernel/trace/trace_entries.h
+++ b/kernel/trace/trace_entries.h
@@ -66,6 +66,8 @@ FTRACE_ENTRY_REG(function, ftrace_entry,
66 66
67 F_printk(" %lx <-- %lx", __entry->ip, __entry->parent_ip), 67 F_printk(" %lx <-- %lx", __entry->ip, __entry->parent_ip),
68 68
69 FILTER_TRACE_FN,
70
69 perf_ftrace_event_register 71 perf_ftrace_event_register
70); 72);
71 73
@@ -80,7 +82,9 @@ FTRACE_ENTRY(funcgraph_entry, ftrace_graph_ent_entry,
80 __field_desc( int, graph_ent, depth ) 82 __field_desc( int, graph_ent, depth )
81 ), 83 ),
82 84
83 F_printk("--> %lx (%d)", __entry->func, __entry->depth) 85 F_printk("--> %lx (%d)", __entry->func, __entry->depth),
86
87 FILTER_OTHER
84); 88);
85 89
86/* Function return entry */ 90/* Function return entry */
@@ -100,7 +104,9 @@ FTRACE_ENTRY(funcgraph_exit, ftrace_graph_ret_entry,
100 F_printk("<-- %lx (%d) (start: %llx end: %llx) over: %d", 104 F_printk("<-- %lx (%d) (start: %llx end: %llx) over: %d",
101 __entry->func, __entry->depth, 105 __entry->func, __entry->depth,
102 __entry->calltime, __entry->rettime, 106 __entry->calltime, __entry->rettime,
103 __entry->depth) 107 __entry->depth),
108
109 FILTER_OTHER
104); 110);
105 111
106/* 112/*
@@ -129,8 +135,9 @@ FTRACE_ENTRY(context_switch, ctx_switch_entry,
129 F_printk("%u:%u:%u ==> %u:%u:%u [%03u]", 135 F_printk("%u:%u:%u ==> %u:%u:%u [%03u]",
130 __entry->prev_pid, __entry->prev_prio, __entry->prev_state, 136 __entry->prev_pid, __entry->prev_prio, __entry->prev_state,
131 __entry->next_pid, __entry->next_prio, __entry->next_state, 137 __entry->next_pid, __entry->next_prio, __entry->next_state,
132 __entry->next_cpu 138 __entry->next_cpu),
133 ) 139
140 FILTER_OTHER
134); 141);
135 142
136/* 143/*
@@ -148,8 +155,9 @@ FTRACE_ENTRY_DUP(wakeup, ctx_switch_entry,
148 F_printk("%u:%u:%u ==+ %u:%u:%u [%03u]", 155 F_printk("%u:%u:%u ==+ %u:%u:%u [%03u]",
149 __entry->prev_pid, __entry->prev_prio, __entry->prev_state, 156 __entry->prev_pid, __entry->prev_prio, __entry->prev_state,
150 __entry->next_pid, __entry->next_prio, __entry->next_state, 157 __entry->next_pid, __entry->next_prio, __entry->next_state,
151 __entry->next_cpu 158 __entry->next_cpu),
152 ) 159
160 FILTER_OTHER
153); 161);
154 162
155/* 163/*
@@ -171,7 +179,9 @@ FTRACE_ENTRY(kernel_stack, stack_entry,
171 "\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n", 179 "\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n",
172 __entry->caller[0], __entry->caller[1], __entry->caller[2], 180 __entry->caller[0], __entry->caller[1], __entry->caller[2],
173 __entry->caller[3], __entry->caller[4], __entry->caller[5], 181 __entry->caller[3], __entry->caller[4], __entry->caller[5],
174 __entry->caller[6], __entry->caller[7]) 182 __entry->caller[6], __entry->caller[7]),
183
184 FILTER_OTHER
175); 185);
176 186
177FTRACE_ENTRY(user_stack, userstack_entry, 187FTRACE_ENTRY(user_stack, userstack_entry,
@@ -187,7 +197,9 @@ FTRACE_ENTRY(user_stack, userstack_entry,
187 "\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n", 197 "\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n\t=> (%08lx)\n",
188 __entry->caller[0], __entry->caller[1], __entry->caller[2], 198 __entry->caller[0], __entry->caller[1], __entry->caller[2],
189 __entry->caller[3], __entry->caller[4], __entry->caller[5], 199 __entry->caller[3], __entry->caller[4], __entry->caller[5],
190 __entry->caller[6], __entry->caller[7]) 200 __entry->caller[6], __entry->caller[7]),
201
202 FILTER_OTHER
191); 203);
192 204
193/* 205/*
@@ -204,7 +216,9 @@ FTRACE_ENTRY(bprint, bprint_entry,
204 ), 216 ),
205 217
206 F_printk("%08lx fmt:%p", 218 F_printk("%08lx fmt:%p",
207 __entry->ip, __entry->fmt) 219 __entry->ip, __entry->fmt),
220
221 FILTER_OTHER
208); 222);
209 223
210FTRACE_ENTRY(print, print_entry, 224FTRACE_ENTRY(print, print_entry,
@@ -217,7 +231,9 @@ FTRACE_ENTRY(print, print_entry,
217 ), 231 ),
218 232
219 F_printk("%08lx %s", 233 F_printk("%08lx %s",
220 __entry->ip, __entry->buf) 234 __entry->ip, __entry->buf),
235
236 FILTER_OTHER
221); 237);
222 238
223FTRACE_ENTRY(mmiotrace_rw, trace_mmiotrace_rw, 239FTRACE_ENTRY(mmiotrace_rw, trace_mmiotrace_rw,
@@ -236,7 +252,9 @@ FTRACE_ENTRY(mmiotrace_rw, trace_mmiotrace_rw,
236 252
237 F_printk("%lx %lx %lx %d %x %x", 253 F_printk("%lx %lx %lx %d %x %x",
238 (unsigned long)__entry->phys, __entry->value, __entry->pc, 254 (unsigned long)__entry->phys, __entry->value, __entry->pc,
239 __entry->map_id, __entry->opcode, __entry->width) 255 __entry->map_id, __entry->opcode, __entry->width),
256
257 FILTER_OTHER
240); 258);
241 259
242FTRACE_ENTRY(mmiotrace_map, trace_mmiotrace_map, 260FTRACE_ENTRY(mmiotrace_map, trace_mmiotrace_map,
@@ -254,7 +272,9 @@ FTRACE_ENTRY(mmiotrace_map, trace_mmiotrace_map,
254 272
255 F_printk("%lx %lx %lx %d %x", 273 F_printk("%lx %lx %lx %d %x",
256 (unsigned long)__entry->phys, __entry->virt, __entry->len, 274 (unsigned long)__entry->phys, __entry->virt, __entry->len,
257 __entry->map_id, __entry->opcode) 275 __entry->map_id, __entry->opcode),
276
277 FILTER_OTHER
258); 278);
259 279
260 280
@@ -274,6 +294,8 @@ FTRACE_ENTRY(branch, trace_branch,
274 294
275 F_printk("%u:%s:%s (%u)", 295 F_printk("%u:%s:%s (%u)",
276 __entry->line, 296 __entry->line,
277 __entry->func, __entry->file, __entry->correct) 297 __entry->func, __entry->file, __entry->correct),
298
299 FILTER_OTHER
278); 300);
279 301
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 76afaee99dbc..3da3d0ec3584 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -899,6 +899,11 @@ int filter_assign_type(const char *type)
899 return FILTER_OTHER; 899 return FILTER_OTHER;
900} 900}
901 901
902static bool is_function_field(struct ftrace_event_field *field)
903{
904 return field->filter_type == FILTER_TRACE_FN;
905}
906
902static bool is_string_field(struct ftrace_event_field *field) 907static bool is_string_field(struct ftrace_event_field *field)
903{ 908{
904 return field->filter_type == FILTER_DYN_STRING || 909 return field->filter_type == FILTER_DYN_STRING ||
@@ -986,7 +991,7 @@ static int init_pred(struct filter_parse_state *ps,
986 fn = filter_pred_strloc; 991 fn = filter_pred_strloc;
987 else 992 else
988 fn = filter_pred_pchar; 993 fn = filter_pred_pchar;
989 } else { 994 } else if (!is_function_field(field)) {
990 if (field->is_signed) 995 if (field->is_signed)
991 ret = strict_strtoll(pred->regex.pattern, 0, &val); 996 ret = strict_strtoll(pred->regex.pattern, 0, &val);
992 else 997 else
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c
index a3dbee6d04cd..7b46c9bd22ae 100644
--- a/kernel/trace/trace_export.c
+++ b/kernel/trace/trace_export.c
@@ -23,8 +23,10 @@
23 * function and thus become accesible via perf. 23 * function and thus become accesible via perf.
24 */ 24 */
25#undef FTRACE_ENTRY_REG 25#undef FTRACE_ENTRY_REG
26#define FTRACE_ENTRY_REG(name, struct_name, id, tstruct, print, regfn) \ 26#define FTRACE_ENTRY_REG(name, struct_name, id, tstruct, print, \
27 FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) 27 filter, regfn) \
28 FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \
29 filter)
28 30
29/* not needed for this file */ 31/* not needed for this file */
30#undef __field_struct 32#undef __field_struct
@@ -52,21 +54,22 @@
52#define F_printk(fmt, args...) fmt, args 54#define F_printk(fmt, args...) fmt, args
53 55
54#undef FTRACE_ENTRY 56#undef FTRACE_ENTRY
55#define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \ 57#define FTRACE_ENTRY(name, struct_name, id, tstruct, print, filter) \
56struct ____ftrace_##name { \ 58struct ____ftrace_##name { \
57 tstruct \ 59 tstruct \
58}; \ 60}; \
59static void __always_unused ____ftrace_check_##name(void) \ 61static void __always_unused ____ftrace_check_##name(void) \
60{ \ 62{ \
61 struct ____ftrace_##name *__entry = NULL; \ 63 struct ____ftrace_##name *__entry = NULL; \
62 \ 64 \
63 /* force compile-time check on F_printk() */ \ 65 /* force compile-time check on F_printk() */ \
64 printk(print); \ 66 printk(print); \
65} 67}
66 68
67#undef FTRACE_ENTRY_DUP 69#undef FTRACE_ENTRY_DUP
68#define FTRACE_ENTRY_DUP(name, struct_name, id, tstruct, print) \ 70#define FTRACE_ENTRY_DUP(name, struct_name, id, tstruct, print, filter) \
69 FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) 71 FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \
72 filter)
70 73
71#include "trace_entries.h" 74#include "trace_entries.h"
72 75
@@ -75,7 +78,7 @@ static void __always_unused ____ftrace_check_##name(void) \
75 ret = trace_define_field(event_call, #type, #item, \ 78 ret = trace_define_field(event_call, #type, #item, \
76 offsetof(typeof(field), item), \ 79 offsetof(typeof(field), item), \
77 sizeof(field.item), \ 80 sizeof(field.item), \
78 is_signed_type(type), FILTER_OTHER); \ 81 is_signed_type(type), filter_type); \
79 if (ret) \ 82 if (ret) \
80 return ret; 83 return ret;
81 84
@@ -85,7 +88,7 @@ static void __always_unused ____ftrace_check_##name(void) \
85 offsetof(typeof(field), \ 88 offsetof(typeof(field), \
86 container.item), \ 89 container.item), \
87 sizeof(field.container.item), \ 90 sizeof(field.container.item), \
88 is_signed_type(type), FILTER_OTHER); \ 91 is_signed_type(type), filter_type); \
89 if (ret) \ 92 if (ret) \
90 return ret; 93 return ret;
91 94
@@ -99,7 +102,7 @@ static void __always_unused ____ftrace_check_##name(void) \
99 ret = trace_define_field(event_call, event_storage, #item, \ 102 ret = trace_define_field(event_call, event_storage, #item, \
100 offsetof(typeof(field), item), \ 103 offsetof(typeof(field), item), \
101 sizeof(field.item), \ 104 sizeof(field.item), \
102 is_signed_type(type), FILTER_OTHER); \ 105 is_signed_type(type), filter_type); \
103 mutex_unlock(&event_storage_mutex); \ 106 mutex_unlock(&event_storage_mutex); \
104 if (ret) \ 107 if (ret) \
105 return ret; \ 108 return ret; \
@@ -112,7 +115,7 @@ static void __always_unused ____ftrace_check_##name(void) \
112 offsetof(typeof(field), \ 115 offsetof(typeof(field), \
113 container.item), \ 116 container.item), \
114 sizeof(field.container.item), \ 117 sizeof(field.container.item), \
115 is_signed_type(type), FILTER_OTHER); \ 118 is_signed_type(type), filter_type); \
116 if (ret) \ 119 if (ret) \
117 return ret; 120 return ret;
118 121
@@ -120,17 +123,18 @@ static void __always_unused ____ftrace_check_##name(void) \
120#define __dynamic_array(type, item) \ 123#define __dynamic_array(type, item) \
121 ret = trace_define_field(event_call, #type, #item, \ 124 ret = trace_define_field(event_call, #type, #item, \
122 offsetof(typeof(field), item), \ 125 offsetof(typeof(field), item), \
123 0, is_signed_type(type), FILTER_OTHER);\ 126 0, is_signed_type(type), filter_type);\
124 if (ret) \ 127 if (ret) \
125 return ret; 128 return ret;
126 129
127#undef FTRACE_ENTRY 130#undef FTRACE_ENTRY
128#define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \ 131#define FTRACE_ENTRY(name, struct_name, id, tstruct, print, filter) \
129int \ 132int \
130ftrace_define_fields_##name(struct ftrace_event_call *event_call) \ 133ftrace_define_fields_##name(struct ftrace_event_call *event_call) \
131{ \ 134{ \
132 struct struct_name field; \ 135 struct struct_name field; \
133 int ret; \ 136 int ret; \
137 int filter_type = filter; \
134 \ 138 \
135 tstruct; \ 139 tstruct; \
136 \ 140 \
@@ -161,7 +165,8 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \
161#define F_printk(fmt, args...) #fmt ", " __stringify(args) 165#define F_printk(fmt, args...) #fmt ", " __stringify(args)
162 166
163#undef FTRACE_ENTRY_REG 167#undef FTRACE_ENTRY_REG
164#define FTRACE_ENTRY_REG(call, struct_name, etype, tstruct, print, regfn)\ 168#define FTRACE_ENTRY_REG(call, struct_name, etype, tstruct, print, filter,\
169 regfn) \
165 \ 170 \
166struct ftrace_event_class event_class_ftrace_##call = { \ 171struct ftrace_event_class event_class_ftrace_##call = { \
167 .system = __stringify(TRACE_SYSTEM), \ 172 .system = __stringify(TRACE_SYSTEM), \
@@ -180,9 +185,9 @@ struct ftrace_event_call __used \
180__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call; 185__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call;
181 186
182#undef FTRACE_ENTRY 187#undef FTRACE_ENTRY
183#define FTRACE_ENTRY(call, struct_name, etype, tstruct, print) \ 188#define FTRACE_ENTRY(call, struct_name, etype, tstruct, print, filter) \
184 FTRACE_ENTRY_REG(call, struct_name, etype, \ 189 FTRACE_ENTRY_REG(call, struct_name, etype, \
185 PARAMS(tstruct), PARAMS(print), NULL) 190 PARAMS(tstruct), PARAMS(print), filter, NULL)
186 191
187int ftrace_event_is_function(struct ftrace_event_call *call) 192int ftrace_event_is_function(struct ftrace_event_call *call)
188{ 193{