summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2025-11-04 22:54:02 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-12-07 06:09:34 +0900
commit5b9790d2009e1ac61ce93b93eecfa464b972122b (patch)
tree23a06f1e6b576649199e7e89affe76069121cdeb /arch
parent891775b1b4edd131ad2f9a3130f0efd1204377ae (diff)
downloadlinux-5b9790d2009e1ac61ce93b93eecfa464b972122b.tar.gz
linux-5b9790d2009e1ac61ce93b93eecfa464b972122b.tar.bz2
linux-5b9790d2009e1ac61ce93b93eecfa464b972122b.zip
Revert "perf/x86: Always store regs->ip in perf_callchain_kernel()"
commit 6d08340d1e354787d6c65a8c3cdd4d41ffb8a5ed upstream. This reverts commit 83f44ae0f8afcc9da659799db8693f74847e66b3. Currently we store initial stacktrace entry twice for non-HW ot_regs, which means callers that fail perf_hw_regs(regs) condition in perf_callchain_kernel. It's easy to reproduce this bpftrace: # bpftrace -e 'tracepoint:sched:sched_process_exec { print(kstack()); }' Attaching 1 probe... bprm_execve+1767 bprm_execve+1767 do_execveat_common.isra.0+425 __x64_sys_execve+56 do_syscall_64+133 entry_SYSCALL_64_after_hwframe+118 When perf_callchain_kernel calls unwind_start with first_frame, AFAICS we do not skip regs->ip, but it's added as part of the unwind process. Hence reverting the extra perf_callchain_store for non-hw regs leg. I was not able to bisect this, so I'm not really sure why this was needed in v5.2 and why it's not working anymore, but I could see double entries as far as v5.10. I did the test for both ORC and framepointer unwind with and without the this fix and except for the initial entry the stacktraces are the same. Acked-by: Song Liu <song@kernel.org> Signed-off-by: Jiri Olsa <jolsa@kernel.org> Link: https://lore.kernel.org/r/20251104215405.168643-2-jolsa@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/events/core.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index e55fc25da2da..9a77c6062c24 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -2772,13 +2772,13 @@ perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *re
return;
}
- if (perf_callchain_store(entry, regs->ip))
- return;
-
- if (perf_hw_regs(regs))
+ if (perf_hw_regs(regs)) {
+ if (perf_callchain_store(entry, regs->ip))
+ return;
unwind_start(&state, current, regs, NULL);
- else
+ } else {
unwind_start(&state, current, NULL, (void *)regs->sp);
+ }
for (; !unwind_done(&state); unwind_next_frame(&state)) {
addr = unwind_get_return_address(&state);