[PATCH V2] arm64:ftrace: add save_stack_trace_regs()
David Long
dave.long at linaro.org
Thu Sep 1 13:38:20 PDT 2016
On 09/01/2016 09:35 AM, Pratyush Anand wrote:
> Implement save_stack_trace_regs, so that stacktrace of a kprobe events can be
> obtained.
>
> Signed-off-by: Pratyush Anand <panand at redhat.com>
> ---
> V1 to V2: Rebased to latest kernel.
>
> I see following stack trace for kprobe at xhci_irq():
>
> echo stacktrace > /sys/kernel/debug/tracing/trace_options
> echo "p xhci_irq" > /sys/kernel/debug/tracing/kprobe_events
> echo 1 > /sys/kernel/debug/tracing/events/kprobes/enable
> more /sys/kernel/debug/tracing/trace
>
> <idle>-0 [004] d.h. 1356.000496: p_xhci_irq_0:(xhci_irq+0x0/0x9ac)
> <idle>-0 [004] d.h. 1356.000497: <stack trace>
> => xhci_irq
> => __handle_irq_event_percpu
> => handle_irq_event_percpu
> => handle_irq_event
> => handle_fasteoi_irq
> => generic_handle_irq
> => __handle_domain_irq
> => gic_handle_irq
> => el1_irq
> => arch_cpu_idle
> => default_idle_call
> => cpu_startup_entry
> => secondary_start_kernel
> =>
>
> arch/arm64/kernel/stacktrace.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c
> index d9751a4769e7..bd6d9d8087f0 100644
> --- a/arch/arm64/kernel/stacktrace.c
> +++ b/arch/arm64/kernel/stacktrace.c
> @@ -152,6 +152,24 @@ static int save_trace(struct stackframe *frame, void *d)
> return trace->nr_entries >= trace->max_entries;
> }
>
> +void save_stack_trace_regs(struct pt_regs *regs, struct stack_trace *trace)
> +{
> + struct stack_trace_data data;
> + struct stackframe frame;
> +
> + data.trace = trace;
> + data.skip = trace->skip;
> + data.no_sched_functions = 0;
> +
> + frame.fp = regs->regs[29];
> + frame.sp = regs->sp;
> + frame.pc = regs->pc;
Interesting that arm64 does not define an "lr" field in struct
stackframe like 32-bit arm does.
> +
> + walk_stackframe(current, &frame, save_trace, &data);
> + if (trace->nr_entries < trace->max_entries)
> + trace->entries[trace->nr_entries++] = ULONG_MAX;
> +}
> +
> void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
> {
> struct stack_trace_data data;
>
Looks OK to me. I successfully (if briefly) tested it with v4.8-rc4 on
hikey.
Thanks,
-dl
More information about the linux-arm-kernel
mailing list