Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/dumpstack: Add log_lvl to show_iret_regs()

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

authored by

Dmitry Safonov and committed by
Thomas Gleixner
fd07f802 ba47d845

+6 -6
+1 -1
arch/x86/include/asm/kdebug.h
··· 37 37 extern int __must_check __die(const char *, struct pt_regs *, long); 38 38 extern void show_stack_regs(struct pt_regs *regs); 39 39 extern void __show_regs(struct pt_regs *regs, enum show_regs_mode); 40 - extern void show_iret_regs(struct pt_regs *regs); 40 + extern void show_iret_regs(struct pt_regs *regs, const char *log_lvl); 41 41 extern unsigned long oops_begin(void); 42 42 extern void oops_end(unsigned long, struct pt_regs *, int signr); 43 43
+4 -4
arch/x86/kernel/dumpstack.c
··· 126 126 show_opcodes(regs, loglvl); 127 127 } 128 128 129 - void show_iret_regs(struct pt_regs *regs) 129 + void show_iret_regs(struct pt_regs *regs, const char *log_lvl) 130 130 { 131 - show_ip(regs, KERN_DEFAULT); 132 - printk(KERN_DEFAULT "RSP: %04x:%016lx EFLAGS: %08lx", (int)regs->ss, 131 + show_ip(regs, log_lvl); 132 + printk("%sRSP: %04x:%016lx EFLAGS: %08lx", log_lvl, (int)regs->ss, 133 133 regs->sp, regs->flags); 134 134 } 135 135 ··· 155 155 * full pt_regs might not have been saved yet. In that case 156 156 * just print the iret frame. 157 157 */ 158 - show_iret_regs(regs); 158 + show_iret_regs(regs, KERN_DEFAULT); 159 159 } 160 160 } 161 161
+1 -1
arch/x86/kernel/process_64.c
··· 69 69 unsigned int fsindex, gsindex; 70 70 unsigned int ds, es; 71 71 72 - show_iret_regs(regs); 72 + show_iret_regs(regs, KERN_DEFAULT); 73 73 74 74 if (regs->orig_ax != -1) 75 75 pr_cont(" ORIG_RAX: %016lx\n", regs->orig_ax);