55a25c933d159d5a289265e604d608d96277e63c
[linux-2.6.git] / kernel / trace / trace_event_profile.c
1 /*
2  * trace event based perf counter profiling
3  *
4  * Copyright (C) 2009 Red Hat Inc, Peter Zijlstra <pzijlstr@redhat.com>
5  *
6  */
7
8 #include <linux/module.h>
9 #include "trace.h"
10
11 int ftrace_profile_enable(int event_id)
12 {
13         struct ftrace_event_call *event;
14         int ret = -EINVAL;
15
16         mutex_lock(&event_mutex);
17         list_for_each_entry(event, &ftrace_events, list) {
18                 if (event->id == event_id && event->profile_enable &&
19                     try_module_get(event->mod)) {
20                         ret = event->profile_enable(event);
21                         break;
22                 }
23         }
24         mutex_unlock(&event_mutex);
25
26         return ret;
27 }
28
29 void ftrace_profile_disable(int event_id)
30 {
31         struct ftrace_event_call *event;
32
33         mutex_lock(&event_mutex);
34         list_for_each_entry(event, &ftrace_events, list) {
35                 if (event->id == event_id) {
36                         event->profile_disable(event);
37                         module_put(event->mod);
38                         break;
39                 }
40         }
41         mutex_unlock(&event_mutex);
42 }