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 2277b492582d ("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.
Cc: Daniel Thompson <[email protected]>
Cc: Douglas Anderson <[email protected]>
Cc: Jason Wessel <[email protected]>
Cc: [email protected]
Signed-off-by: Dmitry Safonov <[email protected]>
---
kernel/debug/kdb/kdb_bt.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/kernel/debug/kdb/kdb_bt.c b/kernel/debug/kdb/kdb_bt.c
index 3de0cc780c16..43f5dcd2b9ac 100644
--- a/kernel/debug/kdb/kdb_bt.c
+++ b/kernel/debug/kdb/kdb_bt.c
@@ -21,17 +21,18 @@
static void kdb_show_stack(struct task_struct *p, void *addr)
{
- int old_lvl = console_loglevel;
-
- console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
kdb_trap_printk++;
- if (!addr && kdb_task_has_cpu(p))
+ if (!addr && kdb_task_has_cpu(p)) {
+ int old_lvl = console_loglevel;
+
+ console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
kdb_dump_stack_on_cpu(kdb_process_cpu(p));
- else
- show_stack(p, addr);
+ console_loglevel = old_lvl;
+ } else {
+ show_stack_loglvl(p, addr, KERN_EMERG);
+ }
- console_loglevel = old_lvl;
kdb_trap_printk--;
}
--
2.25.1
Hi,
On Mon, Mar 16, 2020 at 7:43 AM Dmitry Safonov <[email protected]> wrote:
>
> 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 2277b492582d ("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.
>
> Cc: Daniel Thompson <[email protected]>
> Cc: Douglas Anderson <[email protected]>
> Cc: Jason Wessel <[email protected]>
> Cc: [email protected]
> Signed-off-by: Dmitry Safonov <[email protected]>
> ---
> kernel/debug/kdb/kdb_bt.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
Presuming that the rest of this series is deemed acceptable by those
in charge, this patch looks fine to me:
Reviewed-by: Douglas Anderson <[email protected]>
-Doug
On Mon, Mar 16, 2020 at 02:39:13PM +0000, Dmitry Safonov wrote:
> 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 2277b492582d ("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.
>
> Cc: Daniel Thompson <[email protected]>
> Cc: Douglas Anderson <[email protected]>
> Cc: Jason Wessel <[email protected]>
> Cc: [email protected]
> Signed-off-by: Dmitry Safonov <[email protected]>
Acked-by: Daniel Thompson <[email protected]>
> ---
> kernel/debug/kdb/kdb_bt.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/kernel/debug/kdb/kdb_bt.c b/kernel/debug/kdb/kdb_bt.c
> index 3de0cc780c16..43f5dcd2b9ac 100644
> --- a/kernel/debug/kdb/kdb_bt.c
> +++ b/kernel/debug/kdb/kdb_bt.c
> @@ -21,17 +21,18 @@
>
> static void kdb_show_stack(struct task_struct *p, void *addr)
> {
> - int old_lvl = console_loglevel;
> -
> - console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
> kdb_trap_printk++;
>
> - if (!addr && kdb_task_has_cpu(p))
> + if (!addr && kdb_task_has_cpu(p)) {
> + int old_lvl = console_loglevel;
> +
> + console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
> kdb_dump_stack_on_cpu(kdb_process_cpu(p));
> - else
> - show_stack(p, addr);
> + console_loglevel = old_lvl;
> + } else {
> + show_stack_loglvl(p, addr, KERN_EMERG);
> + }
>
> - console_loglevel = old_lvl;
> kdb_trap_printk--;
> }
>
> --
> 2.25.1
>