linux-stable/kernel/trace
Zhou Chengming 75e8387685 perf/ftrace: Fix double traces of perf on ftrace:function
When running perf on the ftrace:function tracepoint, there is a bug
which can be reproduced by:

  perf record -e ftrace:function -a sleep 20 &
  perf record -e ftrace:function ls
  perf script

              ls 10304 [005]   171.853235: ftrace:function:
  perf_output_begin
              ls 10304 [005]   171.853237: ftrace:function:
  perf_output_begin
              ls 10304 [005]   171.853239: ftrace:function:
  task_tgid_nr_ns
              ls 10304 [005]   171.853240: ftrace:function:
  task_tgid_nr_ns
              ls 10304 [005]   171.853242: ftrace:function:
  __task_pid_nr_ns
              ls 10304 [005]   171.853244: ftrace:function:
  __task_pid_nr_ns

We can see that all the function traces are doubled.

The problem is caused by the inconsistency of the register
function perf_ftrace_event_register() with the probe function
perf_ftrace_function_call(). The former registers one probe
for every perf_event. And the latter handles all perf_events
on the current cpu. So when two perf_events on the current cpu,
the traces of them will be doubled.

So this patch adds an extra parameter "event" for perf_tp_event,
only send sample data to this event when it's not NULL.

Signed-off-by: Zhou Chengming <zhouchengming1@huawei.com>
Reviewed-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: acme@kernel.org
Cc: alexander.shishkin@linux.intel.com
Cc: huawei.libin@huawei.com
Link: http://lkml.kernel.org/r/1503668977-12526-1-git-send-email-zhouchengming1@huawei.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-08-29 13:29:29 +02:00
..
blktrace.c block: switch bios to blk_status_t 2017-06-09 09:27:32 -06:00
bpf_trace.c bpf: fix bpf_trace_printk on 32 bit archs 2017-08-15 17:32:15 -07:00
ftrace.c ftrace: Check for null ret_stack on profile function graph entry function 2017-08-24 10:04:01 -04:00
Kconfig tracing: Rename update the enum_map file 2017-06-13 17:13:06 -04:00
Makefile
power-traces.c
ring_buffer.c ring-buffer: Have ring_buffer_alloc_read_page() return error on offline CPU 2017-08-02 14:23:02 -04:00
ring_buffer_benchmark.c ring-buffer: Have ring_buffer_alloc_read_page() return error on offline CPU 2017-08-02 14:23:02 -04:00
rpm-traces.c
trace.c ring-buffer: Have ring_buffer_alloc_read_page() return error on offline CPU 2017-08-02 14:23:02 -04:00
trace.h trace: fix the errors caused by incompatible type of RCU variables 2017-07-20 09:27:29 -04:00
trace_benchmark.c tracing: Have the trace_event benchmark thread call cond_resched_rcu_qs() 2017-04-17 15:21:19 -04:00
trace_benchmark.h
trace_branch.c
trace_clock.c
trace_entries.h trace: make trace_hwlat timestamp y2038 safe 2017-05-08 17:15:15 -07:00
trace_event_perf.c perf/ftrace: Fix double traces of perf on ftrace:function 2017-08-29 13:29:29 +02:00
trace_events.c tracing: Add support for recording tgid of tasks 2017-06-27 13:30:28 -04:00
trace_events_filter.c tracing: Fix freeing of filter in create_filter() when set_str is false 2017-08-24 10:07:38 -04:00
trace_events_filter_test.h
trace_events_hist.c
trace_events_trigger.c
trace_export.c
trace_functions.c ftrace: Fix regression with module command in stack_trace_filter 2017-06-29 10:05:45 -04:00
trace_functions_graph.c
trace_hwlat.c trace: make trace_hwlat timestamp y2038 safe 2017-05-08 17:15:15 -07:00
trace_irqsoff.c
trace_kdb.c
trace_kprobe.c perf/ftrace: Fix double traces of perf on ftrace:function 2017-08-29 13:29:29 +02:00
trace_mmiotrace.c
trace_nop.c
trace_output.c tracing: Add support for display of tgid in trace output 2017-06-27 13:30:28 -04:00
trace_output.h
trace_printk.c
trace_probe.c
trace_probe.h
trace_sched_switch.c tracing: Add support for recording tgid of tasks 2017-06-27 13:30:28 -04:00
trace_sched_wakeup.c
trace_selftest.c
trace_selftest_dynamic.c
trace_seq.c
trace_stack.c tracing: Do note expose stack_trace_filter without DYNAMIC_FTRACE 2017-07-11 19:21:04 -04:00
trace_stat.c
trace_stat.h
trace_syscalls.c perf/ftrace: Fix double traces of perf on ftrace:function 2017-08-29 13:29:29 +02:00
trace_uprobe.c perf/ftrace: Fix double traces of perf on ftrace:function 2017-08-29 13:29:29 +02:00
tracing_map.c tracing: Fix kmemleak in tracing_map_array_free() 2017-08-24 10:05:51 -04:00
tracing_map.h