Re: [PATCH] perf/ftrace: fix doubled traces of perf on ftrace:function
From: Steven Rostedt
Date: Fri Aug 25 2017 - 09:56:51 EST
On Fri, 25 Aug 2017 21:49:37 +0800
Zhou Chengming <zhouchengming1@xxxxxxxxxx> wrote:
> When run 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 in perf.data
> of "ls".
>
> 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@xxxxxxxxxx>
> ---
> include/linux/perf_event.h | 2 +-
> include/linux/trace_events.h | 4 ++--
> kernel/events/core.c | 13 +++++++++----
> kernel/trace/trace_event_perf.c | 4 +++-
> kernel/trace/trace_kprobe.c | 4 ++--
> kernel/trace/trace_syscalls.c | 4 ++--
> kernel/trace/trace_uprobe.c | 2 +-
The trace files look fine to me.
Acked-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
-- Steve
> 7 files changed, 20 insertions(+), 13 deletions(-)
>