diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace_event_profile.c | 20 |
1 files changed, 18 insertions, 2 deletions
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 | } |