|
@@ -8,6 +8,14 @@
|
|
#include <linux/module.h>
|
|
#include <linux/module.h>
|
|
#include "trace.h"
|
|
#include "trace.h"
|
|
|
|
|
|
|
|
+static int ftrace_profile_enable_event(struct ftrace_event_call *event)
|
|
|
|
+{
|
|
|
|
+ if (atomic_inc_return(&event->profile_count))
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+ return event->profile_enable();
|
|
|
|
+}
|
|
|
|
+
|
|
int ftrace_profile_enable(int event_id)
|
|
int ftrace_profile_enable(int event_id)
|
|
{
|
|
{
|
|
struct ftrace_event_call *event;
|
|
struct ftrace_event_call *event;
|
|
@@ -17,7 +25,7 @@ int ftrace_profile_enable(int event_id)
|
|
list_for_each_entry(event, &ftrace_events, list) {
|
|
list_for_each_entry(event, &ftrace_events, list) {
|
|
if (event->id == event_id && event->profile_enable &&
|
|
if (event->id == event_id && event->profile_enable &&
|
|
try_module_get(event->mod)) {
|
|
try_module_get(event->mod)) {
|
|
- ret = event->profile_enable(event);
|
|
|
|
|
|
+ ret = ftrace_profile_enable_event(event);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -26,6 +34,14 @@ int ftrace_profile_enable(int event_id)
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static void ftrace_profile_disable_event(struct ftrace_event_call *event)
|
|
|
|
+{
|
|
|
|
+ if (!atomic_add_negative(-1, &event->profile_count))
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ event->profile_disable();
|
|
|
|
+}
|
|
|
|
+
|
|
void ftrace_profile_disable(int event_id)
|
|
void ftrace_profile_disable(int event_id)
|
|
{
|
|
{
|
|
struct ftrace_event_call *event;
|
|
struct ftrace_event_call *event;
|
|
@@ -33,7 +49,7 @@ void ftrace_profile_disable(int event_id)
|
|
mutex_lock(&event_mutex);
|
|
mutex_lock(&event_mutex);
|
|
list_for_each_entry(event, &ftrace_events, list) {
|
|
list_for_each_entry(event, &ftrace_events, list) {
|
|
if (event->id == event_id) {
|
|
if (event->id == event_id) {
|
|
- event->profile_disable(event);
|
|
|
|
|
|
+ ftrace_profile_disable_event(event);
|
|
module_put(event->mod);
|
|
module_put(event->mod);
|
|
break;
|
|
break;
|
|
}
|
|
}
|