diff options
author | Zhou Chengming <zhouchengming1@huawei.com> | 2017-08-25 09:49:37 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-08-29 07:29:29 -0400 |
commit | 75e8387685f6c65feb195a4556110b58f852b848 (patch) | |
tree | 1c8f8318f1fe76197a2a0d2fcfc53992b1855b30 /kernel/events | |
parent | f12f42acdbb577a12eecfcebbbec41c81505c4dc (diff) |
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>
Diffstat (limited to 'kernel/events')
-rw-r--r-- | kernel/events/core.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index ce131d25622a..03ac9c8b02fb 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -7906,16 +7906,15 @@ void perf_trace_run_bpf_submit(void *raw_data, int size, int rctx, | |||
7906 | } | 7906 | } |
7907 | } | 7907 | } |
7908 | perf_tp_event(call->event.type, count, raw_data, size, regs, head, | 7908 | perf_tp_event(call->event.type, count, raw_data, size, regs, head, |
7909 | rctx, task); | 7909 | rctx, task, NULL); |
7910 | } | 7910 | } |
7911 | EXPORT_SYMBOL_GPL(perf_trace_run_bpf_submit); | 7911 | EXPORT_SYMBOL_GPL(perf_trace_run_bpf_submit); |
7912 | 7912 | ||
7913 | void perf_tp_event(u16 event_type, u64 count, void *record, int entry_size, | 7913 | void perf_tp_event(u16 event_type, u64 count, void *record, int entry_size, |
7914 | struct pt_regs *regs, struct hlist_head *head, int rctx, | 7914 | struct pt_regs *regs, struct hlist_head *head, int rctx, |
7915 | struct task_struct *task) | 7915 | struct task_struct *task, struct perf_event *event) |
7916 | { | 7916 | { |
7917 | struct perf_sample_data data; | 7917 | struct perf_sample_data data; |
7918 | struct perf_event *event; | ||
7919 | 7918 | ||
7920 | struct perf_raw_record raw = { | 7919 | struct perf_raw_record raw = { |
7921 | .frag = { | 7920 | .frag = { |
@@ -7929,9 +7928,15 @@ void perf_tp_event(u16 event_type, u64 count, void *record, int entry_size, | |||
7929 | 7928 | ||
7930 | perf_trace_buf_update(record, event_type); | 7929 | perf_trace_buf_update(record, event_type); |
7931 | 7930 | ||
7932 | hlist_for_each_entry_rcu(event, head, hlist_entry) { | 7931 | /* Use the given event instead of the hlist */ |
7932 | if (event) { | ||
7933 | if (perf_tp_event_match(event, &data, regs)) | 7933 | if (perf_tp_event_match(event, &data, regs)) |
7934 | perf_swevent_event(event, count, &data, regs); | 7934 | perf_swevent_event(event, count, &data, regs); |
7935 | } else { | ||
7936 | hlist_for_each_entry_rcu(event, head, hlist_entry) { | ||
7937 | if (perf_tp_event_match(event, &data, regs)) | ||
7938 | perf_swevent_event(event, count, &data, regs); | ||
7939 | } | ||
7935 | } | 7940 | } |
7936 | 7941 | ||
7937 | /* | 7942 | /* |