linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next 0/7] riscv: Improvments for stacktrace
@ 2022-09-20 15:11 Chen Zhongjin
  2022-09-20 15:11 ` [PATCH -next 1/7] riscv: stacktrace: Replace walk_stackframe with arch_stack_walk Chen Zhongjin
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Chen Zhongjin @ 2022-09-20 15:11 UTC (permalink / raw)
  To: linux-kernel, linux-riscv, linux-perf-users
  Cc: paul.walmsley, palmer, aou, peterz, mingo, acme, mark.rutland,
	alexander.shishkin, namhyung, jolsa, guoren, nsaenzju, frederic,
	changbin.du, vincent.chen, ardb, mhiramat, rostedt, keescook,
	catalin.marinas, chenzhongjin

Currently, the stacktrace with FRAME_POINTER on riscv has some problem:

1. stacktrace will stop at irq so it can't get the stack frames before
irq entry.
2. stacktrace can't unwind all the real stack frames when there is
k{ret}probes or ftrace.

These are mainly becase when there is a pt_regs on stack, we can't unwind
the stack frame as normal function.

Some architectures (e.g. arm64) create a extra stackframe inside pt_regs.
However this doesn't work for riscv because the ra is not ensured to be
pushed to stack. As explained in:
commit f766f77a74f5("riscv/stacktrace: Fix stack output without ra on the stack top")

So, I choosed the method of x86 that, if there is a pt_regs on stack,
we encoded the frame pointer and save it. When unwinding stack frame,
we can get pt_regs and registers required for unwinding stacks.

In addition, the patch set contains some refactoring of stacktrace.c to
keep the stacktrace code on riscv consistent with other architectures.

Chen Zhongjin (7):
  riscv: stacktrace: Replace walk_stackframe with arch_stack_walk
  riscv: stacktrace: Introduce unwind functions
  riscv: stacktrace: Save pt_regs in encoded fp on irq entry
  riscv: syscall: Don't clobber s0 when syscall
  riscv: stacktrace: Implement stacktrace for irq
  riscv: stacktrace: Fix unwinding on ftrace_regs_call
  riscv: stacktrace: Fix unwinding on __kretporbe_trampoline

 arch/riscv/include/asm/frame.h                |  45 +++++
 arch/riscv/include/asm/stacktrace.h           |  13 +-
 arch/riscv/kernel/entry.S                     |  23 +--
 arch/riscv/kernel/mcount-dyn.S                |   8 +
 arch/riscv/kernel/perf_callchain.c            |   2 +-
 arch/riscv/kernel/probes/kprobes_trampoline.S |   8 +
 arch/riscv/kernel/stacktrace.c                | 155 ++++++++++++------
 7 files changed, 195 insertions(+), 59 deletions(-)
 create mode 100644 arch/riscv/include/asm/frame.h

-- 
2.17.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2022-09-21 12:33 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-20 15:11 [PATCH -next 0/7] riscv: Improvments for stacktrace Chen Zhongjin
2022-09-20 15:11 ` [PATCH -next 1/7] riscv: stacktrace: Replace walk_stackframe with arch_stack_walk Chen Zhongjin
2022-09-20 15:11 ` [PATCH -next 2/7] riscv: stacktrace: Introduce unwind functions Chen Zhongjin
2022-09-20 15:11 ` [PATCH -next 3/7] riscv: stacktrace: Save pt_regs in encoded fp on irq entry Chen Zhongjin
2022-09-21  2:13   ` Guo Ren
2022-09-20 15:11 ` [PATCH -next 4/7] riscv: syscall: Don't clobber s0 when syscall Chen Zhongjin
2022-09-21  1:30   ` Guo Ren
2022-09-21  2:16     ` Guo Ren
2022-09-20 15:12 ` [PATCH -next 5/7] riscv: stacktrace: Implement stacktrace for irq Chen Zhongjin
2022-09-20 15:12 ` [PATCH -next 6/7] riscv: stacktrace: Fix unwinding on ftrace_regs_call Chen Zhongjin
2022-09-21  1:43   ` Guo Ren
2022-09-21  3:00     ` Chen Zhongjin
2022-09-20 15:12 ` [PATCH -next 7/7] riscv: stacktrace: Fix unwinding on __kretporbe_trampoline Chen Zhongjin
2022-09-21  2:30 ` [PATCH -next 0/7] riscv: Improvments for stacktrace Guo Ren
2022-09-21 12:33   ` Chen Zhongjin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).