]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
arm64: add loglvl to dump_backtrace()
authorDmitry Safonov <dima@arista.com>
Tue, 9 Jun 2020 04:30:23 +0000 (21:30 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 9 Jun 2020 16:39:11 +0000 (09:39 -0700)
Currently, the log-level of show_stack() depends on a platform
realization.  It creates situations where the headers are printed with
lower log level or higher than the stacktrace (depending on a platform or
user).

Furthermore, it forces the logic decision from user to an architecture
side.  In result, some users as sysrq/kdb/etc are doing tricks with
temporary rising console_loglevel while printing their messages.  And in
result it not only may print unwanted messages from other CPUs, but also
omit printing at all in the unlucky case where the printk() was deferred.

Introducing log-level parameter and KERN_UNSUPPRESSED [1] seems an easier
approach than introducing more printk buffers.  Also, it will consolidate
printings with headers.

Add log level argument to dump_backtrace() as a preparation for
introducing show_stack_loglvl().

[1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/T/#u

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Will Deacon <will@kernel.org>
Link: http://lkml.kernel.org/r/20200418201944.482088-10-dima@arista.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/arm64/include/asm/stacktrace.h
arch/arm64/kernel/process.c
arch/arm64/kernel/traps.c

index 5017b531a41531d384a97046e0bc0efedb21abad..fc7613023c19209fdb7c015ddf647ff07ad892e9 100644 (file)
@@ -64,7 +64,8 @@ struct stackframe {
 extern int unwind_frame(struct task_struct *tsk, struct stackframe *frame);
 extern void walk_stackframe(struct task_struct *tsk, struct stackframe *frame,
                            int (*fn)(struct stackframe *, void *), void *data);
-extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk);
+extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
+                          const char *loglvl);
 
 DECLARE_PER_CPU(unsigned long *, irq_stack_ptr);
 
index eade7807e819d5637ea157315819ca136153e43d..6089638c7d43f4937194236da52abb281531bf12 100644 (file)
@@ -306,7 +306,7 @@ void __show_regs(struct pt_regs *regs)
 void show_regs(struct pt_regs * regs)
 {
        __show_regs(regs);
-       dump_backtrace(regs, NULL);
+       dump_backtrace(regs, NULL, KERN_DEFAULT);
 }
 
 static void tls_thread_flush(void)
index d332590f59782c9ede3aa955fe1f78ed62a1256b..f602aca64baaf8d88c3bd59860727fc1b9668e2e 100644 (file)
@@ -53,9 +53,9 @@ static const char *handler[]= {
 
 int show_unhandled_signals = 0;
 
-static void dump_backtrace_entry(unsigned long where)
+static void dump_backtrace_entry(unsigned long where, const char *loglvl)
 {
-       printk(" %pS\n", (void *)where);
+       printk("%s %pS\n", loglvl, (void *)where);
 }
 
 static void dump_kernel_instr(const char *lvl, struct pt_regs *regs)
@@ -83,7 +83,8 @@ static void dump_kernel_instr(const char *lvl, struct pt_regs *regs)
        printk("%sCode: %s\n", lvl, str);
 }
 
-void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
+void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
+                   const char *loglvl)
 {
        struct stackframe frame;
        int skip = 0;
@@ -115,11 +116,11 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
                                thread_saved_pc(tsk));
        }
 
-       printk("Call trace:\n");
+       printk("%sCall trace:\n", loglvl);
        do {
                /* skip until specified stack frame */
                if (!skip) {
-                       dump_backtrace_entry(frame.pc);
+                       dump_backtrace_entry(frame.pc, loglvl);
                } else if (frame.fp == regs->regs[29]) {
                        skip = 0;
                        /*
@@ -129,7 +130,7 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
                         * at which an exception has taken place, use regs->pc
                         * instead.
                         */
-                       dump_backtrace_entry(regs->pc);
+                       dump_backtrace_entry(regs->pc, loglvl);
                }
        } while (!unwind_frame(tsk, &frame));
 
@@ -138,7 +139,7 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
 
 void show_stack(struct task_struct *tsk, unsigned long *sp)
 {
-       dump_backtrace(NULL, tsk);
+       dump_backtrace(NULL, tsk, KERN_DEFAULT);
        barrier();
 }