aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/ftrace_event.h2
-rw-r--r--include/linux/syscalls.h18
-rw-r--r--include/trace/ftrace.h45
-rw-r--r--kernel/trace/trace_events.c6
-rw-r--r--kernel/trace/trace_kprobe.c14
-rw-r--r--kernel/trace/trace_syscalls.c8
6 files changed, 41 insertions, 52 deletions
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index 4f77932b0983..b1a007d6e8fd 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -148,7 +148,7 @@ struct ftrace_event_call {
148 struct ftrace_event_class *class; 148 struct ftrace_event_class *class;
149 char *name; 149 char *name;
150 struct dentry *dir; 150 struct dentry *dir;
151 struct trace_event *event; 151 struct trace_event event;
152 int enabled; 152 int enabled;
153 int id; 153 int id;
154 const char *print_fmt; 154 const char *print_fmt;
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index f7256770a20f..a1a86a53bc73 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -120,24 +120,20 @@ struct perf_event_attr;
120 120
121extern struct ftrace_event_class event_class_syscall_enter; 121extern struct ftrace_event_class event_class_syscall_enter;
122extern struct ftrace_event_class event_class_syscall_exit; 122extern struct ftrace_event_class event_class_syscall_exit;
123extern struct trace_event_functions enter_syscall_print_funcs;
124extern struct trace_event_functions exit_syscall_print_funcs;
123 125
124#define SYSCALL_TRACE_ENTER_EVENT(sname) \ 126#define SYSCALL_TRACE_ENTER_EVENT(sname) \
125 static struct syscall_metadata __syscall_meta_##sname; \ 127 static struct syscall_metadata __syscall_meta_##sname; \
126 static struct ftrace_event_call \ 128 static struct ftrace_event_call \
127 __attribute__((__aligned__(4))) event_enter_##sname; \ 129 __attribute__((__aligned__(4))) event_enter_##sname; \
128 static struct trace_event_functions enter_syscall_print_funcs_##sname = { \
129 .trace = print_syscall_enter, \
130 }; \
131 static struct trace_event enter_syscall_print_##sname = { \
132 .funcs = &enter_syscall_print_funcs_##sname, \
133 }; \
134 static struct ftrace_event_call __used \ 130 static struct ftrace_event_call __used \
135 __attribute__((__aligned__(4))) \ 131 __attribute__((__aligned__(4))) \
136 __attribute__((section("_ftrace_events"))) \ 132 __attribute__((section("_ftrace_events"))) \
137 event_enter_##sname = { \ 133 event_enter_##sname = { \
138 .name = "sys_enter"#sname, \ 134 .name = "sys_enter"#sname, \
139 .class = &event_class_syscall_enter, \ 135 .class = &event_class_syscall_enter, \
140 .event = &enter_syscall_print_##sname, \ 136 .event.funcs = &enter_syscall_print_funcs, \
141 .data = (void *)&__syscall_meta_##sname,\ 137 .data = (void *)&__syscall_meta_##sname,\
142 } 138 }
143 139
@@ -145,19 +141,13 @@ extern struct ftrace_event_class event_class_syscall_exit;
145 static struct syscall_metadata __syscall_meta_##sname; \ 141 static struct syscall_metadata __syscall_meta_##sname; \
146 static struct ftrace_event_call \ 142 static struct ftrace_event_call \
147 __attribute__((__aligned__(4))) event_exit_##sname; \ 143 __attribute__((__aligned__(4))) event_exit_##sname; \
148 static struct trace_event_functions exit_syscall_print_funcs_##sname = { \
149 .trace = print_syscall_exit, \
150 }; \
151 static struct trace_event exit_syscall_print_##sname = { \
152 .funcs = &exit_syscall_print_funcs_##sname, \
153 }; \
154 static struct ftrace_event_call __used \ 144 static struct ftrace_event_call __used \
155 __attribute__((__aligned__(4))) \ 145 __attribute__((__aligned__(4))) \
156 __attribute__((section("_ftrace_events"))) \ 146 __attribute__((section("_ftrace_events"))) \
157 event_exit_##sname = { \ 147 event_exit_##sname = { \
158 .name = "sys_exit"#sname, \ 148 .name = "sys_exit"#sname, \
159 .class = &event_class_syscall_exit, \ 149 .class = &event_class_syscall_exit, \
160 .event = &exit_syscall_print_##sname, \ 150 .event.funcs = &exit_syscall_print_funcs, \
161 .data = (void *)&__syscall_meta_##sname,\ 151 .data = (void *)&__syscall_meta_##sname,\
162 } 152 }
163 153
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 51ed7f3568a5..824141d5cf04 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -206,18 +206,22 @@
206#undef DECLARE_EVENT_CLASS 206#undef DECLARE_EVENT_CLASS
207#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ 207#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
208static notrace enum print_line_t \ 208static notrace enum print_line_t \
209ftrace_raw_output_id_##call(int event_id, const char *name, \ 209ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \
210 struct trace_iterator *iter, int flags) \ 210 struct trace_event *trace_event) \
211{ \ 211{ \
212 struct ftrace_event_call *event; \
212 struct trace_seq *s = &iter->seq; \ 213 struct trace_seq *s = &iter->seq; \
213 struct ftrace_raw_##call *field; \ 214 struct ftrace_raw_##call *field; \
214 struct trace_entry *entry; \ 215 struct trace_entry *entry; \
215 struct trace_seq *p; \ 216 struct trace_seq *p; \
216 int ret; \ 217 int ret; \
217 \ 218 \
219 event = container_of(trace_event, struct ftrace_event_call, \
220 event); \
221 \
218 entry = iter->ent; \ 222 entry = iter->ent; \
219 \ 223 \
220 if (entry->type != event_id) { \ 224 if (entry->type != event->id) { \
221 WARN_ON_ONCE(1); \ 225 WARN_ON_ONCE(1); \
222 return TRACE_TYPE_UNHANDLED; \ 226 return TRACE_TYPE_UNHANDLED; \
223 } \ 227 } \
@@ -226,7 +230,7 @@ ftrace_raw_output_id_##call(int event_id, const char *name, \
226 \ 230 \
227 p = &get_cpu_var(ftrace_event_seq); \ 231 p = &get_cpu_var(ftrace_event_seq); \
228 trace_seq_init(p); \ 232 trace_seq_init(p); \
229 ret = trace_seq_printf(s, "%s: ", name); \ 233 ret = trace_seq_printf(s, "%s: ", event->name); \
230 if (ret) \ 234 if (ret) \
231 ret = trace_seq_printf(s, print); \ 235 ret = trace_seq_printf(s, print); \
232 put_cpu(); \ 236 put_cpu(); \
@@ -234,17 +238,10 @@ ftrace_raw_output_id_##call(int event_id, const char *name, \
234 return TRACE_TYPE_PARTIAL_LINE; \ 238 return TRACE_TYPE_PARTIAL_LINE; \
235 \ 239 \
236 return TRACE_TYPE_HANDLED; \ 240 return TRACE_TYPE_HANDLED; \
237} 241} \
238 242static struct trace_event_functions ftrace_event_type_funcs_##call = { \
239#undef DEFINE_EVENT 243 .trace = ftrace_raw_output_##call, \
240#define DEFINE_EVENT(template, name, proto, args) \ 244};
241static notrace enum print_line_t \
242ftrace_raw_output_##name(struct trace_iterator *iter, int flags, \
243 struct trace_event *event) \
244{ \
245 return ftrace_raw_output_id_##template(event_##name.id, \
246 #name, iter, flags); \
247}
248 245
249#undef DEFINE_EVENT_PRINT 246#undef DEFINE_EVENT_PRINT
250#define DEFINE_EVENT_PRINT(template, call, proto, args, print) \ 247#define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
@@ -277,7 +274,10 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \
277 return TRACE_TYPE_PARTIAL_LINE; \ 274 return TRACE_TYPE_PARTIAL_LINE; \
278 \ 275 \
279 return TRACE_TYPE_HANDLED; \ 276 return TRACE_TYPE_HANDLED; \
280} 277} \
278static struct trace_event_functions ftrace_event_type_funcs_##call = { \
279 .trace = ftrace_raw_output_##call, \
280};
281 281
282#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) 282#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
283 283
@@ -533,20 +533,13 @@ ftrace_raw_event_##call(void *__data, proto) \
533 533
534#undef DEFINE_EVENT 534#undef DEFINE_EVENT
535#define DEFINE_EVENT(template, call, proto, args) \ 535#define DEFINE_EVENT(template, call, proto, args) \
536static struct trace_event_functions ftrace_event_type_funcs_##call = { \
537 .trace = ftrace_raw_output_##call, \
538}; \
539static struct trace_event ftrace_event_type_##call = { \
540 .funcs = &ftrace_event_type_funcs_##call, \
541}; \
542static inline void ftrace_test_probe_##call(void) \ 536static inline void ftrace_test_probe_##call(void) \
543{ \ 537{ \
544 check_trace_callback_type_##call(ftrace_raw_event_##template); \ 538 check_trace_callback_type_##call(ftrace_raw_event_##template); \
545} 539}
546 540
547#undef DEFINE_EVENT_PRINT 541#undef DEFINE_EVENT_PRINT
548#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ 542#define DEFINE_EVENT_PRINT(template, name, proto, args, print)
549 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
550 543
551#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) 544#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
552 545
@@ -582,7 +575,7 @@ __attribute__((__aligned__(4))) \
582__attribute__((section("_ftrace_events"))) event_##call = { \ 575__attribute__((section("_ftrace_events"))) event_##call = { \
583 .name = #call, \ 576 .name = #call, \
584 .class = &event_class_##template, \ 577 .class = &event_class_##template, \
585 .event = &ftrace_event_type_##call, \ 578 .event.funcs = &ftrace_event_type_funcs_##template, \
586 .print_fmt = print_fmt_##template, \ 579 .print_fmt = print_fmt_##template, \
587}; 580};
588 581
@@ -596,7 +589,7 @@ __attribute__((__aligned__(4))) \
596__attribute__((section("_ftrace_events"))) event_##call = { \ 589__attribute__((section("_ftrace_events"))) event_##call = { \
597 .name = #call, \ 590 .name = #call, \
598 .class = &event_class_##template, \ 591 .class = &event_class_##template, \
599 .event = &ftrace_event_type_##call, \ 592 .event.funcs = &ftrace_event_type_funcs_##call, \
600 .print_fmt = print_fmt_##call, \ 593 .print_fmt = print_fmt_##call, \
601} 594}
602 595
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 8e94255a45e7..aafe5bff8f59 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -122,7 +122,7 @@ int trace_event_raw_init(struct ftrace_event_call *call)
122{ 122{
123 int id; 123 int id;
124 124
125 id = register_ftrace_event(call->event); 125 id = register_ftrace_event(&call->event);
126 if (!id) 126 if (!id)
127 return -ENODEV; 127 return -ENODEV;
128 call->id = id; 128 call->id = id;
@@ -1073,8 +1073,8 @@ static void remove_subsystem_dir(const char *name)
1073static void __trace_remove_event_call(struct ftrace_event_call *call) 1073static void __trace_remove_event_call(struct ftrace_event_call *call)
1074{ 1074{
1075 ftrace_event_enable_disable(call, 0); 1075 ftrace_event_enable_disable(call, 0);
1076 if (call->event) 1076 if (call->event.funcs)
1077 __unregister_ftrace_event(call->event); 1077 __unregister_ftrace_event(&call->event);
1078 debugfs_remove_recursive(call->dir); 1078 debugfs_remove_recursive(call->dir);
1079 list_del(&call->list); 1079 list_del(&call->list);
1080 trace_destroy_fields(call); 1080 trace_destroy_fields(call);
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index b989ae229a20..d8061c3e02c9 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -204,7 +204,6 @@ struct trace_probe {
204 const char *symbol; /* symbol name */ 204 const char *symbol; /* symbol name */
205 struct ftrace_event_class class; 205 struct ftrace_event_class class;
206 struct ftrace_event_call call; 206 struct ftrace_event_call call;
207 struct trace_event event;
208 unsigned int nr_args; 207 unsigned int nr_args;
209 struct probe_arg args[]; 208 struct probe_arg args[];
210}; 209};
@@ -1020,7 +1019,7 @@ print_kprobe_event(struct trace_iterator *iter, int flags,
1020 int i; 1019 int i;
1021 1020
1022 field = (struct kprobe_trace_entry *)iter->ent; 1021 field = (struct kprobe_trace_entry *)iter->ent;
1023 tp = container_of(event, struct trace_probe, event); 1022 tp = container_of(event, struct trace_probe, call.event);
1024 1023
1025 if (!trace_seq_printf(s, "%s: (", tp->call.name)) 1024 if (!trace_seq_printf(s, "%s: (", tp->call.name))
1026 goto partial; 1025 goto partial;
@@ -1054,7 +1053,7 @@ print_kretprobe_event(struct trace_iterator *iter, int flags,
1054 int i; 1053 int i;
1055 1054
1056 field = (struct kretprobe_trace_entry *)iter->ent; 1055 field = (struct kretprobe_trace_entry *)iter->ent;
1057 tp = container_of(event, struct trace_probe, event); 1056 tp = container_of(event, struct trace_probe, call.event);
1058 1057
1059 if (!trace_seq_printf(s, "%s: (", tp->call.name)) 1058 if (!trace_seq_printf(s, "%s: (", tp->call.name))
1060 goto partial; 1059 goto partial;
@@ -1364,20 +1363,19 @@ static int register_probe_event(struct trace_probe *tp)
1364 1363
1365 /* Initialize ftrace_event_call */ 1364 /* Initialize ftrace_event_call */
1366 if (probe_is_return(tp)) { 1365 if (probe_is_return(tp)) {
1367 tp->event.funcs = &kretprobe_funcs;
1368 INIT_LIST_HEAD(&call->class->fields); 1366 INIT_LIST_HEAD(&call->class->fields);
1367 call->event.funcs = &kretprobe_funcs;
1369 call->class->raw_init = probe_event_raw_init; 1368 call->class->raw_init = probe_event_raw_init;
1370 call->class->define_fields = kretprobe_event_define_fields; 1369 call->class->define_fields = kretprobe_event_define_fields;
1371 } else { 1370 } else {
1372 INIT_LIST_HEAD(&call->class->fields); 1371 INIT_LIST_HEAD(&call->class->fields);
1373 tp->event.funcs = &kprobe_funcs; 1372 call->event.funcs = &kprobe_funcs;
1374 call->class->raw_init = probe_event_raw_init; 1373 call->class->raw_init = probe_event_raw_init;
1375 call->class->define_fields = kprobe_event_define_fields; 1374 call->class->define_fields = kprobe_event_define_fields;
1376 } 1375 }
1377 if (set_print_fmt(tp) < 0) 1376 if (set_print_fmt(tp) < 0)
1378 return -ENOMEM; 1377 return -ENOMEM;
1379 call->event = &tp->event; 1378 call->id = register_ftrace_event(&call->event);
1380 call->id = register_ftrace_event(&tp->event);
1381 if (!call->id) { 1379 if (!call->id) {
1382 kfree(call->print_fmt); 1380 kfree(call->print_fmt);
1383 return -ENODEV; 1381 return -ENODEV;
@@ -1389,7 +1387,7 @@ static int register_probe_event(struct trace_probe *tp)
1389 if (ret) { 1387 if (ret) {
1390 pr_info("Failed to register kprobe event: %s\n", call->name); 1388 pr_info("Failed to register kprobe event: %s\n", call->name);
1391 kfree(call->print_fmt); 1389 kfree(call->print_fmt);
1392 unregister_ftrace_event(&tp->event); 1390 unregister_ftrace_event(&call->event);
1393 } 1391 }
1394 return ret; 1392 return ret;
1395} 1393}
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 3751c81998cb..7c7cfe95a853 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -39,6 +39,14 @@ syscall_get_exit_fields(struct ftrace_event_call *call)
39 return &entry->exit_fields; 39 return &entry->exit_fields;
40} 40}
41 41
42struct trace_event_functions enter_syscall_print_funcs = {
43 .trace = print_syscall_enter,
44};
45
46struct trace_event_functions exit_syscall_print_funcs = {
47 .trace = print_syscall_exit,
48};
49
42struct ftrace_event_class event_class_syscall_enter = { 50struct ftrace_event_class event_class_syscall_enter = {
43 .system = "syscalls", 51 .system = "syscalls",
44 .reg = syscall_enter_register, 52 .reg = syscall_enter_register,