[PATCH 1/3] arm64: stacktrace: recover return address for first entry

Mark Rutland mark.rutland at arm.com
Tue Apr 11 09:12:03 PDT 2023


On Thu, Apr 06, 2023 at 04:25:50PM +0100, Will Deacon wrote:
> On Fri, Mar 24, 2023 at 01:49:56PM +0000, Mark Rutland wrote:
> > +static __always_inline int
> > +unwind_recover_return_address(struct unwind_state *state)
> > +{
> > +	struct task_struct *tsk = state->task;
> > +
> > +#ifdef CONFIG_FUNCTION_GRAPH_TRACER
> > +	if (tsk->ret_stack &&
> > +	    (state->pc == (unsigned long)return_to_handler)) {
> > +		unsigned long orig_pc;
> > +		orig_pc = ftrace_graph_ret_addr(tsk, NULL, state->pc,
> > +						(void *)state->fp);
> > +		if (WARN_ON_ONCE(state->pc == orig_pc))
> > +			return -EINVAL;
> > +		state->pc = orig_pc;
> > +	}
> > +#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
> > +
> > +#ifdef CONFIG_KRETPROBES
> > +	if (is_kretprobe_trampoline(state->pc))
> > +		state->pc = kretprobe_find_ret_addr(tsk, (void *)state->fp, &state->kr_cur);
> > +#endif /* CONFIG_KRETPROBES */
> > +
> > +	return 0;
> > +}
> 
> This generates an unused variable warning with defconfig:
> 
> arch/arm64/kernel/stacktrace.c: In function ‘unwind_recover_return_address’:
> arch/arm64/kernel/stacktrace.c:78:22: warning: unused variable ‘tsk’ [-Wunused-variable]
>    78 |  struct task_struct *tsk = state->task;
>       |                      ^~~

Sorry about that; I had tested with and without each of
CONFIG_FUNCTION_GRAPH_TRACER and CONFIG_KRETPROBES, but hadn't tested without
both of them.

I'll get rid of `tsk` and use `state->task` directly in each case for v2.

Thanks,
Mark.



More information about the linux-arm-kernel mailing list