kdb: don't play with console_loglevel

Print the stack trace with KERN_EMERG - it should be always visible.

Playing with console_loglevel is a bad idea as there may be more messages
printed than wanted.  Also the stack trace might be not printed at all if
printk() was deferred and console_loglevel was raised back before the
trace got flushed.

Unfortunately, after rebasing on commit 2277b49258 ("kdb: Fix stack
crawling on 'running' CPUs that aren't the master"), kdb_show_stack() uses
now kdb_dump_stack_on_cpu(), which for now won't be converted as it uses
dump_stack() instead of show_stack().

Convert for now the branch that uses show_stack() and remove
console_loglevel exercise from that case.

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Acked-by: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Jason Wessel <jason.wessel@windriver.com>
Link: http://lkml.kernel.org/r/20200418201944.482088-48-dima@arista.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Dmitry Safonov 2020-06-08 21:32:19 -07:00 committed by Linus Torvalds
parent 3f0543780e
commit 77819daf24

View File

@ -21,17 +21,18 @@
static void kdb_show_stack(struct task_struct *p, void *addr) static void kdb_show_stack(struct task_struct *p, void *addr)
{ {
kdb_trap_printk++;
if (!addr && kdb_task_has_cpu(p)) {
int old_lvl = console_loglevel; int old_lvl = console_loglevel;
console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH; console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
kdb_trap_printk++;
if (!addr && kdb_task_has_cpu(p))
kdb_dump_stack_on_cpu(kdb_process_cpu(p)); kdb_dump_stack_on_cpu(kdb_process_cpu(p));
else
show_stack(p, addr);
console_loglevel = old_lvl; console_loglevel = old_lvl;
} else {
show_stack_loglvl(p, addr, KERN_EMERG);
}
kdb_trap_printk--; kdb_trap_printk--;
} }