From: Petr Mladek <pmladek@suse.com>
Subject: [PATCH] printk: Switch to the sync mode when an emergency message is
printed
Patch-mainline: No, still being discussed upstream
References: bsc#1034995, bsc#1174146
The fix for bsc#995541 forced printk sync mode in suspend_console().
It was supposed to fix two problems:
+ Avoid calling wake_up_process() during suspend. It caused printk()
recursion when the timekeeping was already disabled.
+ Help to actually see the messages during the suspend when the
printk_kthread is not longer scheduled.
It solved the problem with the suspend but it does not work is some
other important situations, for example, kexec, shutdown. suspend_console()
is not called there. Note that we have disabled CONFIG_KEXEC_JUMP in
SLE12 kernels.
This patch switches to the sync mode when a message with LOGLEVEL_EMERG
is printed. It handles most of the interesting situations, including
kexec and shutdown.
Signed-off-by: Petr Mladek <pmladek@suse.com>
---
kernel/printk/printk.c | 8 ++++++++
1 file changed, 8 insertions(+)
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1995,6 +1995,14 @@ int vprintk_store(int facility, int leve
if (level == LOGLEVEL_DEFAULT)
level = default_message_loglevel;
+ /*
+ * Emergency level indicates that the system is unstable and, thus,
+ * we better stop relying on wake_up(printk_kthread) and try to do
+ * a direct printing.
+ */
+ if (level == LOGLEVEL_EMERG)
+ printk_force_sync_mode();
+
if (dict)
lflags |= LOG_NEWLINE;