public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Andy Isaacson <adi@hexapodia.org>
Cc: Andi Kleen <ak@muc.de>,
	linux-kernel@vger.kernel.org, Andrew Morton <akpm@osdl.org>
Subject: Re: overlaping printk
Date: Thu, 20 May 2004 20:57:45 +0200	[thread overview]
Message-ID: <20040520185745.GA7706@elte.hu> (raw)
In-Reply-To: <20040520161901.GD13601@hexapodia.org>

[-- Attachment #1: Type: text/plain, Size: 429 bytes --]


* Andy Isaacson <adi@hexapodia.org> wrote:

> It looks like this will cause problems if the user experiences an oops
> during boot, runs for a few hours, and then has another oops.  Won't
> the second oops fail to break the lock, and end up just deadlocking?

i've attached a new patch that does what Andi suggested too - 
timestamping of the oopses. This way we will zap no sooner than 10 
seconds after the first oops.

	Ingo

[-- Attachment #2: bust-spinlocks-fix-2.6.6-A1 --]
[-- Type: text/plain, Size: 1514 bytes --]

--- linux/kernel/printk.c.orig	
+++ linux/kernel/printk.c	
@@ -55,6 +55,9 @@ EXPORT_SYMBOL(console_printk);
 
 int oops_in_progress;
 
+/* zap spinlocks only once: */
+unsigned long oops_timestamp;
+
 /*
  * console_sem protects the console_drivers list, and also
  * provides serialisation for access to the entire console
@@ -472,6 +475,23 @@ static void emit_log_char(char c)
 }
 
 /*
+ * Zap console related locks when oopsing. Only zap at most once
+ * every 10 seconds, to leave time for slow consoles to print a
+ * full oops.
+ */
+static inline void zap_locks(void)
+{
+	if (!time_after(jiffies, oops_timestamp + 10*HZ))
+		return;
+	oops_timestamp = jiffies;
+
+	/* If a crash is occurring, make sure we can't deadlock */
+	spin_lock_init(&logbuf_lock);
+	/* And make sure that we print immediately */
+	init_MUTEX(&console_sem);
+}
+
+/*
  * This is printk.  It can be called from any context.  We want it to work.
  * 
  * We try to grab the console_sem.  If we succeed, it's easy - we log the output and
@@ -493,12 +513,8 @@ asmlinkage int printk(const char *fmt, .
 	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 */
-		spin_lock_init(&logbuf_lock);
-		/* And make sure that we print immediately */
-		init_MUTEX(&console_sem);
-	}
+	if (unlikely(oops_in_progress))
+		zap_locks();
 
 	/* This stops the holder of console_sem just where we want him */
 	spin_lock_irqsave(&logbuf_lock, flags);

  reply	other threads:[~2004-05-20 18:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1XBEP-Mc-49@gated-at.bofh.it>
     [not found] ` <1XBXw-13D-3@gated-at.bofh.it>
     [not found]   ` <1XWpp-zy-9@gated-at.bofh.it>
2004-05-20 14:53     ` overlaping printk Andi Kleen
2004-05-20 15:19       ` Ingo Molnar
2004-05-20 15:53         ` Ingo Molnar
2004-05-20 16:19           ` Andy Isaacson
2004-05-20 18:57             ` Ingo Molnar [this message]
2004-05-20 23:11               ` Andrew Morton
2004-05-21  7:00                 ` Ingo Molnar
2004-05-19 15:55 Tuukka Toivonen
2004-05-19 16:03 ` Ricky Beam
2004-05-20 14:03   ` Ingo Molnar
  -- strict thread matches above, loose matches on Subject: below --
2004-05-19 15:19 Ricky Beam
2004-05-19 15:26 ` Tigran Aivazian
2004-05-19 15:31   ` Ricky Beam
2004-05-19 15:39 ` Randy.Dunlap
2004-05-20  7:21 ` Andrew Morton

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=20040520185745.GA7706@elte.hu \
    --to=mingo@elte.hu \
    --cc=adi@hexapodia.org \
    --cc=ak@muc.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /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