* [PATCH] anti-cross-CPU printk/oops interleaving
@ 2003-07-04 9:11 David Howells
0 siblings, 0 replies; only message in thread
From: David Howells @ 2003-07-04 9:11 UTC (permalink / raw)
To: torvalds; +Cc: linux-kernel
Hi Linus,
This patch prevents an oops on one CPU being interleaved char-by-char with
printks being performed on other CPUs, thus rendering them actually readable
under those circumstances.
David
diff -ur linux-2.5.74/kernel/printk.c linux-2.5.74-auto/kernel/printk.c
--- linux-2.5.74/kernel/printk.c 2003-07-03 15:37:24.000000000 +0100
+++ linux-2.5.74-auto/kernel/printk.c 2003-07-03 15:41:15.000000000 +0100
@@ -378,6 +378,9 @@
logged_chars++;
}
+/* cpu currently holding logbuf_lock */
+static volatile int printk_cpu = -1;
+
/*
* This is printk. It can be called from any context. We want it to work.
*
@@ -400,8 +403,9 @@
static char printk_buf[1024];
static int log_level_unknown = 1;
- if (oops_in_progress) {
- /* If a crash is occurring, make sure we can't deadlock */
+ if (oops_in_progress && printk_cpu == smp_processor_id()) {
+ /* If a crash is occurring during printk() on this CPU,
+ * make sure we can't deadlock */
spin_lock_init(&logbuf_lock);
/* And make sure that we print immediately */
init_MUTEX(&console_sem);
@@ -409,6 +413,7 @@
/* This stops the holder of console_sem just where we want him */
spin_lock_irqsave(&logbuf_lock, flags);
+ printk_cpu = smp_processor_id();
/* Emit the output into the temporary buffer */
va_start(args, fmt);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-07-04 8:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-07-04 9:11 [PATCH] anti-cross-CPU printk/oops interleaving David Howells
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox