x86/dumpstack: Add log_lvl to show_iret_regs()
authorDmitry Safonov <dima@arista.com>
Mon, 29 Jun 2020 14:48:45 +0000 (15:48 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 22 Jul 2020 21:56:53 +0000 (23:56 +0200)
show_trace_log_lvl() provides x86 platform-specific way to unwind
backtrace with a given log level. Unfortunately, registers dump(s) are
not printed with the same log level - instead, KERN_DEFAULT is always
used.

Arista's switches uses quite common setup with rsyslog, where only
urgent messages goes to console (console_log_level=KERN_ERR), everything
else goes into /var/log/ as the console baud-rate often is indecently
slow (9600 bps).

Backtrace dumps without registers printed have proven to be as useful as
morning standups. Furthermore, in order to introduce KERN_UNSUPPRESSED
(which I believe is still the most elegant way to fix raciness of sysrq[1])
the log level should be passed down the stack to register dumping
functions. Besides, there is a potential use-case for printing traces
with KERN_DEBUG level [2] (where registers dump shouldn't appear with
higher log level).

Add log_lvl parameter to show_iret_regs() as a preparation to add it
to __show_regs() and show_regs_if_on_stack().

[1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/
[2]: https://lore.kernel.org/linux-doc/20190724170249.9644-1-dima@arista.com/

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Petr Mladek <pmladek@suse.com>
Link: https://lkml.kernel.org/r/20200629144847.492794-2-dima@arista.com
arch/x86/include/asm/kdebug.h
arch/x86/kernel/dumpstack.c
arch/x86/kernel/process_64.c

index 247ab14c630948d2e8f588cb5c5ee58069e111d1..da024bbda6f4552801ee488d8d920c5c2093d628 100644 (file)
@@ -37,7 +37,7 @@ void die_addr(const char *str, struct pt_regs *regs, long err, long gp_addr);
 extern int __must_check __die(const char *, struct pt_regs *, long);
 extern void show_stack_regs(struct pt_regs *regs);
 extern void __show_regs(struct pt_regs *regs, enum show_regs_mode);
-extern void show_iret_regs(struct pt_regs *regs);
+extern void show_iret_regs(struct pt_regs *regs, const char *log_lvl);
 extern unsigned long oops_begin(void);
 extern void oops_end(unsigned long, struct pt_regs *, int signr);
 
index b037cfa7c0c52ff98ddee8e4ea7ce9ae68800928..c36d629a25a822b7812163b53ec971e661c622ff 100644 (file)
@@ -126,10 +126,10 @@ void show_ip(struct pt_regs *regs, const char *loglvl)
        show_opcodes(regs, loglvl);
 }
 
-void show_iret_regs(struct pt_regs *regs)
+void show_iret_regs(struct pt_regs *regs, const char *log_lvl)
 {
-       show_ip(regs, KERN_DEFAULT);
-       printk(KERN_DEFAULT "RSP: %04x:%016lx EFLAGS: %08lx", (int)regs->ss,
+       show_ip(regs, log_lvl);
+       printk("%sRSP: %04x:%016lx EFLAGS: %08lx", log_lvl, (int)regs->ss,
                regs->sp, regs->flags);
 }
 
@@ -155,7 +155,7 @@ static void show_regs_if_on_stack(struct stack_info *info, struct pt_regs *regs,
                 * full pt_regs might not have been saved yet.  In that case
                 * just print the iret frame.
                 */
-               show_iret_regs(regs);
+               show_iret_regs(regs, KERN_DEFAULT);
        }
 }
 
index 9a97415b21394d24de456930cbcb2ab6f1b3c000..09bcb296cda691904a4b05b4d177369949869d42 100644 (file)
@@ -69,7 +69,7 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode)
        unsigned int fsindex, gsindex;
        unsigned int ds, es;
 
-       show_iret_regs(regs);
+       show_iret_regs(regs, KERN_DEFAULT);
 
        if (regs->orig_ax != -1)
                pr_cont(" ORIG_RAX: %016lx\n", regs->orig_ax);