From: David Howells <dhowells@redhat.com>
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org, dhowells@redhat.com
Subject: [PATCH] printk simultaneous oops disentangling
Date: Thu, 22 Aug 2002 13:09:18 +0100 [thread overview]
Message-ID: <12669.1030018158@warthog.cambridge.redhat.com> (raw)
Hi Linus,
Here's a patch to stop multiple simultaneous oopses on an SMP system from
interleaving with and overwriting bits of each other. It only permits lock
breaking if the printk lock is held by the same CPU.
David
--- linux-2.5.31/kernel/printk.c Mon Jul 22 11:58:29 2002
+++ linux-trace-2531/kernel/printk.c Thu Aug 22 12:51:24 2002
@@ -390,6 +390,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.
*
@@ -412,8 +415,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);
@@ -421,6 +425,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);
@@ -450,6 +455,7 @@
* On some architectures, the consoles are not usable
* on secondary CPUs early in the boot process.
*/
+ printk_cpu = -1;
spin_unlock_irqrestore(&logbuf_lock, flags);
goto out;
}
@@ -458,6 +464,7 @@
* We own the drivers. We can drop the spinlock and let
* release_console_sem() print the text
*/
+ printk_cpu = -1;
spin_unlock_irqrestore(&logbuf_lock, flags);
console_may_schedule = 0;
release_console_sem();
@@ -467,6 +474,7 @@
* allows the semaphore holder to proceed and to call the
* console drivers with the output which we just produced.
*/
+ printk_cpu = -1;
spin_unlock_irqrestore(&logbuf_lock, flags);
}
out:
next reply other threads:[~2002-08-22 12:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-22 12:09 David Howells [this message]
2002-08-22 15:51 ` [PATCH] printk simultaneous oops disentangling Benjamin LaHaise
2002-08-22 15:57 ` Benjamin LaHaise
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=12669.1030018158@warthog.cambridge.redhat.com \
--to=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox