• Jinjie Ruan's avatar
    riscv: stacktrace: Add USER_STACKTRACE support · 1a748331
    Jinjie Ruan authored
    Currently, userstacktrace is unsupported for riscv. So use the
    perf_callchain_user() code as blueprint to implement the
    arch_stack_walk_user() which add userstacktrace support on riscv.
    Meanwhile, we can use arch_stack_walk_user() to simplify the implementation
    of perf_callchain_user().
    
    A ftrace test case is shown as below:
    
    	# cd /sys/kernel/debug/tracing
    	# echo 1 > options/userstacktrace
    	# echo 1 > options/sym-userobj
    	# echo 1 > events/sched/sched_process_fork/enable
    	# cat trace
    	......
    	            bash-178     [000] ...1.    97.968395: sched_process_fork: comm=bash pid=178 child_comm=bash child_pid=231
    	            bash-178     [000] ...1.    97.970075: <user stack trace>
    	 => /lib/libc.so.6[+0xb5090]
    
    Also a simple perf test is ok as below:
    
    	# perf record -e cpu-clock --call-graph fp top
    	# perf report --call-graph
    
    	.....
    	[[31m  66.54%[[m     0.00%  top      [kernel.kallsyms]            [k] ret_from_exception
                |
                ---ret_from_exception
                   |
                   |--[[31m58.97%[[m--do_trap_ecall_u
                   |          |
                   |          |--[[31m17.34%[[m--__riscv_sys_read
                   |          |          ksys_read
                   |          |          |
                   |          |           --[[31m16.88%[[m--vfs_read
                   |          |                     |
                   |          |                     |--[[31m10.90%[[m--seq_read
    Signed-off-by: default avatarJinjie Ruan <ruanjinjie@huawei.com>
    Tested-by: default avatarJinjie Ruan <ruanjinjie@huawei.com>
    Cc: Björn Töpel <bjorn@kernel.org>
    Link: https://lore.kernel.org/r/20240708032847.2998158-3-ruanjinjie@huawei.comSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
    1a748331
perf_callchain.c 1.08 KB