ftrace: Fix perf-tracepoint OOPS
authorPeter Zijlstra <peterz@infradead.org>
Wed, 5 Aug 2009 18:41:04 +0000 (20:41 +0200)
committerIngo Molnar <mingo@elte.hu>
Thu, 6 Aug 2009 04:26:09 +0000 (06:26 +0200)
Not all tracepoints are created equal, in specific the ftrace
tracepoints are created with TRACE_EVENT_FORMAT() which does
not generate the needed bits to tie them into perf counters.

For those events, don't create the 'id' file and fail
->profile_enable when their ID is specified through other
means.

Reported-by: Chris Mason <chris.mason@oracle.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <1249497664.5890.4.camel@laptop>
[ v2: fix build error in the !CONFIG_EVENT_PROFILE case ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
include/linux/ftrace_event.h
kernel/trace/trace_event_profile.c
kernel/trace/trace_events.c

index 5c093ffc655bfd36c1579f539d5520a0ded30c15..d7cd193c2277a1191e16f5d5fcd93d5ee9a2b6d5 100644 (file)
@@ -119,11 +119,9 @@ struct ftrace_event_call {
        void                    *filter;
        void                    *mod;
 
-#ifdef CONFIG_EVENT_PROFILE
-       atomic_t        profile_count;
-       int             (*profile_enable)(struct ftrace_event_call *);
-       void            (*profile_disable)(struct ftrace_event_call *);
-#endif
+       atomic_t                profile_count;
+       int                     (*profile_enable)(struct ftrace_event_call *);
+       void                    (*profile_disable)(struct ftrace_event_call *);
 };
 
 #define MAX_FILTER_PRED                32
index 5b5895afecfe425f5c917af29b13d29ff4acf918..11ba5bb4ed0a71f0c3da5e8a2ce73471456aec47 100644 (file)
@@ -14,7 +14,7 @@ int ftrace_profile_enable(int event_id)
 
        mutex_lock(&event_mutex);
        list_for_each_entry(event, &ftrace_events, list) {
-               if (event->id == event_id) {
+               if (event->id == event_id && event->profile_enable) {
                        ret = event->profile_enable(event);
                        break;
                }
index 23d2972b22d67a773f0d6d8242e173941d174c76..e75276a49cf5cfa2fb968609602621fa8e5a5da3 100644 (file)
@@ -940,7 +940,7 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events,
                entry = trace_create_file("enable", 0644, call->dir, call,
                                          enable);
 
-       if (call->id)
+       if (call->id && call->profile_enable)
                entry = trace_create_file("id", 0444, call->dir, call,
                                          id);