Skip to content

Commit d3119bc

Browse files
committed
LoongArch: Fix callchain parse error with kernel tracepoint events
In order to fix perf's callchain parse error for LoongArch, we implement perf_arch_fetch_caller_regs() which fills several necessary registers used for callchain unwinding, including sp, fp, and era. This is similar to the following commits. commit b3eac02: ("arm: perf: Fix callchain parse error with kernel tracepoint events") commit 5b09a09: ("arm64: perf: Fix callchain parse error with kernel tracepoint events") commit 9a7e8ec: ("riscv: perf: Fix callchain parse error with kernel tracepoint events") Test with commands: perf record -e sched:sched_switch -g --call-graph dwarf perf report Without this patch: Children Self Command Shared Object Symbol ........ ........ ............. ................. .................... 43.41% 43.41% swapper [unknown] [k] 0000000000000000 10.94% 10.94% loong-container [unknown] [k] 0000000000000000 | |--5.98%--0x12006ba38 | |--2.56%--0x12006bb84 | --2.40%--0x12006b6b8 With this patch, callchain can be parsed correctly: Children Self Command Shared Object Symbol ........ ........ ............. ................. .................... 47.57% 47.57% swapper [kernel.vmlinux] [k] __schedule | ---__schedule 26.76% 26.76% loong-container [kernel.vmlinux] [k] __schedule | |--13.78%--0x12006ba38 | | | |--9.19%--__schedule | | | --4.59%--handle_syscall | do_syscall | sys_futex | do_futex | futex_wait | futex_wait_queue_me | hrtimer_start_range_ns | __schedule | |--8.38%--0x12006bb84 | handle_syscall | do_syscall | sys_epoll_pwait | do_epoll_wait | schedule_hrtimeout_range_clock | hrtimer_start_range_ns | __schedule | --4.59%--0x12006b6b8 handle_syscall do_syscall sys_nanosleep hrtimer_nanosleep do_nanosleep hrtimer_start_range_ns __schedule Cc: [email protected] Fixes: b37042b ("LoongArch: Add perf events support") Reported-by: Youling Tang <[email protected]> Suggested-by: Youling Tang <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent efb44ff commit d3119bc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

arch/loongarch/include/asm/perf_event.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
#ifndef __LOONGARCH_PERF_EVENT_H__
88
#define __LOONGARCH_PERF_EVENT_H__
99

10+
#include <asm/ptrace.h>
11+
1012
#define perf_arch_bpf_user_pt_regs(regs) (struct user_pt_regs *)regs
1113

14+
#define perf_arch_fetch_caller_regs(regs, __ip) { \
15+
(regs)->csr_era = (__ip); \
16+
(regs)->regs[3] = current_stack_pointer; \
17+
(regs)->regs[22] = (unsigned long) __builtin_frame_address(0); \
18+
}
19+
1220
#endif /* __LOONGARCH_PERF_EVENT_H__ */

0 commit comments

Comments
 (0)