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

Andrii Nakryiko andrii at kernel.org
Tue Dec 1 15:02:44 PST 2026


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.

v2->v3:
  - skip the duplicate leaf for PSR_MODE_EL1t regs in kunwind_stack_walk()
    by stepping to the frame record at x29, instead of dropping it in
    perf_callchain_kernel(); perf_callchain.c is not changed anymore (Alexei);
  - patch 3 commit message adjusted accordingly.

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);

v2: https://lore.kernel.org/bpf/20261119000112.2377949-1-andrii@kernel.org/
v1: https://lore.kernel.org/bpf/20261114001846.873499-1-andrii@kernel.org/

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           |  3 +-
 arch/arm64/kernel/stacktrace.c                |  6 ++
 .../selftests/bpf/prog_tests/stacktrace_ips.c | 67 ++++++++++++++++++-
 .../selftests/bpf/progs/stacktrace_ips.c      | 18 ++++-
 4 files changed, 88 insertions(+), 6 deletions(-)

-- 
2.53.1-Meta




More information about the linux-arm-kernel mailing list