linux/arch/riscv
Jinjie Ruan 1a74833182
riscv: stacktrace: Add USER_STACKTRACE support
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: Jinjie Ruan <ruanjinjie@huawei.com>
Tested-by: Jinjie Ruan <ruanjinjie@huawei.com>
Cc: Björn Töpel <bjorn@kernel.org>
Link: https://lore.kernel.org/r/20240708032847.2998158-3-ruanjinjie@huawei.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
2024-09-14 23:57:16 -07:00
..
boot RISC-V Patches for the 6.11 Merge Window, Part 2 2024-07-27 10:14:34 -07:00
configs RISC-V: run savedefconfig for defconfig 2024-07-22 10:57:47 -07:00
crypto crypto: riscv - add vector crypto accelerated AES-CBC-CTS 2024-03-20 08:56:11 -07:00
errata riscv: Extend cpufeature.c to detect vendor extensions 2024-07-22 15:36:54 -07:00
include RISC-V Patches for the 6.11 Merge Window, Part 2 2024-07-27 10:14:34 -07:00
kernel riscv: stacktrace: Add USER_STACKTRACE support 2024-09-14 23:57:16 -07:00
kvm ARM: 2024-07-20 12:41:03 -07:00
lib riscv: Optimize crc32 with Zbc extension 2024-07-10 13:19:50 -07:00
mm - 875fa64577da ("mm/hugetlb_vmemmap: fix race with speculative PFN 2024-07-21 17:15:46 -07:00
net RISC-V Patches for the 6.11 Merge Window, Part 1 2024-07-20 09:11:27 -07:00
purgatory Makefile: remove redundant tool coverage variables 2024-05-14 23:35:48 +09:00
tools riscv: Check relocations at compile time 2023-04-19 07:46:32 -07:00
Kbuild RISC-V: hook new crypto subdir into build-system 2024-01-22 17:55:17 -08:00
Kconfig riscv: stacktrace: Add USER_STACKTRACE support 2024-09-14 23:57:16 -07:00
Kconfig.debug riscv: Add tests for riscv module loading 2023-11-07 14:59:32 -08:00
Kconfig.errata riscv: thead: Rename T-Head PBMT to MAE 2024-04-25 10:22:33 -07:00
Kconfig.socs RISC-V: drop SOC_VIRT for ARCH_VIRT 2024-04-10 11:37:50 +01:00
Kconfig.vendor riscv: Extend cpufeature.c to detect vendor extensions 2024-07-22 15:36:54 -07:00
Makefile Merge patch series "riscv: Apply Zawrs when available" 2024-07-12 08:55:29 -07:00
Makefile.postlink kbuild: remove ARCH_POSTLINK from module builds 2023-10-28 21:10:08 +09:00