@@ -94,4 +94,15 @@ static inline bool on_accessible_stack(struct task_struct const *tsk,
return false;
}
+static inline void start_backtrace(struct stackframe *frame,
+ struct task_struct const *tsk,
+ unsigned long fp, unsigned long pc)
+{
+ frame->fp = fp;
+ frame->pc = pc;
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ frame.graph = tsk->curr_ret_stack;
+#endif
+}
+
#endif /* __ASM_STACKTRACE_H */
@@ -452,11 +452,7 @@ unsigned long get_wchan(struct task_struct *p)
if (!stack_page)
return 0;
- frame.fp = thread_saved_fp(p);
- frame.pc = thread_saved_pc(p);
-#ifdef CONFIG_FUNCTION_GRAPH_TRACER
- frame.graph = p->curr_ret_stack;
-#endif
+ start_backtrace(&frame, p, thread_saved_fp(p), thread_saved_pc(p));
do {
if (unwind_frame(p, &frame))
goto out;
@@ -49,11 +49,7 @@ unsigned long profile_pc(struct pt_regs *regs)
if (!in_lock_functions(regs->pc))
return regs->pc;
- frame.fp = regs->regs[29];
- frame.pc = regs->pc;
-#ifdef CONFIG_FUNCTION_GRAPH_TRACER
- frame.graph = current->curr_ret_stack;
-#endif
+ start_backtrace(&frame, current, regs->regs[29], regs->pc);
do {
int ret = unwind_frame(NULL, &frame);
if (ret < 0)
@@ -111,19 +111,14 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
if (!try_get_task_stack(tsk))
return;
- if (tsk == current) {
- frame.fp = (unsigned long)__builtin_frame_address(0);
- frame.pc = (unsigned long)dump_backtrace;
- } else {
- /*
- * task blocked in __switch_to
- */
- frame.fp = thread_saved_fp(tsk);
- frame.pc = thread_saved_pc(tsk);
- }
-#ifdef CONFIG_FUNCTION_GRAPH_TRACER
- frame.graph = tsk->curr_ret_stack;
-#endif
+ if (tsk == current)
+ start_backtrace(&frame, tsk,
+ (unsigned long)__builtin_frame_address(0),
+ (unsigned long)dump_backtrace);
+ else /* task blocked in __switch_to */
+ start_backtrace(&frame, tsk,
+ thread_saved_fp(tsk),
+ thread_saved_pc(tsk));
skip = !!regs;
printk("Call trace:\n");