diff options
-rw-r--r-- | include/linux/ftrace_event.h | 4 | ||||
-rw-r--r-- | include/linux/syscalls.h | 24 | ||||
-rw-r--r-- | include/trace/ftrace.h | 28 | ||||
-rw-r--r-- | kernel/trace/trace_event_profile.c | 20 |
4 files changed, 36 insertions, 40 deletions
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h index bd099ba82ccc..bc103d7b1ca8 100644 --- a/include/linux/ftrace_event.h +++ b/include/linux/ftrace_event.h | |||
@@ -130,8 +130,8 @@ struct ftrace_event_call { | |||
130 | void *data; | 130 | void *data; |
131 | 131 | ||
132 | atomic_t profile_count; | 132 | atomic_t profile_count; |
133 | int (*profile_enable)(struct ftrace_event_call *); | 133 | int (*profile_enable)(void); |
134 | void (*profile_disable)(struct ftrace_event_call *); | 134 | void (*profile_disable)(void); |
135 | }; | 135 | }; |
136 | 136 | ||
137 | #define MAX_FILTER_PRED 32 | 137 | #define MAX_FILTER_PRED 32 |
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index a8e37821cc60..7d9803cbb20f 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h | |||
@@ -100,33 +100,25 @@ struct perf_counter_attr; | |||
100 | 100 | ||
101 | #ifdef CONFIG_EVENT_PROFILE | 101 | #ifdef CONFIG_EVENT_PROFILE |
102 | #define TRACE_SYS_ENTER_PROFILE(sname) \ | 102 | #define TRACE_SYS_ENTER_PROFILE(sname) \ |
103 | static int prof_sysenter_enable_##sname(struct ftrace_event_call *event_call) \ | 103 | static int prof_sysenter_enable_##sname(void) \ |
104 | { \ | 104 | { \ |
105 | int ret = 0; \ | 105 | return reg_prof_syscall_enter("sys"#sname); \ |
106 | if (!atomic_inc_return(&event_enter_##sname.profile_count)) \ | ||
107 | ret = reg_prof_syscall_enter("sys"#sname); \ | ||
108 | return ret; \ | ||
109 | } \ | 106 | } \ |
110 | \ | 107 | \ |
111 | static void prof_sysenter_disable_##sname(struct ftrace_event_call *event_call)\ | 108 | static void prof_sysenter_disable_##sname(void) \ |
112 | { \ | 109 | { \ |
113 | if (atomic_add_negative(-1, &event_enter_##sname.profile_count)) \ | 110 | unreg_prof_syscall_enter("sys"#sname); \ |
114 | unreg_prof_syscall_enter("sys"#sname); \ | ||
115 | } | 111 | } |
116 | 112 | ||
117 | #define TRACE_SYS_EXIT_PROFILE(sname) \ | 113 | #define TRACE_SYS_EXIT_PROFILE(sname) \ |
118 | static int prof_sysexit_enable_##sname(struct ftrace_event_call *event_call) \ | 114 | static int prof_sysexit_enable_##sname(void) \ |
119 | { \ | 115 | { \ |
120 | int ret = 0; \ | 116 | return reg_prof_syscall_exit("sys"#sname); \ |
121 | if (!atomic_inc_return(&event_exit_##sname.profile_count)) \ | ||
122 | ret = reg_prof_syscall_exit("sys"#sname); \ | ||
123 | return ret; \ | ||
124 | } \ | 117 | } \ |
125 | \ | 118 | \ |
126 | static void prof_sysexit_disable_##sname(struct ftrace_event_call *event_call) \ | 119 | static void prof_sysexit_disable_##sname(void) \ |
127 | { \ | 120 | { \ |
128 | if (atomic_add_negative(-1, &event_exit_##sname.profile_count)) \ | 121 | unreg_prof_syscall_exit("sys"#sname); \ |
129 | unreg_prof_syscall_exit("sys"#sname); \ | ||
130 | } | 122 | } |
131 | 123 | ||
132 | #define TRACE_SYS_ENTER_PROFILE_INIT(sname) \ | 124 | #define TRACE_SYS_ENTER_PROFILE_INIT(sname) \ |
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h index 72a3b437b829..a822087857e9 100644 --- a/include/trace/ftrace.h +++ b/include/trace/ftrace.h | |||
@@ -382,20 +382,14 @@ static inline int ftrace_get_offsets_##call( \ | |||
382 | * | 382 | * |
383 | * NOTE: The insertion profile callback (ftrace_profile_<call>) is defined later | 383 | * NOTE: The insertion profile callback (ftrace_profile_<call>) is defined later |
384 | * | 384 | * |
385 | * static int ftrace_profile_enable_<call>(struct ftrace_event_call *event_call) | 385 | * static int ftrace_profile_enable_<call>(void) |
386 | * { | 386 | * { |
387 | * int ret = 0; | 387 | * return register_trace_<call>(ftrace_profile_<call>); |
388 | * | ||
389 | * if (!atomic_inc_return(&event_call->profile_count)) | ||
390 | * ret = register_trace_<call>(ftrace_profile_<call>); | ||
391 | * | ||
392 | * return ret; | ||
393 | * } | 388 | * } |
394 | * | 389 | * |
395 | * static void ftrace_profile_disable_<call>(struct ftrace_event_call *event_call) | 390 | * static void ftrace_profile_disable_<call>(void) |
396 | * { | 391 | * { |
397 | * if (atomic_add_negative(-1, &event->call->profile_count)) | 392 | * unregister_trace_<call>(ftrace_profile_<call>); |
398 | * unregister_trace_<call>(ftrace_profile_<call>); | ||
399 | * } | 393 | * } |
400 | * | 394 | * |
401 | */ | 395 | */ |
@@ -405,20 +399,14 @@ static inline int ftrace_get_offsets_##call( \ | |||
405 | \ | 399 | \ |
406 | static void ftrace_profile_##call(proto); \ | 400 | static void ftrace_profile_##call(proto); \ |
407 | \ | 401 | \ |
408 | static int ftrace_profile_enable_##call(struct ftrace_event_call *event_call) \ | 402 | static int ftrace_profile_enable_##call(void) \ |
409 | { \ | 403 | { \ |
410 | int ret = 0; \ | 404 | return register_trace_##call(ftrace_profile_##call); \ |
411 | \ | ||
412 | if (!atomic_inc_return(&event_call->profile_count)) \ | ||
413 | ret = register_trace_##call(ftrace_profile_##call); \ | ||
414 | \ | ||
415 | return ret; \ | ||
416 | } \ | 405 | } \ |
417 | \ | 406 | \ |
418 | static void ftrace_profile_disable_##call(struct ftrace_event_call *event_call)\ | 407 | static void ftrace_profile_disable_##call(void) \ |
419 | { \ | 408 | { \ |
420 | if (atomic_add_negative(-1, &event_call->profile_count)) \ | 409 | unregister_trace_##call(ftrace_profile_##call); \ |
421 | unregister_trace_##call(ftrace_profile_##call); \ | ||
422 | } | 410 | } |
423 | 411 | ||
424 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | 412 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
diff --git a/kernel/trace/trace_event_profile.c b/kernel/trace/trace_event_profile.c index 55a25c933d15..df4a74efd50c 100644 --- a/kernel/trace/trace_event_profile.c +++ b/kernel/trace/trace_event_profile.c | |||
@@ -8,6 +8,14 @@ | |||
8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
9 | #include "trace.h" | 9 | #include "trace.h" |
10 | 10 | ||
11 | static int ftrace_profile_enable_event(struct ftrace_event_call *event) | ||
12 | { | ||
13 | if (atomic_inc_return(&event->profile_count)) | ||
14 | return 0; | ||
15 | |||
16 | return event->profile_enable(); | ||
17 | } | ||
18 | |||
11 | int ftrace_profile_enable(int event_id) | 19 | int ftrace_profile_enable(int event_id) |
12 | { | 20 | { |
13 | struct ftrace_event_call *event; | 21 | struct ftrace_event_call *event; |
@@ -17,7 +25,7 @@ int ftrace_profile_enable(int event_id) | |||
17 | list_for_each_entry(event, &ftrace_events, list) { | 25 | list_for_each_entry(event, &ftrace_events, list) { |
18 | if (event->id == event_id && event->profile_enable && | 26 | if (event->id == event_id && event->profile_enable && |
19 | try_module_get(event->mod)) { | 27 | try_module_get(event->mod)) { |
20 | ret = event->profile_enable(event); | 28 | ret = ftrace_profile_enable_event(event); |
21 | break; | 29 | break; |
22 | } | 30 | } |
23 | } | 31 | } |
@@ -26,6 +34,14 @@ int ftrace_profile_enable(int event_id) | |||
26 | return ret; | 34 | return ret; |
27 | } | 35 | } |
28 | 36 | ||
37 | static void ftrace_profile_disable_event(struct ftrace_event_call *event) | ||
38 | { | ||
39 | if (!atomic_add_negative(-1, &event->profile_count)) | ||
40 | return; | ||
41 | |||
42 | event->profile_disable(); | ||
43 | } | ||
44 | |||
29 | void ftrace_profile_disable(int event_id) | 45 | void ftrace_profile_disable(int event_id) |
30 | { | 46 | { |
31 | struct ftrace_event_call *event; | 47 | struct ftrace_event_call *event; |
@@ -33,7 +49,7 @@ void ftrace_profile_disable(int event_id) | |||
33 | mutex_lock(&event_mutex); | 49 | mutex_lock(&event_mutex); |
34 | list_for_each_entry(event, &ftrace_events, list) { | 50 | list_for_each_entry(event, &ftrace_events, list) { |
35 | if (event->id == event_id) { | 51 | if (event->id == event_id) { |
36 | event->profile_disable(event); | 52 | ftrace_profile_disable_event(event); |
37 | module_put(event->mod); | 53 | module_put(event->mod); |
38 | break; | 54 | break; |
39 | } | 55 | } |