Skip to content

Fix duplicate caller frame in arm64 stack traces

Andrii Nakryiko bpf linux-arm-kernel linux-perf-users 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 2 repliesIn review
  2. v13 patches 4 repliesSuperseded

Changes in v2 from the cover letter

- keep __builtin_frame_address(0) in perf_arch_fetch_caller_regs(), mark

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3arm64: perf: Don't report the caller twice in caller-regs callchainsarch/arm64/include/asm/perf_event.h arch/arm64/kernel/perf_callchain.c+33 -22 replies
2/3selftests/bpf: Add stacktrace_ips test for tracepointtools/testing/selftests/bpf/prog_tests/stacktrace_ips.c tools/testing/selftests/bpf/progs/stacktrace_ips.c+67 -00 replies
3/3selftests/bpf: Run stacktrace_ips raw_tp, tp and fentry tests on arm64tools/testing/selftests/bpf/prog_tests/stacktrace_ips.c tools/testing/selftests/bpf/progs/stacktrace_ips.c+14 -60 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH bpf-next v2 0/3] Fix duplicate caller frame in arm64 stack traces

On arm64 the caller is reported twice when the kernel builds a callchain for the current task from regs filled by perf_fetch_caller_regs(), instead of regs saved by a real exception. There was a similar problem on x86-64, but it was since fixed. Now it's time for arm64.

Patch 1 has the fix, patches 2-3 add BPF selftests for this.

I'm targeting bpf-next because of BPF selftests and to have BPF CI test everything. Patch 1 doesn't have to go through bpf-next, but it's simple enough, so if arm64 folks are ok with that, please ack and then we'll land everything in one go into bpf-next.

v1->v2:
- keep __builtin_frame_address(0) in perf_arch_fetch_caller_regs(), mark

    these regs with PSR_MODE_EL1t instead, and have perf_callchain_kernel()
    skip the duplicate leaf regs->pc for them, like x86 does with
    perf_hw_regs() (Will);

v1: https://lore.kernel.org/bpf/[email protected]/

Andrii Nakryiko (3):
arm64: perf: Don't report the caller twice in caller-regs callchains selftests/bpf: Add stacktrace_ips test for tracepoint selftests/bpf: Run stacktrace_ips raw_tp, tp and fentry tests on arm64

 arch/arm64/include/asm/perf_event.h           |  2 +-
 arch/arm64/kernel/perf_callchain.c            | 33 ++++++++-
 .../selftests/bpf/prog_tests/stacktrace_ips.c | 67 ++++++++++++++++++-
 .../selftests/bpf/progs/stacktrace_ips.c      | 18 ++++-
 4 files changed, 113 insertions(+), 7 deletions(-)
Signature · 1 line
2.53.1-Meta