]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ftrace: ensure every event gets an id
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Thu, 19 Mar 2009 19:26:14 +0000 (20:26 +0100)
committerIngo Molnar <mingo@elte.hu>
Fri, 20 Mar 2009 09:17:06 +0000 (10:17 +0100)
Impact: widen user-space visibe event IDs to all events

Previously only TRACE_EVENT events got ids, because only they
generated raw output which needs to be demuxed from the trace.

In order to provide a unique ID for each event, register everybody,
regardless.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <20090319194233.464914218@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/trace/trace_events_stage_3.h
kernel/trace/trace_output.c

index ae2e323df0c7bb8a68efc07d767de008b177709a..4c26d97b450836515b3978da1d2a80f9e82962e7 100644 (file)
@@ -130,7 +130,19 @@ static void ftrace_unreg_event_##call(void)                                \
 {                                                                      \
        unregister_trace_##call(ftrace_event_##call);                   \
 }                                                                      \
-
+                                                                       \
+static struct ftrace_event_call event_##call;                          \
+                                                                       \
+static int ftrace_init_event_##call(void)                              \
+{                                                                      \
+       int id;                                                         \
+                                                                       \
+       id = register_ftrace_event(NULL);                               \
+       if (!id)                                                        \
+               return -ENODEV;                                         \
+       event_##call.id = id;                                           \
+       return 0;                                                       \
+}
 
 #undef TRACE_FORMAT
 #define TRACE_FORMAT(call, proto, args, fmt)                           \
@@ -140,6 +152,7 @@ __attribute__((__aligned__(4)))                                             \
 __attribute__((section("_ftrace_events"))) event_##call = {            \
        .name                   = #call,                                \
        .system                 = __stringify(TRACE_SYSTEM),            \
+       .raw_init               = ftrace_init_event_##call,             \
        .regfunc                = ftrace_reg_event_##call,              \
        .unregfunc              = ftrace_unreg_event_##call,            \
 }
index b45141748af51b255755e42a2a0d3ec74afbd2bd..19261fdd245581c42f1912b50febc03f5b9164a9 100644 (file)
@@ -481,6 +481,11 @@ int register_ftrace_event(struct trace_event *event)
 
        mutex_lock(&trace_event_mutex);
 
+       if (!event) {
+               ret = next_event_type++;
+               goto out;
+       }
+
        if (!event->type)
                event->type = next_event_type++;
        else if (event->type > __TRACE_LAST_TYPE) {