arm64: stacktrace: Factor out backtrace initialisation
Some common code is required by each stacktrace user to initialise struct stackframe before the first call to unwind_frame(). In preparation for adding to the common code, this patch factors it out into a separate function start_backtrace(), and modifies the stacktrace callers appropriately. No functional change. Signed-off-by: Dave Martin <dave.martin@arm.com> [Mark: drop tsk argument, update more callsites] Signed-off-by: Mark Rutland <mark.rutland@arm.com> Reviewed-by: James Morse <james.morse@arm.com> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Will Deacon <will@kernel.org>
This commit is contained in:
parent
8caa6e2be7
commit
f3dcbe67ed
|
@ -131,4 +131,14 @@ static inline bool on_accessible_stack(const struct task_struct *tsk,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void start_backtrace(struct stackframe *frame,
|
||||||
|
unsigned long fp, unsigned long pc)
|
||||||
|
{
|
||||||
|
frame->fp = fp;
|
||||||
|
frame->pc = pc;
|
||||||
|
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
||||||
|
frame->graph = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* __ASM_STACKTRACE_H */
|
#endif /* __ASM_STACKTRACE_H */
|
||||||
|
|
|
@ -154,12 +154,7 @@ void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
frame.fp = regs->regs[29];
|
start_backtrace(&frame, regs->regs[29], regs->pc);
|
||||||
frame.pc = regs->pc;
|
|
||||||
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
|
||||||
frame.graph = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
walk_stackframe(current, &frame, callchain_trace, entry);
|
walk_stackframe(current, &frame, callchain_trace, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -498,11 +498,8 @@ unsigned long get_wchan(struct task_struct *p)
|
||||||
if (!stack_page)
|
if (!stack_page)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
frame.fp = thread_saved_fp(p);
|
start_backtrace(&frame, thread_saved_fp(p), thread_saved_pc(p));
|
||||||
frame.pc = thread_saved_pc(p);
|
|
||||||
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
|
||||||
frame.graph = 0;
|
|
||||||
#endif
|
|
||||||
do {
|
do {
|
||||||
if (unwind_frame(p, &frame))
|
if (unwind_frame(p, &frame))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
@ -38,12 +38,9 @@ void *return_address(unsigned int level)
|
||||||
data.level = level + 2;
|
data.level = level + 2;
|
||||||
data.addr = NULL;
|
data.addr = NULL;
|
||||||
|
|
||||||
frame.fp = (unsigned long)__builtin_frame_address(0);
|
start_backtrace(&frame,
|
||||||
frame.pc = (unsigned long)return_address; /* dummy */
|
(unsigned long)__builtin_frame_address(0),
|
||||||
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
(unsigned long)return_address);
|
||||||
frame.graph = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
walk_stackframe(current, &frame, save_return_addr, &data);
|
walk_stackframe(current, &frame, save_return_addr, &data);
|
||||||
|
|
||||||
if (!data.level)
|
if (!data.level)
|
||||||
|
|
|
@ -122,12 +122,7 @@ void save_stack_trace_regs(struct pt_regs *regs, struct stack_trace *trace)
|
||||||
data.skip = trace->skip;
|
data.skip = trace->skip;
|
||||||
data.no_sched_functions = 0;
|
data.no_sched_functions = 0;
|
||||||
|
|
||||||
frame.fp = regs->regs[29];
|
start_backtrace(&frame, regs->regs[29], regs->pc);
|
||||||
frame.pc = regs->pc;
|
|
||||||
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
|
||||||
frame.graph = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
walk_stackframe(current, &frame, save_trace, &data);
|
walk_stackframe(current, &frame, save_trace, &data);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(save_stack_trace_regs);
|
EXPORT_SYMBOL_GPL(save_stack_trace_regs);
|
||||||
|
@ -146,17 +141,15 @@ static noinline void __save_stack_trace(struct task_struct *tsk,
|
||||||
data.no_sched_functions = nosched;
|
data.no_sched_functions = nosched;
|
||||||
|
|
||||||
if (tsk != current) {
|
if (tsk != current) {
|
||||||
frame.fp = thread_saved_fp(tsk);
|
start_backtrace(&frame, thread_saved_fp(tsk),
|
||||||
frame.pc = thread_saved_pc(tsk);
|
thread_saved_pc(tsk));
|
||||||
} else {
|
} else {
|
||||||
/* We don't want this function nor the caller */
|
/* We don't want this function nor the caller */
|
||||||
data.skip += 2;
|
data.skip += 2;
|
||||||
frame.fp = (unsigned long)__builtin_frame_address(0);
|
start_backtrace(&frame,
|
||||||
frame.pc = (unsigned long)__save_stack_trace;
|
(unsigned long)__builtin_frame_address(0),
|
||||||
|
(unsigned long)__save_stack_trace);
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
|
||||||
frame.graph = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
walk_stackframe(tsk, &frame, save_trace, &data);
|
walk_stackframe(tsk, &frame, save_trace, &data);
|
||||||
|
|
||||||
|
|
|
@ -38,11 +38,8 @@ unsigned long profile_pc(struct pt_regs *regs)
|
||||||
if (!in_lock_functions(regs->pc))
|
if (!in_lock_functions(regs->pc))
|
||||||
return regs->pc;
|
return regs->pc;
|
||||||
|
|
||||||
frame.fp = regs->regs[29];
|
start_backtrace(&frame, regs->regs[29], regs->pc);
|
||||||
frame.pc = regs->pc;
|
|
||||||
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
|
||||||
frame.graph = 0;
|
|
||||||
#endif
|
|
||||||
do {
|
do {
|
||||||
int ret = unwind_frame(NULL, &frame);
|
int ret = unwind_frame(NULL, &frame);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
|
|
@ -100,18 +100,17 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (tsk == current) {
|
if (tsk == current) {
|
||||||
frame.fp = (unsigned long)__builtin_frame_address(0);
|
start_backtrace(&frame,
|
||||||
frame.pc = (unsigned long)dump_backtrace;
|
(unsigned long)__builtin_frame_address(0),
|
||||||
|
(unsigned long)dump_backtrace);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* task blocked in __switch_to
|
* task blocked in __switch_to
|
||||||
*/
|
*/
|
||||||
frame.fp = thread_saved_fp(tsk);
|
start_backtrace(&frame,
|
||||||
frame.pc = thread_saved_pc(tsk);
|
thread_saved_fp(tsk),
|
||||||
|
thread_saved_pc(tsk));
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
|
||||||
frame.graph = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
printk("Call trace:\n");
|
printk("Call trace:\n");
|
||||||
do {
|
do {
|
||||||
|
|
Loading…
Reference in New Issue