Hi Mao, Mao Han <han_mao@xxxxxxxxx> 於 2019年8月23日 週五 下午2:16寫道: > > This patch add support for perf callchain sampling on riscv platform. > The return address of leaf function is retrieved from pt_regs as > it is not saved in the outmost frame. > > Signed-off-by: Mao Han <han_mao@xxxxxxxxx> > Cc: Paul Walmsley <paul.walmsley@xxxxxxxxxx> > Cc: Greentime Hu <green.hu@xxxxxxxxx> > Cc: Palmer Dabbelt <palmer@xxxxxxxxxx> > Cc: linux-riscv <linux-riscv@xxxxxxxxxxxxxxxxxxx> > Cc: Christoph Hellwig <hch@xxxxxx> > Cc: Guo Ren <guoren@xxxxxxxxxx> > --- > arch/riscv/Makefile | 3 + > arch/riscv/kernel/Makefile | 3 +- > arch/riscv/kernel/perf_callchain.c | 115 +++++++++++++++++++++++++++++++++++++ > 3 files changed, 120 insertions(+), 1 deletion(-) > create mode 100644 arch/riscv/kernel/perf_callchain.c I just tested "./perf record -e cpu-clock --call-graph fp ls" on Unleashed board and I got this failure. I take a look at it. It seem failed in here. Do you have any idea? It seems fine in Qemu. 1 *frame = *((struct stackframe *)frame->fp - 1); ffffffe0001a198c: 00863a83 ld s5,8(a2) ffffffe0001a1990: ff093903 ld s2,-16(s2) ./perf record -e cpu-clock --call-graph fp ls [ 9619.423884] hrtimer: interrupt took 733000 ns [ 9619.977017] Unable to handle kernel paging request at virtual address ffffffffffffff94 [ 9620.214736] Oops [#1] [ 9620.289893] Modules linked in: [ 9620.391378] CPU: 0 PID: 264 Comm: ls Not tainted 5.3.0-rc5-00003-gb008f6bcd67c #4 [ 9620.640176] sepc: ffffffe0001a198c ra : ffffffe0001a199a sp : ffffffe000093720 [ 9620.880366] gp : ffffffe00097dad8 tp : ffffffe000082e40 t0 : 0000000000046000 [ 9621.120564] t1 : 0000000000000002 t2 : 0000000000000007 s0 : ffffffe000093760 [ 9621.360768] s1 : ffffffe000093788 a0 : 0000000000000003 a1 : 0000000000000000 [ 9621.600991] a2 : ffffffffffffff8c a3 : 0000000000001fa0 a4 : 0000000000000010 [ 9621.841181] a5 : 0000000000000002 a6 : 0000000000000001 a7 : ffffffe079b34e10 [ 9622.081400] s2 : ffffffffffffff9c s3 : ffffffe000000000 s4 : 0000000000001ff8 [ 9622.321618] s5 : ffffffe000093da0 s6 : ffffffe00097d540 s7 : ffffffe07a1517a0 [ 9622.561811] s8 : 000008bf01c7ff60 s9 : ffffffe000235b2a s10: 0000000200000120 [ 9622.802015] s11: 0000000000000001 t3 : ffffffe079b34e00 t4 : 0000000000000001 [ 9623.042194] t5 : 0000000000000008 t6 : ffffffe0009208d0 [ 9623.218785] sstatus: 0000000200000100 sbadaddr: ffffffffffffff94 scause: 000000000000000d [ 9623.490850] ---[ end trace 49043f28e856d84d ]--- [ 9623.644217] Kernel panic - not syncing: Fatal exception in interrupt [ 9623.855470] SMP: stopping secondary CPUs [ 9623.985955] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---