[PATCH v2] arm64: Add USER_STACKTRACE support

chenqiwu qiwuchen55 at gmail.com
Sat Dec 9 05:20:38 PST 2023


On Tue, Nov 28, 2023 at 02:48:32PM +0000, Mark Rutland wrote:
> On Fri, Nov 24, 2023 at 11:27:39PM -0800, qiwuchen55 at gmail.com wrote:
> > From: chenqiwu <qiwu.chen at transsion.com>
> > 
> > Use the perf_callchain_user() code as blueprint to implement
> > arch_stack_walk_user() which add ftrace userstacktrace support
> > on arm64.
> > With this patch, tracer can get userstacktrace by below callchain:
> > ftrace_trace_userstack ->
> > 	stack_trace_save_user ->
> > 		aasrch_stack_walk_user
> > An example test case is as shown 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-418     [000] .....   121.820661: sched_process_fork: comm=bash pid=418 child_comm=bash child_pid=441
> >   bash-418     [000] .....   121.821340: <user stack trace>
> >  => /lib/aarch64-linux-gnu/libc-2.32.so[+0xa76d8]
> >  => /bin/bash[+0x5f354]
> >  => /bin/bash[+0x47fe8]
> >  => /bin/bash[+0x493f8]
> >  => /bin/bash[+0x4aec4]
> >  => /bin/bash[+0x4c31c]
> >  => /bin/bash[+0x339b0]
> >  => /bin/bash[+0x322f8]
> > 
> > changes in v2:
> >     - Remove useless arch_dump_user_stacktrace().
> >     - Rework arch_stack_walk_user() implementation.
> >     - Modify the commit message.
> > Tested-by: chenqiwu <qiwu.chen at transsion.com>
> > Signed-off-by: chenqiwu <qiwu.chen at transsion.com>
> > ---
> >  arch/arm64/Kconfig             |   1 +
> >  arch/arm64/kernel/stacktrace.c | 120 +++++++++++++++++++++++++++++++++
> >  2 files changed, 121 insertions(+)
> 
> Thanks for this, it looks much better than v1.
> However, as I mentioned on v1, we want to have one copy of this code. 
> 
> Rather than just copying the logic from perf_callchain.c, please also update 
> perf_callchain_user() to use arch_stack_walk_user() and delete the redundant code.
> 
> Thanks,
> Mark.
>
Hi Mark,
Thanks for your professional advice, I make an improvement in patch v3.
Please help review this again:
https://patchwork.kernel.org/project/linux-arm-kernel/patch/20231129160119.60829-1-qiwu.chen@transsion.com/
Thanks
Qiwu



More information about the linux-arm-kernel mailing list