Skip to content

Commit 612695b

Browse files
tnovakRussell King (Oracle)
authored andcommitted
ARM: 9251/1: perf: Fix stacktraces for tracepoint events in THUMB2 kernels
Store the frame address where arm_get_current_stackframe() looks for it (ARM_r7 instead of ARM_fp if CONFIG_THUMB2_KERNEL=y). Otherwise frame->fp gets set to 0, causing unwind_frame() to fail. # bpftrace -e 't:sched:sched_switch { @[kstack] = count(); exit(); }' Attaching 1 probe... @[ __schedule+1059 ]: 1 A typical first unwind instruction is 0x97 (SP = R7), so after executing it SP ends up being 0 and -URC_FAILURE is returned. unwind_frame(pc = ac9da7d7 lr = 00000000 sp = c69bdda0 fp = 00000000) unwind_find_idx(ac9da7d7) unwind_exec_insn: insn = 00000097 unwind_exec_insn: fp = 00000000 sp = 00000000 lr = 00000000 pc = 00000000 With this patch: # bpftrace -e 't:sched:sched_switch { @[kstack] = count(); exit(); }' Attaching 1 probe... @[ __schedule+1059 __schedule+1059 schedule+79 schedule_hrtimeout_range_clock+163 schedule_hrtimeout_range+17 ep_poll+471 SyS_epoll_wait+111 sys_epoll_pwait+231 __ret_fast_syscall+1 ]: 1 Link: https://lore.kernel.org/r/[email protected]/ Reviewed-by: Linus Walleij <[email protected]> Signed-off-by: Tomislav Novak <[email protected]> Signed-off-by: Russell King (Oracle) <[email protected]>
1 parent 14ca1a4 commit 612695b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/arm/include/asm/perf_event.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extern unsigned long perf_misc_flags(struct pt_regs *regs);
1717

1818
#define perf_arch_fetch_caller_regs(regs, __ip) { \
1919
(regs)->ARM_pc = (__ip); \
20-
(regs)->ARM_fp = (unsigned long) __builtin_frame_address(0); \
20+
frame_pointer((regs)) = (unsigned long) __builtin_frame_address(0); \
2121
(regs)->ARM_sp = current_stack_pointer; \
2222
(regs)->ARM_cpsr = SVC_MODE; \
2323
}

0 commit comments

Comments
 (0)