Re: [PATCH v3] decode_stacktrace: Decode caller address

From: Luca Ceresoli

Date: Tue Mar 10 2026 - 14:40:48 EST


Hello Masami,

On Fri Mar 6, 2026 at 1:50 AM CET, Masami Hiramatsu (Google) wrote:
> From: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
>
> Decode the caller address instead of the return address by default.
> This also introduced -R option to provide return address decoding
> mode.
>
> This changes the decode_stacktrace.sh to decode the line info 1byte
> before the return address which will be the call(branch) instruction
> address. If the return address is a symbol address (zero offset from
> it), it falls back to decoding the return address.
>
> This improves results especially when optimizations have changed the
> order of the lines around the return address, or when the return
> address does not have the actual line information.
>
> With this change;
> Call Trace:
> <TASK>
> dump_stack_lvl (lib/dump_stack.c:94 lib/dump_stack.c:120)
> lockdep_rcu_suspicious (kernel/locking/lockdep.c:6876)
> event_filter_pid_sched_process_fork (kernel/trace/trace_events.c:1057)
> kernel_clone (include/trace/events/sched.h:396 include/trace/events/sched.h:396 kernel/fork.c:2664)
> __x64_sys_clone (kernel/fork.c:2795 kernel/fork.c:2779 kernel/fork.c:2779)
> do_syscall_64 (arch/x86/entry/syscall_64.c:63 arch/x86/entry/syscall_64.c:94)
> ? entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
> ? trace_irq_disable (include/trace/events/preemptirq.h:36)
> entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
>
>
> Without this (or give -R option);
> Call Trace:
> <TASK>
> dump_stack_lvl (lib/dump_stack.c:122)
> lockdep_rcu_suspicious (kernel/locking/lockdep.c:6877)
> event_filter_pid_sched_process_fork (kernel/trace/trace_events.c:?)
> kernel_clone (include/trace/events/sched.h:? include/trace/events/sched.h:396 kernel/fork.c:2664)
> __x64_sys_clone (kernel/fork.c:2779)
> do_syscall_64 (arch/x86/entry/syscall_64.c:?)
> ? entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130)
> ? trace_irq_disable (include/trace/events/preemptirq.h:36)
> entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130)
>
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>

An oops just happened on some code I'm working on on ARM64 (i.MX8MP) and
decode_stacktrace produced a way more precise output with the patch
applied.

Tested-by: Luca Ceresoli <luca.ceresoli@xxxxxxxxxxx> # arm64

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com