Skip to contentSkip to conversation

csky: Add perf_arch_fetch_caller_regs support

PATCH New [email protected] 1 participant 1 message Apr 10, 2019

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH v2 1/1 csky: Add perf_arch_fetch_caller_regs support

From: Mao Han <[email protected]>

In trace events as tracepoints context are not able to be retrieve with task_pt_regs. Without arch caller regs support the pt_regs context will be all zero, perf can not parsing the callchain and resolving the symbols correctly, some time will even get into deadlock while handling the page fault, eg:

perf kmem —page record ls

Changelog
- Add test case cmd in comment
- Use regs_fp(regs) which is defined in abi/regdef.h

---
 arch/csky/abiv1/inc/abi/regdef.h   | 1 +
 arch/csky/abiv2/inc/abi/regdef.h   | 1 +
 arch/csky/include/asm/perf_event.h | 8 ++++++++
 3 files changed, 10 insertions(+)
arch/csky/abiv1/inc/abi/regdef.h +1 -0
index 729b1c3..104707f 100644
@@ -6,6 +6,7 @@
 
 #define syscallid	r1
 #define regs_syscallid(regs) regs->regs[9]
+#define regs_fp(regs) regs->regs[2]
 
 /*
  * PSR format:
arch/csky/abiv2/inc/abi/regdef.h +1 -0
index 77cb178..d7328bb 100644
@@ -6,6 +6,7 @@
 
 #define syscallid	r7
 #define regs_syscallid(regs) regs->regs[3]
+#define regs_fp(regs) regs->regs[4]
 
 /*
  * PSR format:
arch/csky/include/asm/perf_event.h +8 -0
index ea81931..572093e 100644
@@ -4,4 +4,12 @@
 #ifndef __ASM_CSKY_PERF_EVENT_H
 #define __ASM_CSKY_PERF_EVENT_H
 
+#include <abi/regdef.h>
+
+#define perf_arch_fetch_caller_regs(regs, __ip) { \
+	(regs)->pc = (__ip); \
+	regs_fp(regs) = (unsigned long) __builtin_frame_address(0); \
+	asm volatile("mov %0, sp\n":"=r"((regs)->usp)); \
+}
+
 #endif /* __ASM_PERF_EVENT_ELF_H */
Signature · 1 line
2.7.4