History

kgdb: Flush console before entering kgdb on panic

When entering kdb/kgdb on a kernel panic, it was be observed that the console isn't flushed before the `kdb` prompt came up. Specifically, when using the buddy lockup detector on arm64 and running: echo HARDLOCKUP > /sys/kernel/debug/provoke-crash/DIRECT I could see: [ 26.161099] lkdtm: Performing direct entry HARDLOCKUP [ 32.499881] watchdog: Watchdog detected hard LOCKUP on cpu 6 [ 32.552865] Sending NMI from CPU 5 to CPUs 6: [ 32.557359] NMI backtrace for cpu 6 ... [backtrace for cpu 6] ... [ 32.558353] NMI backtrace for cpu 5 ... [backtrace for cpu 5] ... [ 32.867471] Sending NMI from CPU 5 to CPUs 0-4,7: [ 32.872321] NMI backtrace forP cpuANC: Hard LOCKUP Entering kdb (current=..., pid 0) on processor 5 due to Keyboard Entry [5]kdb> As you can see, backtraces for the other CPUs start printing and get interleaved with the kdb PANIC print. Let's replicate the commands to flush the console in the kdb panic entry point to avoid this.

Douglas Anderson committed 3 years ago

Commit dd712d31 parent 94f6f051 file · +3 −0Browse files

Showing the changes to kernel/debug (1 of 1 file). Show all

Unified · Split

kernel/debug/debug_core.c+3−0
@@ -1006,6 +1006,9 @@ void kgdb_panic(const char *msg) · 1005 unmodified lines
10061006 if (panic_timeout)
10071007 return;
10081008
1009+ debug_locks_off();
1010+ console_flush_on_panic(CONSOLE_FLUSH_PENDING);
1011+
10091012 if (dbg_kdb_mode)
10101013 kdb_printf("PANIC: %s\n", msg);
10111014