diff options
author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2009-09-22 19:49:27 -0400 |
---|---|---|
committer | Anton Vorontsov <avorontsov@ru.mvista.com> | 2009-09-22 19:49:27 -0400 |
commit | f056878332a91ed984a116bad4e7d49aefff9e6e (patch) | |
tree | 572f4757c8e7811d45e0be0c2ae529c78fb63441 /kernel/trace/trace_events.c | |
parent | 3961f7c3cf247eee5df7fabadc7a40f2deeb98f3 (diff) | |
parent | 7fa07729e439a6184bd824746d06a49cca553f15 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts:
drivers/power/wm97xx_battery.c
Diffstat (limited to 'kernel/trace/trace_events.c')
-rw-r--r-- | kernel/trace/trace_events.c | 282 |
1 files changed, 171 insertions, 111 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 53c8fd376a88..6f03c8a1105e 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c | |||
@@ -17,16 +17,20 @@ | |||
17 | #include <linux/ctype.h> | 17 | #include <linux/ctype.h> |
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | 19 | ||
20 | #include <asm/setup.h> | ||
21 | |||
20 | #include "trace_output.h" | 22 | #include "trace_output.h" |
21 | 23 | ||
24 | #undef TRACE_SYSTEM | ||
22 | #define TRACE_SYSTEM "TRACE_SYSTEM" | 25 | #define TRACE_SYSTEM "TRACE_SYSTEM" |
23 | 26 | ||
24 | DEFINE_MUTEX(event_mutex); | 27 | DEFINE_MUTEX(event_mutex); |
25 | 28 | ||
26 | LIST_HEAD(ftrace_events); | 29 | LIST_HEAD(ftrace_events); |
27 | 30 | ||
28 | int trace_define_field(struct ftrace_event_call *call, char *type, | 31 | int trace_define_field(struct ftrace_event_call *call, const char *type, |
29 | char *name, int offset, int size, int is_signed) | 32 | const char *name, int offset, int size, int is_signed, |
33 | int filter_type) | ||
30 | { | 34 | { |
31 | struct ftrace_event_field *field; | 35 | struct ftrace_event_field *field; |
32 | 36 | ||
@@ -42,9 +46,15 @@ int trace_define_field(struct ftrace_event_call *call, char *type, | |||
42 | if (!field->type) | 46 | if (!field->type) |
43 | goto err; | 47 | goto err; |
44 | 48 | ||
49 | if (filter_type == FILTER_OTHER) | ||
50 | field->filter_type = filter_assign_type(type); | ||
51 | else | ||
52 | field->filter_type = filter_type; | ||
53 | |||
45 | field->offset = offset; | 54 | field->offset = offset; |
46 | field->size = size; | 55 | field->size = size; |
47 | field->is_signed = is_signed; | 56 | field->is_signed = is_signed; |
57 | |||
48 | list_add(&field->link, &call->fields); | 58 | list_add(&field->link, &call->fields); |
49 | 59 | ||
50 | return 0; | 60 | return 0; |
@@ -60,6 +70,29 @@ err: | |||
60 | } | 70 | } |
61 | EXPORT_SYMBOL_GPL(trace_define_field); | 71 | EXPORT_SYMBOL_GPL(trace_define_field); |
62 | 72 | ||
73 | #define __common_field(type, item) \ | ||
74 | ret = trace_define_field(call, #type, "common_" #item, \ | ||
75 | offsetof(typeof(ent), item), \ | ||
76 | sizeof(ent.item), \ | ||
77 | is_signed_type(type), FILTER_OTHER); \ | ||
78 | if (ret) \ | ||
79 | return ret; | ||
80 | |||
81 | int trace_define_common_fields(struct ftrace_event_call *call) | ||
82 | { | ||
83 | int ret; | ||
84 | struct trace_entry ent; | ||
85 | |||
86 | __common_field(unsigned short, type); | ||
87 | __common_field(unsigned char, flags); | ||
88 | __common_field(unsigned char, preempt_count); | ||
89 | __common_field(int, pid); | ||
90 | __common_field(int, lock_depth); | ||
91 | |||
92 | return ret; | ||
93 | } | ||
94 | EXPORT_SYMBOL_GPL(trace_define_common_fields); | ||
95 | |||
63 | #ifdef CONFIG_MODULES | 96 | #ifdef CONFIG_MODULES |
64 | 97 | ||
65 | static void trace_destroy_fields(struct ftrace_event_call *call) | 98 | static void trace_destroy_fields(struct ftrace_event_call *call) |
@@ -84,14 +117,14 @@ static void ftrace_event_enable_disable(struct ftrace_event_call *call, | |||
84 | if (call->enabled) { | 117 | if (call->enabled) { |
85 | call->enabled = 0; | 118 | call->enabled = 0; |
86 | tracing_stop_cmdline_record(); | 119 | tracing_stop_cmdline_record(); |
87 | call->unregfunc(); | 120 | call->unregfunc(call->data); |
88 | } | 121 | } |
89 | break; | 122 | break; |
90 | case 1: | 123 | case 1: |
91 | if (!call->enabled) { | 124 | if (!call->enabled) { |
92 | call->enabled = 1; | 125 | call->enabled = 1; |
93 | tracing_start_cmdline_record(); | 126 | tracing_start_cmdline_record(); |
94 | call->regfunc(); | 127 | call->regfunc(call->data); |
95 | } | 128 | } |
96 | break; | 129 | break; |
97 | } | 130 | } |
@@ -198,11 +231,9 @@ static ssize_t | |||
198 | ftrace_event_write(struct file *file, const char __user *ubuf, | 231 | ftrace_event_write(struct file *file, const char __user *ubuf, |
199 | size_t cnt, loff_t *ppos) | 232 | size_t cnt, loff_t *ppos) |
200 | { | 233 | { |
234 | struct trace_parser parser; | ||
201 | size_t read = 0; | 235 | size_t read = 0; |
202 | int i, set = 1; | ||
203 | ssize_t ret; | 236 | ssize_t ret; |
204 | char *buf; | ||
205 | char ch; | ||
206 | 237 | ||
207 | if (!cnt || cnt < 0) | 238 | if (!cnt || cnt < 0) |
208 | return 0; | 239 | return 0; |
@@ -211,60 +242,28 @@ ftrace_event_write(struct file *file, const char __user *ubuf, | |||
211 | if (ret < 0) | 242 | if (ret < 0) |
212 | return ret; | 243 | return ret; |
213 | 244 | ||
214 | ret = get_user(ch, ubuf++); | 245 | if (trace_parser_get_init(&parser, EVENT_BUF_SIZE + 1)) |
215 | if (ret) | ||
216 | return ret; | ||
217 | read++; | ||
218 | cnt--; | ||
219 | |||
220 | /* skip white space */ | ||
221 | while (cnt && isspace(ch)) { | ||
222 | ret = get_user(ch, ubuf++); | ||
223 | if (ret) | ||
224 | return ret; | ||
225 | read++; | ||
226 | cnt--; | ||
227 | } | ||
228 | |||
229 | /* Only white space found? */ | ||
230 | if (isspace(ch)) { | ||
231 | file->f_pos += read; | ||
232 | ret = read; | ||
233 | return ret; | ||
234 | } | ||
235 | |||
236 | buf = kmalloc(EVENT_BUF_SIZE+1, GFP_KERNEL); | ||
237 | if (!buf) | ||
238 | return -ENOMEM; | 246 | return -ENOMEM; |
239 | 247 | ||
240 | if (cnt > EVENT_BUF_SIZE) | 248 | read = trace_get_user(&parser, ubuf, cnt, ppos); |
241 | cnt = EVENT_BUF_SIZE; | 249 | |
250 | if (trace_parser_loaded((&parser))) { | ||
251 | int set = 1; | ||
242 | 252 | ||
243 | i = 0; | 253 | if (*parser.buffer == '!') |
244 | while (cnt && !isspace(ch)) { | ||
245 | if (!i && ch == '!') | ||
246 | set = 0; | 254 | set = 0; |
247 | else | ||
248 | buf[i++] = ch; | ||
249 | 255 | ||
250 | ret = get_user(ch, ubuf++); | 256 | parser.buffer[parser.idx] = 0; |
257 | |||
258 | ret = ftrace_set_clr_event(parser.buffer + !set, set); | ||
251 | if (ret) | 259 | if (ret) |
252 | goto out_free; | 260 | goto out_put; |
253 | read++; | ||
254 | cnt--; | ||
255 | } | 261 | } |
256 | buf[i] = 0; | ||
257 | |||
258 | file->f_pos += read; | ||
259 | |||
260 | ret = ftrace_set_clr_event(buf, set); | ||
261 | if (ret) | ||
262 | goto out_free; | ||
263 | 262 | ||
264 | ret = read; | 263 | ret = read; |
265 | 264 | ||
266 | out_free: | 265 | out_put: |
267 | kfree(buf); | 266 | trace_parser_put(&parser); |
268 | 267 | ||
269 | return ret; | 268 | return ret; |
270 | } | 269 | } |
@@ -272,42 +271,32 @@ ftrace_event_write(struct file *file, const char __user *ubuf, | |||
272 | static void * | 271 | static void * |
273 | t_next(struct seq_file *m, void *v, loff_t *pos) | 272 | t_next(struct seq_file *m, void *v, loff_t *pos) |
274 | { | 273 | { |
275 | struct list_head *list = m->private; | 274 | struct ftrace_event_call *call = v; |
276 | struct ftrace_event_call *call; | ||
277 | 275 | ||
278 | (*pos)++; | 276 | (*pos)++; |
279 | 277 | ||
280 | for (;;) { | 278 | list_for_each_entry_continue(call, &ftrace_events, list) { |
281 | if (list == &ftrace_events) | ||
282 | return NULL; | ||
283 | |||
284 | call = list_entry(list, struct ftrace_event_call, list); | ||
285 | |||
286 | /* | 279 | /* |
287 | * The ftrace subsystem is for showing formats only. | 280 | * The ftrace subsystem is for showing formats only. |
288 | * They can not be enabled or disabled via the event files. | 281 | * They can not be enabled or disabled via the event files. |
289 | */ | 282 | */ |
290 | if (call->regfunc) | 283 | if (call->regfunc) |
291 | break; | 284 | return call; |
292 | |||
293 | list = list->next; | ||
294 | } | 285 | } |
295 | 286 | ||
296 | m->private = list->next; | 287 | return NULL; |
297 | |||
298 | return call; | ||
299 | } | 288 | } |
300 | 289 | ||
301 | static void *t_start(struct seq_file *m, loff_t *pos) | 290 | static void *t_start(struct seq_file *m, loff_t *pos) |
302 | { | 291 | { |
303 | struct ftrace_event_call *call = NULL; | 292 | struct ftrace_event_call *call; |
304 | loff_t l; | 293 | loff_t l; |
305 | 294 | ||
306 | mutex_lock(&event_mutex); | 295 | mutex_lock(&event_mutex); |
307 | 296 | ||
308 | m->private = ftrace_events.next; | 297 | call = list_entry(&ftrace_events, struct ftrace_event_call, list); |
309 | for (l = 0; l <= *pos; ) { | 298 | for (l = 0; l <= *pos; ) { |
310 | call = t_next(m, NULL, &l); | 299 | call = t_next(m, call, &l); |
311 | if (!call) | 300 | if (!call) |
312 | break; | 301 | break; |
313 | } | 302 | } |
@@ -317,37 +306,28 @@ static void *t_start(struct seq_file *m, loff_t *pos) | |||
317 | static void * | 306 | static void * |
318 | s_next(struct seq_file *m, void *v, loff_t *pos) | 307 | s_next(struct seq_file *m, void *v, loff_t *pos) |
319 | { | 308 | { |
320 | struct list_head *list = m->private; | 309 | struct ftrace_event_call *call = v; |
321 | struct ftrace_event_call *call; | ||
322 | 310 | ||
323 | (*pos)++; | 311 | (*pos)++; |
324 | 312 | ||
325 | retry: | 313 | list_for_each_entry_continue(call, &ftrace_events, list) { |
326 | if (list == &ftrace_events) | 314 | if (call->enabled) |
327 | return NULL; | 315 | return call; |
328 | |||
329 | call = list_entry(list, struct ftrace_event_call, list); | ||
330 | |||
331 | if (!call->enabled) { | ||
332 | list = list->next; | ||
333 | goto retry; | ||
334 | } | 316 | } |
335 | 317 | ||
336 | m->private = list->next; | 318 | return NULL; |
337 | |||
338 | return call; | ||
339 | } | 319 | } |
340 | 320 | ||
341 | static void *s_start(struct seq_file *m, loff_t *pos) | 321 | static void *s_start(struct seq_file *m, loff_t *pos) |
342 | { | 322 | { |
343 | struct ftrace_event_call *call = NULL; | 323 | struct ftrace_event_call *call; |
344 | loff_t l; | 324 | loff_t l; |
345 | 325 | ||
346 | mutex_lock(&event_mutex); | 326 | mutex_lock(&event_mutex); |
347 | 327 | ||
348 | m->private = ftrace_events.next; | 328 | call = list_entry(&ftrace_events, struct ftrace_event_call, list); |
349 | for (l = 0; l <= *pos; ) { | 329 | for (l = 0; l <= *pos; ) { |
350 | call = s_next(m, NULL, &l); | 330 | call = s_next(m, call, &l); |
351 | if (!call) | 331 | if (!call) |
352 | break; | 332 | break; |
353 | } | 333 | } |
@@ -376,7 +356,7 @@ ftrace_event_seq_open(struct inode *inode, struct file *file) | |||
376 | const struct seq_operations *seq_ops; | 356 | const struct seq_operations *seq_ops; |
377 | 357 | ||
378 | if ((file->f_mode & FMODE_WRITE) && | 358 | if ((file->f_mode & FMODE_WRITE) && |
379 | !(file->f_flags & O_APPEND)) | 359 | (file->f_flags & O_TRUNC)) |
380 | ftrace_clear_events(); | 360 | ftrace_clear_events(); |
381 | 361 | ||
382 | seq_ops = inode->i_private; | 362 | seq_ops = inode->i_private; |
@@ -546,7 +526,7 @@ static int trace_write_header(struct trace_seq *s) | |||
546 | FIELD(unsigned char, flags), | 526 | FIELD(unsigned char, flags), |
547 | FIELD(unsigned char, preempt_count), | 527 | FIELD(unsigned char, preempt_count), |
548 | FIELD(int, pid), | 528 | FIELD(int, pid), |
549 | FIELD(int, tgid)); | 529 | FIELD(int, lock_depth)); |
550 | } | 530 | } |
551 | 531 | ||
552 | static ssize_t | 532 | static ssize_t |
@@ -574,7 +554,7 @@ event_format_read(struct file *filp, char __user *ubuf, size_t cnt, | |||
574 | trace_seq_printf(s, "format:\n"); | 554 | trace_seq_printf(s, "format:\n"); |
575 | trace_write_header(s); | 555 | trace_write_header(s); |
576 | 556 | ||
577 | r = call->show_format(s); | 557 | r = call->show_format(call, s); |
578 | if (!r) { | 558 | if (!r) { |
579 | /* | 559 | /* |
580 | * ug! The format output is bigger than a PAGE!! | 560 | * ug! The format output is bigger than a PAGE!! |
@@ -849,8 +829,10 @@ event_subsystem_dir(const char *name, struct dentry *d_events) | |||
849 | 829 | ||
850 | /* First see if we did not already create this dir */ | 830 | /* First see if we did not already create this dir */ |
851 | list_for_each_entry(system, &event_subsystems, list) { | 831 | list_for_each_entry(system, &event_subsystems, list) { |
852 | if (strcmp(system->name, name) == 0) | 832 | if (strcmp(system->name, name) == 0) { |
833 | system->nr_events++; | ||
853 | return system->entry; | 834 | return system->entry; |
835 | } | ||
854 | } | 836 | } |
855 | 837 | ||
856 | /* need to create new entry */ | 838 | /* need to create new entry */ |
@@ -869,6 +851,7 @@ event_subsystem_dir(const char *name, struct dentry *d_events) | |||
869 | return d_events; | 851 | return d_events; |
870 | } | 852 | } |
871 | 853 | ||
854 | system->nr_events = 1; | ||
872 | system->name = kstrdup(name, GFP_KERNEL); | 855 | system->name = kstrdup(name, GFP_KERNEL); |
873 | if (!system->name) { | 856 | if (!system->name) { |
874 | debugfs_remove(system->entry); | 857 | debugfs_remove(system->entry); |
@@ -920,15 +903,6 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events, | |||
920 | if (strcmp(call->system, TRACE_SYSTEM) != 0) | 903 | if (strcmp(call->system, TRACE_SYSTEM) != 0) |
921 | d_events = event_subsystem_dir(call->system, d_events); | 904 | d_events = event_subsystem_dir(call->system, d_events); |
922 | 905 | ||
923 | if (call->raw_init) { | ||
924 | ret = call->raw_init(); | ||
925 | if (ret < 0) { | ||
926 | pr_warning("Could not initialize trace point" | ||
927 | " events/%s\n", call->name); | ||
928 | return ret; | ||
929 | } | ||
930 | } | ||
931 | |||
932 | call->dir = debugfs_create_dir(call->name, d_events); | 906 | call->dir = debugfs_create_dir(call->name, d_events); |
933 | if (!call->dir) { | 907 | if (!call->dir) { |
934 | pr_warning("Could not create debugfs " | 908 | pr_warning("Could not create debugfs " |
@@ -940,12 +914,12 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events, | |||
940 | entry = trace_create_file("enable", 0644, call->dir, call, | 914 | entry = trace_create_file("enable", 0644, call->dir, call, |
941 | enable); | 915 | enable); |
942 | 916 | ||
943 | if (call->id) | 917 | if (call->id && call->profile_enable) |
944 | entry = trace_create_file("id", 0444, call->dir, call, | 918 | entry = trace_create_file("id", 0444, call->dir, call, |
945 | id); | 919 | id); |
946 | 920 | ||
947 | if (call->define_fields) { | 921 | if (call->define_fields) { |
948 | ret = call->define_fields(); | 922 | ret = call->define_fields(call); |
949 | if (ret < 0) { | 923 | if (ret < 0) { |
950 | pr_warning("Could not initialize trace point" | 924 | pr_warning("Could not initialize trace point" |
951 | " events/%s\n", call->name); | 925 | " events/%s\n", call->name); |
@@ -987,6 +961,32 @@ struct ftrace_module_file_ops { | |||
987 | struct file_operations filter; | 961 | struct file_operations filter; |
988 | }; | 962 | }; |
989 | 963 | ||
964 | static void remove_subsystem_dir(const char *name) | ||
965 | { | ||
966 | struct event_subsystem *system; | ||
967 | |||
968 | if (strcmp(name, TRACE_SYSTEM) == 0) | ||
969 | return; | ||
970 | |||
971 | list_for_each_entry(system, &event_subsystems, list) { | ||
972 | if (strcmp(system->name, name) == 0) { | ||
973 | if (!--system->nr_events) { | ||
974 | struct event_filter *filter = system->filter; | ||
975 | |||
976 | debugfs_remove_recursive(system->entry); | ||
977 | list_del(&system->list); | ||
978 | if (filter) { | ||
979 | kfree(filter->filter_string); | ||
980 | kfree(filter); | ||
981 | } | ||
982 | kfree(system->name); | ||
983 | kfree(system); | ||
984 | } | ||
985 | break; | ||
986 | } | ||
987 | } | ||
988 | } | ||
989 | |||
990 | static struct ftrace_module_file_ops * | 990 | static struct ftrace_module_file_ops * |
991 | trace_create_file_ops(struct module *mod) | 991 | trace_create_file_ops(struct module *mod) |
992 | { | 992 | { |
@@ -1027,6 +1027,7 @@ static void trace_module_add_events(struct module *mod) | |||
1027 | struct ftrace_module_file_ops *file_ops = NULL; | 1027 | struct ftrace_module_file_ops *file_ops = NULL; |
1028 | struct ftrace_event_call *call, *start, *end; | 1028 | struct ftrace_event_call *call, *start, *end; |
1029 | struct dentry *d_events; | 1029 | struct dentry *d_events; |
1030 | int ret; | ||
1030 | 1031 | ||
1031 | start = mod->trace_events; | 1032 | start = mod->trace_events; |
1032 | end = mod->trace_events + mod->num_trace_events; | 1033 | end = mod->trace_events + mod->num_trace_events; |
@@ -1042,7 +1043,15 @@ static void trace_module_add_events(struct module *mod) | |||
1042 | /* The linker may leave blanks */ | 1043 | /* The linker may leave blanks */ |
1043 | if (!call->name) | 1044 | if (!call->name) |
1044 | continue; | 1045 | continue; |
1045 | 1046 | if (call->raw_init) { | |
1047 | ret = call->raw_init(); | ||
1048 | if (ret < 0) { | ||
1049 | if (ret != -ENOSYS) | ||
1050 | pr_warning("Could not initialize trace " | ||
1051 | "point events/%s\n", call->name); | ||
1052 | continue; | ||
1053 | } | ||
1054 | } | ||
1046 | /* | 1055 | /* |
1047 | * This module has events, create file ops for this module | 1056 | * This module has events, create file ops for this module |
1048 | * if not already done. | 1057 | * if not already done. |
@@ -1077,6 +1086,7 @@ static void trace_module_remove_events(struct module *mod) | |||
1077 | list_del(&call->list); | 1086 | list_del(&call->list); |
1078 | trace_destroy_fields(call); | 1087 | trace_destroy_fields(call); |
1079 | destroy_preds(call); | 1088 | destroy_preds(call); |
1089 | remove_subsystem_dir(call->system); | ||
1080 | } | 1090 | } |
1081 | } | 1091 | } |
1082 | 1092 | ||
@@ -1125,7 +1135,7 @@ static int trace_module_notify(struct notifier_block *self, | |||
1125 | } | 1135 | } |
1126 | #endif /* CONFIG_MODULES */ | 1136 | #endif /* CONFIG_MODULES */ |
1127 | 1137 | ||
1128 | struct notifier_block trace_module_nb = { | 1138 | static struct notifier_block trace_module_nb = { |
1129 | .notifier_call = trace_module_notify, | 1139 | .notifier_call = trace_module_notify, |
1130 | .priority = 0, | 1140 | .priority = 0, |
1131 | }; | 1141 | }; |
@@ -1133,6 +1143,18 @@ struct notifier_block trace_module_nb = { | |||
1133 | extern struct ftrace_event_call __start_ftrace_events[]; | 1143 | extern struct ftrace_event_call __start_ftrace_events[]; |
1134 | extern struct ftrace_event_call __stop_ftrace_events[]; | 1144 | extern struct ftrace_event_call __stop_ftrace_events[]; |
1135 | 1145 | ||
1146 | static char bootup_event_buf[COMMAND_LINE_SIZE] __initdata; | ||
1147 | |||
1148 | static __init int setup_trace_event(char *str) | ||
1149 | { | ||
1150 | strlcpy(bootup_event_buf, str, COMMAND_LINE_SIZE); | ||
1151 | ring_buffer_expanded = 1; | ||
1152 | tracing_selftest_disabled = 1; | ||
1153 | |||
1154 | return 1; | ||
1155 | } | ||
1156 | __setup("trace_event=", setup_trace_event); | ||
1157 | |||
1136 | static __init int event_trace_init(void) | 1158 | static __init int event_trace_init(void) |
1137 | { | 1159 | { |
1138 | struct ftrace_event_call *call; | 1160 | struct ftrace_event_call *call; |
@@ -1140,6 +1162,8 @@ static __init int event_trace_init(void) | |||
1140 | struct dentry *entry; | 1162 | struct dentry *entry; |
1141 | struct dentry *d_events; | 1163 | struct dentry *d_events; |
1142 | int ret; | 1164 | int ret; |
1165 | char *buf = bootup_event_buf; | ||
1166 | char *token; | ||
1143 | 1167 | ||
1144 | d_tracer = tracing_init_dentry(); | 1168 | d_tracer = tracing_init_dentry(); |
1145 | if (!d_tracer) | 1169 | if (!d_tracer) |
@@ -1179,12 +1203,34 @@ static __init int event_trace_init(void) | |||
1179 | /* The linker may leave blanks */ | 1203 | /* The linker may leave blanks */ |
1180 | if (!call->name) | 1204 | if (!call->name) |
1181 | continue; | 1205 | continue; |
1206 | if (call->raw_init) { | ||
1207 | ret = call->raw_init(); | ||
1208 | if (ret < 0) { | ||
1209 | if (ret != -ENOSYS) | ||
1210 | pr_warning("Could not initialize trace " | ||
1211 | "point events/%s\n", call->name); | ||
1212 | continue; | ||
1213 | } | ||
1214 | } | ||
1182 | list_add(&call->list, &ftrace_events); | 1215 | list_add(&call->list, &ftrace_events); |
1183 | event_create_dir(call, d_events, &ftrace_event_id_fops, | 1216 | event_create_dir(call, d_events, &ftrace_event_id_fops, |
1184 | &ftrace_enable_fops, &ftrace_event_filter_fops, | 1217 | &ftrace_enable_fops, &ftrace_event_filter_fops, |
1185 | &ftrace_event_format_fops); | 1218 | &ftrace_event_format_fops); |
1186 | } | 1219 | } |
1187 | 1220 | ||
1221 | while (true) { | ||
1222 | token = strsep(&buf, ","); | ||
1223 | |||
1224 | if (!token) | ||
1225 | break; | ||
1226 | if (!*token) | ||
1227 | continue; | ||
1228 | |||
1229 | ret = ftrace_set_clr_event(token, 1); | ||
1230 | if (ret) | ||
1231 | pr_warning("Failed to enable trace event: %s\n", token); | ||
1232 | } | ||
1233 | |||
1188 | ret = register_module_notifier(&trace_module_nb); | 1234 | ret = register_module_notifier(&trace_module_nb); |
1189 | if (ret) | 1235 | if (ret) |
1190 | pr_warning("Failed to register trace events module notifier\n"); | 1236 | pr_warning("Failed to register trace events module notifier\n"); |
@@ -1261,6 +1307,18 @@ static __init void event_trace_self_tests(void) | |||
1261 | if (!call->regfunc) | 1307 | if (!call->regfunc) |
1262 | continue; | 1308 | continue; |
1263 | 1309 | ||
1310 | /* | ||
1311 | * Testing syscall events here is pretty useless, but | ||
1312 | * we still do it if configured. But this is time consuming. | ||
1313 | * What we really need is a user thread to perform the | ||
1314 | * syscalls as we test. | ||
1315 | */ | ||
1316 | #ifndef CONFIG_EVENT_TRACE_TEST_SYSCALLS | ||
1317 | if (call->system && | ||
1318 | strcmp(call->system, "syscalls") == 0) | ||
1319 | continue; | ||
1320 | #endif | ||
1321 | |||
1264 | pr_info("Testing event %s: ", call->name); | 1322 | pr_info("Testing event %s: ", call->name); |
1265 | 1323 | ||
1266 | /* | 1324 | /* |
@@ -1334,12 +1392,13 @@ static __init void event_trace_self_tests(void) | |||
1334 | 1392 | ||
1335 | #ifdef CONFIG_FUNCTION_TRACER | 1393 | #ifdef CONFIG_FUNCTION_TRACER |
1336 | 1394 | ||
1337 | static DEFINE_PER_CPU(atomic_t, test_event_disable); | 1395 | static DEFINE_PER_CPU(atomic_t, ftrace_test_event_disable); |
1338 | 1396 | ||
1339 | static void | 1397 | static void |
1340 | function_test_events_call(unsigned long ip, unsigned long parent_ip) | 1398 | function_test_events_call(unsigned long ip, unsigned long parent_ip) |
1341 | { | 1399 | { |
1342 | struct ring_buffer_event *event; | 1400 | struct ring_buffer_event *event; |
1401 | struct ring_buffer *buffer; | ||
1343 | struct ftrace_entry *entry; | 1402 | struct ftrace_entry *entry; |
1344 | unsigned long flags; | 1403 | unsigned long flags; |
1345 | long disabled; | 1404 | long disabled; |
@@ -1350,14 +1409,15 @@ function_test_events_call(unsigned long ip, unsigned long parent_ip) | |||
1350 | pc = preempt_count(); | 1409 | pc = preempt_count(); |
1351 | resched = ftrace_preempt_disable(); | 1410 | resched = ftrace_preempt_disable(); |
1352 | cpu = raw_smp_processor_id(); | 1411 | cpu = raw_smp_processor_id(); |
1353 | disabled = atomic_inc_return(&per_cpu(test_event_disable, cpu)); | 1412 | disabled = atomic_inc_return(&per_cpu(ftrace_test_event_disable, cpu)); |
1354 | 1413 | ||
1355 | if (disabled != 1) | 1414 | if (disabled != 1) |
1356 | goto out; | 1415 | goto out; |
1357 | 1416 | ||
1358 | local_save_flags(flags); | 1417 | local_save_flags(flags); |
1359 | 1418 | ||
1360 | event = trace_current_buffer_lock_reserve(TRACE_FN, sizeof(*entry), | 1419 | event = trace_current_buffer_lock_reserve(&buffer, |
1420 | TRACE_FN, sizeof(*entry), | ||
1361 | flags, pc); | 1421 | flags, pc); |
1362 | if (!event) | 1422 | if (!event) |
1363 | goto out; | 1423 | goto out; |
@@ -1365,10 +1425,10 @@ function_test_events_call(unsigned long ip, unsigned long parent_ip) | |||
1365 | entry->ip = ip; | 1425 | entry->ip = ip; |
1366 | entry->parent_ip = parent_ip; | 1426 | entry->parent_ip = parent_ip; |
1367 | 1427 | ||
1368 | trace_nowake_buffer_unlock_commit(event, flags, pc); | 1428 | trace_nowake_buffer_unlock_commit(buffer, event, flags, pc); |
1369 | 1429 | ||
1370 | out: | 1430 | out: |
1371 | atomic_dec(&per_cpu(test_event_disable, cpu)); | 1431 | atomic_dec(&per_cpu(ftrace_test_event_disable, cpu)); |
1372 | ftrace_preempt_enable(resched); | 1432 | ftrace_preempt_enable(resched); |
1373 | } | 1433 | } |
1374 | 1434 | ||
@@ -1392,10 +1452,10 @@ static __init void event_trace_self_test_with_function(void) | |||
1392 | 1452 | ||
1393 | static __init int event_trace_self_tests_init(void) | 1453 | static __init int event_trace_self_tests_init(void) |
1394 | { | 1454 | { |
1395 | 1455 | if (!tracing_selftest_disabled) { | |
1396 | event_trace_self_tests(); | 1456 | event_trace_self_tests(); |
1397 | 1457 | event_trace_self_test_with_function(); | |
1398 | event_trace_self_test_with_function(); | 1458 | } |
1399 | 1459 | ||
1400 | return 0; | 1460 | return 0; |
1401 | } | 1461 | } |