On 07/02, Oleg Nesterov wrote:
>
> So please ignore modules ;)

Or lets discuss the change above.

Oleg.

--- x/kernel/trace/trace_events.c
+++ x/kernel/trace/trace_events.c
@@ -1611,14 +1611,40 @@ static void __trace_remove_event_call(st
        destroy_preds(call);
 }
 
+static int event_can_remove(struct ftrace_event_call *call)
+{
+       struct trace_array *tr;
+       struct ftrace_event_file *file;
+
+#ifdef CONFIG_PERF_EVENTS
+       if (call->perf_refcount)
+               return -EBUSY;
+#endif
+       do_for_each_event_file(tr, file) {
+               if (file->event_call != call)
+                       continue;
+               if (file->flags & FTRACE_EVENT_FL_ENABLED)
+                       return -EBUSY;
+               break;
+       } while_for_each_event_file();
+
+       return 0;
+}
+
 /* Remove an event_call */
-void trace_remove_event_call(struct ftrace_event_call *call)
+int trace_remove_event_call(struct ftrace_event_call *call)
 {
+       int err;
+
        mutex_lock(&event_mutex);
        down_write(&trace_event_sem);
-       __trace_remove_event_call(call);
+       err = event_can_remove(call);
+       if (!err)
+               __trace_remove_event_call(call);
        up_write(&trace_event_sem);
        mutex_unlock(&event_mutex);
+
+       return err;
 }
 
 #define for_each_event(event, start, end)                      \

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to