aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_event_profile.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-09-17 18:54:43 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2009-09-18 00:14:32 -0400
commite5e25cf47b0bdd1f7e9b8bb6368ee48e16de0c87 (patch)
tree043e6215359853812130324a24e3d03511b41e2b /kernel/trace/trace_event_profile.c
parent0efb4d20723d58edbad29d1ff98a86b631adb5e6 (diff)
tracing: Factorize the events profile accounting
Factorize the events enabling accounting in a common tracing core helper. This reduces the size of the profile_enable() and profile_disable() callbacks for each trace events. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Acked-by: Steven Rostedt <rostedt@goodmis.org> Acked-by: Li Zefan <lizf@cn.fujitsu.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Jason Baron <jbaron@redhat.com> Cc: Masami Hiramatsu <mhiramat@redhat.com> Cc: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace_event_profile.c')
-rw-r--r--kernel/trace/trace_event_profile.c20
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
11static 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
11int ftrace_profile_enable(int event_id) 19int 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
37static 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
29void ftrace_profile_disable(int event_id) 45void 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 }