linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] printk/nmi: restore printk_func in nmi_panic
@ 2016-02-26  3:37 Sergey Senozhatsky
  2016-02-26 14:57 ` Petr Mladek
  0 siblings, 1 reply; 11+ messages in thread
From: Sergey Senozhatsky @ 2016-02-26  3:37 UTC (permalink / raw)
  To: Petr Mladek
  Cc: Andrew Morton, Jan Kara, Peter Zijlstra, Steven Rostedt,
	Ingo Molnar, linux-kernel, Sergey Senozhatsky, Sergey Senozhatsky

When watchdog detects a hardlockup and calls nmi_panic() `printk_func'
must be restored via printk_nmi_exit() call, so panic() will be able
to flush nmi buf and show backtrace and panic message. We also better
explicitly ask nmi to printk_nmi_flush() in console_flush_on_panic(),
because it may be too late to rely on irq work.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
 include/linux/kernel.h | 6 ++++--
 kernel/printk/printk.c | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index f4fa2b2..3ee33d5 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -469,10 +469,12 @@ do {									\
 	cpu = raw_smp_processor_id();					\
 	old_cpu = atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, cpu);	\
 									\
-	if (old_cpu == PANIC_CPU_INVALID)				\
+	if (old_cpu == PANIC_CPU_INVALID) {				\
+		printk_nmi_exit();					\
 		panic(fmt, ##__VA_ARGS__);				\
-	else if (old_cpu != cpu)					\
+	} else if (old_cpu != cpu) {					\
 		nmi_panic_self_stop(regs);				\
+	}								\
 } while (0)
 
 /*
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 9917f69..13a4022 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2395,6 +2395,7 @@ void console_flush_on_panic(void)
 	 */
 	console_trylock();
 	console_may_schedule = 0;
+	printk_nmi_flush();
 	console_unlock();
 }
 
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-03-01 13:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-26  3:37 [PATCH] printk/nmi: restore printk_func in nmi_panic Sergey Senozhatsky
2016-02-26 14:57 ` Petr Mladek
2016-02-27  2:19   ` Sergey Senozhatsky
2016-02-27  3:09     ` Sergey Senozhatsky
2016-02-27  3:33       ` Sergey Senozhatsky
2016-02-28  3:52         ` Sergey Senozhatsky
2016-02-29 10:31     ` Petr Mladek
2016-02-29 11:19       ` Sergey Senozhatsky
2016-03-01  9:24         ` Sergey Senozhatsky
2016-03-01 11:05           ` Petr Mladek
2016-03-01 13:14             ` Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).