ftrace/perf: Check sample types only for sampling events
authorJiri Olsa <jolsa@kernel.org>
Wed, 16 Mar 2016 14:34:29 +0000 (15:34 +0100)
committerIngo Molnar <mingo@kernel.org>
Thu, 31 Mar 2016 08:30:45 +0000 (10:30 +0200)
Currently we check sample type for ftrace:function events
even if it's not created as a sampling event. That prevents
creating ftrace_function event in counting mode.

Make sure we check sample types only for sampling events.

Before:
  $ sudo perf stat -e ftrace:function ls
  ...

   Performance counter stats for 'ls':

     <not supported>      ftrace:function

         0.001983662 seconds time elapsed

After:
  $ sudo perf stat -e ftrace:function ls
  ...

   Performance counter stats for 'ls':

              44,498      ftrace:function

         0.037534722 seconds time elapsed

Suggested-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Link: http://lkml.kernel.org/r/1458138873-1553-2-git-send-email-jolsa@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/trace/trace_event_perf.c

index 00df25fd86ef458b4ee23d645efda32426af2568..e11108f1d19735026e66fe7336650a9c7559501e 100644 (file)
@@ -47,6 +47,9 @@ static int perf_trace_event_perm(struct trace_event_call *tp_event,
                if (perf_paranoid_tracepoint_raw() && !capable(CAP_SYS_ADMIN))
                        return -EPERM;
 
+               if (!is_sampling_event(p_event))
+                       return 0;
+
                /*
                 * We don't allow user space callchains for  function trace
                 * event, due to issues with page faults while tracing page