arm64: stacktrace: move dump functions to end of file
authorMark Rutland <mark.rutland@arm.com>
Tue, 11 Apr 2023 16:29:42 +0000 (17:29 +0100)
committerWill Deacon <will@kernel.org>
Tue, 11 Apr 2023 17:34:59 +0000 (18:34 +0100)
For historical reasons, the backtrace dumping functions are placed in
the middle of stacktrace.c, despite using functions defined later. For
clarity, and to make subsequent refactoring easier, move the dumping
functions to the end of stacktrace.c

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Kalesh Singh <kaleshsingh@google.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Madhavan T. Venkataraman <madvenka@linux.microsoft.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20230411162943.203199-3-mark.rutland@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kernel/stacktrace.c

index dd03feba80481333f937aa5d83885ce9ad594cf0..ee398cf5141fbc5a05b04907456ba2df991c3320 100644 (file)
@@ -140,39 +140,6 @@ static void notrace unwind(struct unwind_state *state,
 }
 NOKPROBE_SYMBOL(unwind);
 
-static bool dump_backtrace_entry(void *arg, unsigned long where)
-{
-       char *loglvl = arg;
-       printk("%s %pSb\n", loglvl, (void *)where);
-       return true;
-}
-
-void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
-                   const char *loglvl)
-{
-       pr_debug("%s(regs = %p tsk = %p)\n", __func__, regs, tsk);
-
-       if (regs && user_mode(regs))
-               return;
-
-       if (!tsk)
-               tsk = current;
-
-       if (!try_get_task_stack(tsk))
-               return;
-
-       printk("%sCall trace:\n", loglvl);
-       arch_stack_walk(dump_backtrace_entry, (void *)loglvl, tsk, regs);
-
-       put_task_stack(tsk);
-}
-
-void show_stack(struct task_struct *tsk, unsigned long *sp, const char *loglvl)
-{
-       dump_backtrace(NULL, tsk, loglvl);
-       barrier();
-}
-
 /*
  * Per-cpu stacks are only accessible when unwinding the current task in a
  * non-preemptible context.
@@ -237,3 +204,36 @@ noinline noinstr void arch_stack_walk(stack_trace_consume_fn consume_entry,
 
        unwind(&state, consume_entry, cookie);
 }
+
+static bool dump_backtrace_entry(void *arg, unsigned long where)
+{
+       char *loglvl = arg;
+       printk("%s %pSb\n", loglvl, (void *)where);
+       return true;
+}
+
+void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
+                   const char *loglvl)
+{
+       pr_debug("%s(regs = %p tsk = %p)\n", __func__, regs, tsk);
+
+       if (regs && user_mode(regs))
+               return;
+
+       if (!tsk)
+               tsk = current;
+
+       if (!try_get_task_stack(tsk))
+               return;
+
+       printk("%sCall trace:\n", loglvl);
+       arch_stack_walk(dump_backtrace_entry, (void *)loglvl, tsk, regs);
+
+       put_task_stack(tsk);
+}
+
+void show_stack(struct task_struct *tsk, unsigned long *sp, const char *loglvl)
+{
+       dump_backtrace(NULL, tsk, loglvl);
+       barrier();
+}