aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/ftrace_event.h6
-rw-r--r--include/linux/syscalls.h6
-rw-r--r--include/trace/ftrace.h44
-rw-r--r--kernel/trace/trace_events.c20
-rw-r--r--kernel/trace/trace_events_filter.c6
-rw-r--r--kernel/trace/trace_export.c6
-rw-r--r--kernel/trace/trace_kprobe.c12
-rw-r--r--kernel/trace/trace_syscalls.c4
8 files changed, 56 insertions, 48 deletions
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index 39e71b0a3bfd..496eea898ee4 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -113,10 +113,14 @@ void tracing_record_cmdline(struct task_struct *tsk);
113 113
114struct event_filter; 114struct event_filter;
115 115
116struct ftrace_event_class {
117 char *system;
118};
119
116struct ftrace_event_call { 120struct ftrace_event_call {
117 struct list_head list; 121 struct list_head list;
122 struct ftrace_event_class *class;
118 char *name; 123 char *name;
119 char *system;
120 struct dentry *dir; 124 struct dentry *dir;
121 struct trace_event *event; 125 struct trace_event *event;
122 int enabled; 126 int enabled;
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 057929b0a651..ac5791df2506 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -134,6 +134,8 @@ struct perf_event_attr;
134#define __SC_STR_TDECL5(t, a, ...) #t, __SC_STR_TDECL4(__VA_ARGS__) 134#define __SC_STR_TDECL5(t, a, ...) #t, __SC_STR_TDECL4(__VA_ARGS__)
135#define __SC_STR_TDECL6(t, a, ...) #t, __SC_STR_TDECL5(__VA_ARGS__) 135#define __SC_STR_TDECL6(t, a, ...) #t, __SC_STR_TDECL5(__VA_ARGS__)
136 136
137extern struct ftrace_event_class event_class_syscalls;
138
137#define SYSCALL_TRACE_ENTER_EVENT(sname) \ 139#define SYSCALL_TRACE_ENTER_EVENT(sname) \
138 static const struct syscall_metadata __syscall_meta_##sname; \ 140 static const struct syscall_metadata __syscall_meta_##sname; \
139 static struct ftrace_event_call \ 141 static struct ftrace_event_call \
@@ -146,7 +148,7 @@ struct perf_event_attr;
146 __attribute__((section("_ftrace_events"))) \ 148 __attribute__((section("_ftrace_events"))) \
147 event_enter_##sname = { \ 149 event_enter_##sname = { \
148 .name = "sys_enter"#sname, \ 150 .name = "sys_enter"#sname, \
149 .system = "syscalls", \ 151 .class = &event_class_syscalls, \
150 .event = &enter_syscall_print_##sname, \ 152 .event = &enter_syscall_print_##sname, \
151 .raw_init = init_syscall_trace, \ 153 .raw_init = init_syscall_trace, \
152 .define_fields = syscall_enter_define_fields, \ 154 .define_fields = syscall_enter_define_fields, \
@@ -168,7 +170,7 @@ struct perf_event_attr;
168 __attribute__((section("_ftrace_events"))) \ 170 __attribute__((section("_ftrace_events"))) \
169 event_exit_##sname = { \ 171 event_exit_##sname = { \
170 .name = "sys_exit"#sname, \ 172 .name = "sys_exit"#sname, \
171 .system = "syscalls", \ 173 .class = &event_class_syscalls, \
172 .event = &exit_syscall_print_##sname, \ 174 .event = &exit_syscall_print_##sname, \
173 .raw_init = init_syscall_trace, \ 175 .raw_init = init_syscall_trace, \
174 .define_fields = syscall_exit_define_fields, \ 176 .define_fields = syscall_exit_define_fields, \
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 75dd7787fb37..7dcdfd824aab 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -62,7 +62,10 @@
62 struct trace_entry ent; \ 62 struct trace_entry ent; \
63 tstruct \ 63 tstruct \
64 char __data[0]; \ 64 char __data[0]; \
65 }; 65 }; \
66 \
67 static struct ftrace_event_class event_class_##name;
68
66#undef DEFINE_EVENT 69#undef DEFINE_EVENT
67#define DEFINE_EVENT(template, name, proto, args) \ 70#define DEFINE_EVENT(template, name, proto, args) \
68 static struct ftrace_event_call \ 71 static struct ftrace_event_call \
@@ -430,22 +433,6 @@ perf_trace_disable_##name(struct ftrace_event_call *unused) \
430 * 433 *
431 * Override the macros in <trace/trace_events.h> to include the following: 434 * Override the macros in <trace/trace_events.h> to include the following:
432 * 435 *
433 * static void ftrace_event_<call>(proto)
434 * {
435 * event_trace_printk(_RET_IP_, "<call>: " <fmt>);
436 * }
437 *
438 * static int ftrace_reg_event_<call>(struct ftrace_event_call *unused)
439 * {
440 * return register_trace_<call>(ftrace_event_<call>);
441 * }
442 *
443 * static void ftrace_unreg_event_<call>(struct ftrace_event_call *unused)
444 * {
445 * unregister_trace_<call>(ftrace_event_<call>);
446 * }
447 *
448 *
449 * For those macros defined with TRACE_EVENT: 436 * For those macros defined with TRACE_EVENT:
450 * 437 *
451 * static struct ftrace_event_call event_<call>; 438 * static struct ftrace_event_call event_<call>;
@@ -497,17 +484,21 @@ perf_trace_disable_##name(struct ftrace_event_call *unused) \
497 * 484 *
498 * static const char print_fmt_<call>[] = <TP_printk>; 485 * static const char print_fmt_<call>[] = <TP_printk>;
499 * 486 *
487 * static struct ftrace_event_class __used event_class_<template> = {
488 * .system = "<system>",
489 * };
490 *
500 * static struct ftrace_event_call __used 491 * static struct ftrace_event_call __used
501 * __attribute__((__aligned__(4))) 492 * __attribute__((__aligned__(4)))
502 * __attribute__((section("_ftrace_events"))) event_<call> = { 493 * __attribute__((section("_ftrace_events"))) event_<call> = {
503 * .name = "<call>", 494 * .name = "<call>",
504 * .system = "<system>", 495 * .class = event_class_<template>,
505 * .raw_init = trace_event_raw_init, 496 * .raw_init = trace_event_raw_init,
506 * .regfunc = ftrace_reg_event_<call>, 497 * .regfunc = ftrace_raw_reg_event_<call>,
507 * .unregfunc = ftrace_unreg_event_<call>, 498 * .unregfunc = ftrace_raw_unreg_event_<call>,
508 * .print_fmt = print_fmt_<call>, 499 * .print_fmt = print_fmt_<call>,
509 * .define_fields = ftrace_define_fields_<call>, 500 * .define_fields = ftrace_define_fields_<call>,
510 * } 501 * };
511 * 502 *
512 */ 503 */
513 504
@@ -627,7 +618,10 @@ static struct trace_event ftrace_event_type_##call = { \
627 618
628#undef DECLARE_EVENT_CLASS 619#undef DECLARE_EVENT_CLASS
629#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ 620#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
630static const char print_fmt_##call[] = print; 621static const char print_fmt_##call[] = print; \
622static struct ftrace_event_class __used event_class_##call = { \
623 .system = __stringify(TRACE_SYSTEM) \
624};
631 625
632#undef DEFINE_EVENT 626#undef DEFINE_EVENT
633#define DEFINE_EVENT(template, call, proto, args) \ 627#define DEFINE_EVENT(template, call, proto, args) \
@@ -636,7 +630,7 @@ static struct ftrace_event_call __used \
636__attribute__((__aligned__(4))) \ 630__attribute__((__aligned__(4))) \
637__attribute__((section("_ftrace_events"))) event_##call = { \ 631__attribute__((section("_ftrace_events"))) event_##call = { \
638 .name = #call, \ 632 .name = #call, \
639 .system = __stringify(TRACE_SYSTEM), \ 633 .class = &event_class_##template, \
640 .event = &ftrace_event_type_##call, \ 634 .event = &ftrace_event_type_##call, \
641 .raw_init = trace_event_raw_init, \ 635 .raw_init = trace_event_raw_init, \
642 .regfunc = ftrace_raw_reg_event_##call, \ 636 .regfunc = ftrace_raw_reg_event_##call, \
@@ -644,7 +638,7 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
644 .print_fmt = print_fmt_##template, \ 638 .print_fmt = print_fmt_##template, \
645 .define_fields = ftrace_define_fields_##template, \ 639 .define_fields = ftrace_define_fields_##template, \
646 _TRACE_PERF_INIT(call) \ 640 _TRACE_PERF_INIT(call) \
647} 641};
648 642
649#undef DEFINE_EVENT_PRINT 643#undef DEFINE_EVENT_PRINT
650#define DEFINE_EVENT_PRINT(template, call, proto, args, print) \ 644#define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
@@ -655,7 +649,7 @@ static struct ftrace_event_call __used \
655__attribute__((__aligned__(4))) \ 649__attribute__((__aligned__(4))) \
656__attribute__((section("_ftrace_events"))) event_##call = { \ 650__attribute__((section("_ftrace_events"))) event_##call = { \
657 .name = #call, \ 651 .name = #call, \
658 .system = __stringify(TRACE_SYSTEM), \ 652 .class = &event_class_##template, \
659 .event = &ftrace_event_type_##call, \ 653 .event = &ftrace_event_type_##call, \
660 .raw_init = trace_event_raw_init, \ 654 .raw_init = trace_event_raw_init, \
661 .regfunc = ftrace_raw_reg_event_##call, \ 655 .regfunc = ftrace_raw_reg_event_##call, \
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index c697c7043349..2f54b48d3632 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -176,10 +176,10 @@ static int __ftrace_set_clr_event(const char *match, const char *sub,
176 176
177 if (match && 177 if (match &&
178 strcmp(match, call->name) != 0 && 178 strcmp(match, call->name) != 0 &&
179 strcmp(match, call->system) != 0) 179 strcmp(match, call->class->system) != 0)
180 continue; 180 continue;
181 181
182 if (sub && strcmp(sub, call->system) != 0) 182 if (sub && strcmp(sub, call->class->system) != 0)
183 continue; 183 continue;
184 184
185 if (event && strcmp(event, call->name) != 0) 185 if (event && strcmp(event, call->name) != 0)
@@ -355,8 +355,8 @@ static int t_show(struct seq_file *m, void *v)
355{ 355{
356 struct ftrace_event_call *call = v; 356 struct ftrace_event_call *call = v;
357 357
358 if (strcmp(call->system, TRACE_SYSTEM) != 0) 358 if (strcmp(call->class->system, TRACE_SYSTEM) != 0)
359 seq_printf(m, "%s:", call->system); 359 seq_printf(m, "%s:", call->class->system);
360 seq_printf(m, "%s\n", call->name); 360 seq_printf(m, "%s\n", call->name);
361 361
362 return 0; 362 return 0;
@@ -453,7 +453,7 @@ system_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
453 if (!call->name || !call->regfunc) 453 if (!call->name || !call->regfunc)
454 continue; 454 continue;
455 455
456 if (system && strcmp(call->system, system) != 0) 456 if (system && strcmp(call->class->system, system) != 0)
457 continue; 457 continue;
458 458
459 /* 459 /*
@@ -925,8 +925,8 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events,
925 * If the trace point header did not define TRACE_SYSTEM 925 * If the trace point header did not define TRACE_SYSTEM
926 * then the system would be called "TRACE_SYSTEM". 926 * then the system would be called "TRACE_SYSTEM".
927 */ 927 */
928 if (strcmp(call->system, TRACE_SYSTEM) != 0) 928 if (strcmp(call->class->system, TRACE_SYSTEM) != 0)
929 d_events = event_subsystem_dir(call->system, d_events); 929 d_events = event_subsystem_dir(call->class->system, d_events);
930 930
931 call->dir = debugfs_create_dir(call->name, d_events); 931 call->dir = debugfs_create_dir(call->name, d_events);
932 if (!call->dir) { 932 if (!call->dir) {
@@ -1041,7 +1041,7 @@ static void __trace_remove_event_call(struct ftrace_event_call *call)
1041 list_del(&call->list); 1041 list_del(&call->list);
1042 trace_destroy_fields(call); 1042 trace_destroy_fields(call);
1043 destroy_preds(call); 1043 destroy_preds(call);
1044 remove_subsystem_dir(call->system); 1044 remove_subsystem_dir(call->class->system);
1045} 1045}
1046 1046
1047/* Remove an event_call */ 1047/* Remove an event_call */
@@ -1399,8 +1399,8 @@ static __init void event_trace_self_tests(void)
1399 * syscalls as we test. 1399 * syscalls as we test.
1400 */ 1400 */
1401#ifndef CONFIG_EVENT_TRACE_TEST_SYSCALLS 1401#ifndef CONFIG_EVENT_TRACE_TEST_SYSCALLS
1402 if (call->system && 1402 if (call->class->system &&
1403 strcmp(call->system, "syscalls") == 0) 1403 strcmp(call->class->system, "syscalls") == 0)
1404 continue; 1404 continue;
1405#endif 1405#endif
1406 1406
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 88c0b6dbd7fe..ca329603d0bf 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -628,7 +628,7 @@ static int init_subsystem_preds(struct event_subsystem *system)
628 if (!call->define_fields) 628 if (!call->define_fields)
629 continue; 629 continue;
630 630
631 if (strcmp(call->system, system->name) != 0) 631 if (strcmp(call->class->system, system->name) != 0)
632 continue; 632 continue;
633 633
634 err = init_preds(call); 634 err = init_preds(call);
@@ -647,7 +647,7 @@ static void filter_free_subsystem_preds(struct event_subsystem *system)
647 if (!call->define_fields) 647 if (!call->define_fields)
648 continue; 648 continue;
649 649
650 if (strcmp(call->system, system->name) != 0) 650 if (strcmp(call->class->system, system->name) != 0)
651 continue; 651 continue;
652 652
653 filter_disable_preds(call); 653 filter_disable_preds(call);
@@ -1252,7 +1252,7 @@ static int replace_system_preds(struct event_subsystem *system,
1252 if (!call->define_fields) 1252 if (!call->define_fields)
1253 continue; 1253 continue;
1254 1254
1255 if (strcmp(call->system, system->name) != 0) 1255 if (strcmp(call->class->system, system->name) != 0)
1256 continue; 1256 continue;
1257 1257
1258 /* try to see if the filter can be applied */ 1258 /* try to see if the filter can be applied */
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c
index e091f64ba6ce..7f16e2163817 100644
--- a/kernel/trace/trace_export.c
+++ b/kernel/trace/trace_export.c
@@ -18,6 +18,10 @@
18#undef TRACE_SYSTEM 18#undef TRACE_SYSTEM
19#define TRACE_SYSTEM ftrace 19#define TRACE_SYSTEM ftrace
20 20
21struct ftrace_event_class event_class_ftrace = {
22 .system = __stringify(TRACE_SYSTEM),
23};
24
21/* not needed for this file */ 25/* not needed for this file */
22#undef __field_struct 26#undef __field_struct
23#define __field_struct(type, item) 27#define __field_struct(type, item)
@@ -160,7 +164,7 @@ __attribute__((__aligned__(4))) \
160__attribute__((section("_ftrace_events"))) event_##call = { \ 164__attribute__((section("_ftrace_events"))) event_##call = { \
161 .name = #call, \ 165 .name = #call, \
162 .id = type, \ 166 .id = type, \
163 .system = __stringify(TRACE_SYSTEM), \ 167 .class = &event_class_ftrace, \
164 .raw_init = ftrace_raw_init_event, \ 168 .raw_init = ftrace_raw_init_event, \
165 .print_fmt = print, \ 169 .print_fmt = print, \
166 .define_fields = ftrace_define_fields_##call, \ 170 .define_fields = ftrace_define_fields_##call, \
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 1251e367bae9..eda220bf2065 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -332,8 +332,8 @@ static struct trace_probe *alloc_trace_probe(const char *group,
332 goto error; 332 goto error;
333 } 333 }
334 334
335 tp->call.system = kstrdup(group, GFP_KERNEL); 335 tp->call.class->system = kstrdup(group, GFP_KERNEL);
336 if (!tp->call.system) 336 if (!tp->call.class->system)
337 goto error; 337 goto error;
338 338
339 INIT_LIST_HEAD(&tp->list); 339 INIT_LIST_HEAD(&tp->list);
@@ -361,7 +361,7 @@ static void free_trace_probe(struct trace_probe *tp)
361 for (i = 0; i < tp->nr_args; i++) 361 for (i = 0; i < tp->nr_args; i++)
362 free_probe_arg(&tp->args[i]); 362 free_probe_arg(&tp->args[i]);
363 363
364 kfree(tp->call.system); 364 kfree(tp->call.class->system);
365 kfree(tp->call.name); 365 kfree(tp->call.name);
366 kfree(tp->symbol); 366 kfree(tp->symbol);
367 kfree(tp); 367 kfree(tp);
@@ -374,7 +374,7 @@ static struct trace_probe *find_probe_event(const char *event,
374 374
375 list_for_each_entry(tp, &probe_list, list) 375 list_for_each_entry(tp, &probe_list, list)
376 if (strcmp(tp->call.name, event) == 0 && 376 if (strcmp(tp->call.name, event) == 0 &&
377 strcmp(tp->call.system, group) == 0) 377 strcmp(tp->call.class->system, group) == 0)
378 return tp; 378 return tp;
379 return NULL; 379 return NULL;
380} 380}
@@ -399,7 +399,7 @@ static int register_trace_probe(struct trace_probe *tp)
399 mutex_lock(&probe_lock); 399 mutex_lock(&probe_lock);
400 400
401 /* register as an event */ 401 /* register as an event */
402 old_tp = find_probe_event(tp->call.name, tp->call.system); 402 old_tp = find_probe_event(tp->call.name, tp->call.class->system);
403 if (old_tp) { 403 if (old_tp) {
404 /* delete old event */ 404 /* delete old event */
405 unregister_trace_probe(old_tp); 405 unregister_trace_probe(old_tp);
@@ -798,7 +798,7 @@ static int probes_seq_show(struct seq_file *m, void *v)
798 char buf[MAX_ARGSTR_LEN + 1]; 798 char buf[MAX_ARGSTR_LEN + 1];
799 799
800 seq_printf(m, "%c", probe_is_return(tp) ? 'r' : 'p'); 800 seq_printf(m, "%c", probe_is_return(tp) ? 'r' : 'p');
801 seq_printf(m, ":%s/%s", tp->call.system, tp->call.name); 801 seq_printf(m, ":%s/%s", tp->call.class->system, tp->call.name);
802 802
803 if (!tp->symbol) 803 if (!tp->symbol)
804 seq_printf(m, " 0x%p", tp->rp.kp.addr); 804 seq_printf(m, " 0x%p", tp->rp.kp.addr);
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 4d6d711717f2..d036a74a64f3 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -15,6 +15,10 @@ static int sys_refcount_exit;
15static DECLARE_BITMAP(enabled_enter_syscalls, NR_syscalls); 15static DECLARE_BITMAP(enabled_enter_syscalls, NR_syscalls);
16static DECLARE_BITMAP(enabled_exit_syscalls, NR_syscalls); 16static DECLARE_BITMAP(enabled_exit_syscalls, NR_syscalls);
17 17
18struct ftrace_event_class event_class_syscalls = {
19 .system = "syscalls"
20};
21
18extern unsigned long __start_syscalls_metadata[]; 22extern unsigned long __start_syscalls_metadata[];
19extern unsigned long __stop_syscalls_metadata[]; 23extern unsigned long __stop_syscalls_metadata[];
20 24