panic: add an option to replay all the printk message in buffer

Currently on panic, kernel will lower the loglevel and print out pending
printk msg only with console_flush_on_panic().

Add an option for users to configure the "panic_print" to replay all
dmesg in buffer, some of which they may have never seen due to the
loglevel setting, which will help panic debugging .

[ keep the original console_flush_on_panic() inside panic()]
[ use logbuf lock to protect the console log index]
Signed-off-by: Feng Tang <>
Reviewed-by: Petr Mladek <>
Cc: Aaro Koskinen <>
Cc: Petr Mladek <>
Cc: Steven Rostedt <>
Cc: Sergey Senozhatsky <>
Cc: Kees Cook <>
Cc: Borislav Petkov <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
5 files changed