diff mbox series

[2/3] arm64: stacktrace: move dump functions to end of file

Message ID 20230324134958.2496891-3-mark.rutland@arm.com (mailing list archive)
State New, archived
Headers show
Series arm64: stacktrace: cleanups | expand

Commit Message

Mark Rutland March 24, 2023, 1:49 p.m. UTC
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>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Kalesh Singh <kaleshsingh@google.com>
Cc: Madhavan T. Venkataraman <madvenka@linux.microsoft.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Will Deacon <will@kernel.org>
---
 arch/arm64/kernel/stacktrace.c | 66 +++++++++++++++++-----------------
 1 file changed, 33 insertions(+), 33 deletions(-)

Comments

Kalesh Singh March 29, 2023, 8:58 a.m. UTC | #1
On Fri, Mar 24, 2023 at 6:50 AM Mark Rutland <mark.rutland@arm.com> wrote:
>
> 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>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Kalesh Singh <kaleshsingh@google.com>
> Cc: Madhavan T. Venkataraman <madvenka@linux.microsoft.com>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Will Deacon <will@kernel.org>

Reviewed-by: Kalesh Singh <kaleshsingh@google.com>

Thanks,
Kalesh

> ---
>  arch/arm64/kernel/stacktrace.c | 66 +++++++++++++++++-----------------
>  1 file changed, 33 insertions(+), 33 deletions(-)
>
> diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c
> index 219ce0668a3dd..5857e2de147a7 100644
> --- a/arch/arm64/kernel/stacktrace.c
> +++ b/arch/arm64/kernel/stacktrace.c
> @@ -139,39 +139,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.
> @@ -236,3 +203,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();
> +}
> --
> 2.30.2
>
diff mbox series

Patch

diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c
index 219ce0668a3dd..5857e2de147a7 100644
--- a/arch/arm64/kernel/stacktrace.c
+++ b/arch/arm64/kernel/stacktrace.c
@@ -139,39 +139,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.
@@ -236,3 +203,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();
+}