Skip to contentSkip to conversation

panic: panic=-1 for immediate reboot

PATCH In review Mandeep Singh Baines 4 participants 10 messages Jun 20, 2011 – Jul 15, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 panic: panic=-1 for immediate reboot

From: Hugh Dickins <[email protected]>

When kernel BUG or oops occurs, ChromeOS intends to panic and immediately reboot, with stacktrace and other messages preserved in RAM across reboot. But the longer we delay, the more likely the user is to poweroff and lose the info.

panic_timeout (seconds before rebooting) is set by panic= boot option or sysctl or /proc/sys/kernel/panic; but 0 means wait forever, so at present we have to delay at least 1 second.

Let a negative number mean reboot immediately (with the small cosmetic benefit of suppressing that newline-less "Rebooting in %d seconds.." message).

Cc Andrew Morton <[email protected]>
Cc Huang Ying <[email protected]>
Cc Andi Kleen <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Olaf Hering <[email protected]>
---
 kernel/panic.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
kernel/panic.c +2 -0
index 6923167..d7bb697 100644
@@ -119,6 +119,8 @@ NORET_TYPE void panic(const char * fmt, ...)
 			}
 			mdelay(PANIC_TIMER_STEP);
 		}
+	}
+	if (panic_timeout != 0) {
 		/*
 		 * This will not be a clean reboot, with everything
 		 * shutting down.  But if there is a chance of
Signature · 1 line
1.7.3.1
#1 lore raw

PATCH 2/2 panic: do not unblank_screen when panic_timeout < 0

Avoid risk (of screen_unblank) and wasted cycles unblanking if you intend to reboot immediately.

Cc Andrew Morton <[email protected]>
Cc Huang Ying <[email protected]>
Cc Andi Kleen <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Olaf Hering <[email protected]>
Cc Jesse Barnes <[email protected]>
Cc Dave Airlie <[email protected]>
---
 lib/bust_spinlocks.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
lib/bust_spinlocks.c +2 -1
index 9681d54..6a5c7e0 100644
@@ -21,7 +21,8 @@ void __attribute__((weak)) bust_spinlocks(int yes)
 		++oops_in_progress;
 	} else {
 #ifdef CONFIG_VT
-		unblank_screen();
+		if (panic_timeout >= 0)
+			unblank_screen();
 #endif
 		console_unblank();
 		if (--oops_in_progress == 0)
Signature · 1 line
1.7.3.1
#2 lore raw

PATCH 1/1 panic, vt: do not force oops output when panic_timeout < 0

Quoted 3 lines · Mandeep Singh Baines

Avoid risk (of screen_unblank) and wasted cycles unblanking if you intend to reboot immediately.

The original patch doesn't work. It worked fine when I tested with a serial port. When I disabled the serial out, my machine started to get wedged on a panic. I guess screen_unblank was in bust_spinlocks for a reason. It probably bust some spin_locks somewhere.

Below is a replacement for this patch which calls screen_unblank but does not force output when the panic timeout is negative (no wait).

-- >8 -- (snip)

Don't force output if you intend to reboot immediately.

This patch depends on:

http://lkml.kernel.org/r/[email protected]

Change-Id I48f86746ac36d420b1b025197f50d5d56b873e9f
Cc Andrew Morton <[email protected]>
Cc Huang Ying <[email protected]>
Cc Andi Kleen <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Olaf Hering <[email protected]>
Cc Jesse Barnes <[email protected]>
Cc Dave Airlie <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 include/linux/vt_kern.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/vt_kern.h +1 -1
index 4d05e14..c2164fa 100644
@@ -137,7 +137,7 @@ int vty_init(const struct file_operations *console_fops);
 
 static inline bool vt_force_oops_output(struct vc_data *vc)
 {
-	if (oops_in_progress && vc->vc_panic_force_write)
+	if (oops_in_progress && vc->vc_panic_force_write  && panic_timeout >= 0)
 		return true;
 	return false;
 }
Signature · 1 line
1.7.3.1
maintainer
#3 lore raw

Re: [PATCH] panic, vt: do not force oops output when panic_timeout < 0

Quoted 13 lines · On Wed, 22 Jun 2011 15:30:39 -0700 Mandeep Singh Baines <[email protected]>…
Quoted 3 lines · Mandeep Singh Baines

Avoid risk (of screen_unblank) and wasted cycles unblanking if you intend to reboot immediately.

The original patch doesn't work. It worked fine when I tested with a serial port. When I disabled the serial out, my machine started to get wedged on a panic. I guess screen_unblank was in bust_spinlocks for a reason. It probably bust some spin_locks somewhere.

Below is a replacement for this patch which calls screen_unblank but does not force output when the panic timeout is negative (no wait).

Quoted 7 lines

-- >8 -- (snip)

Don't force output if you intend to reboot immediately.

This patch depends on:

http://lkml.kernel.org/r/[email protected]

Please fold this into that and resend the patch series. Please add the needed update to Documentation/kernel-parameters.txt.

#4 lore raw

Re: [PATCH] panic, vt: do not force oops output when panic_timeout < 0

Quoted 18 lines · Andrew Morton
Quoted 15 lines · On Wed, 22 Jun 2011 15:30:39 -0700 Mandeep Singh Baines <[email protected]>…
Quoted 3 lines · Mandeep Singh Baines

Avoid risk (of screen_unblank) and wasted cycles unblanking if you intend to reboot immediately.

The original patch doesn't work. It worked fine when I tested with a serial port. When I disabled the serial out, my machine started to get wedged on a panic. I guess screen_unblank was in bust_spinlocks for a reason. It probably bust some spin_locks somewhere.

Below is a replacement for this patch which calls screen_unblank but does not force output when the panic timeout is negative (no wait).

-- >8 -- (snip)

Quoted 8 lines
Quoted 5 lines

Don't force output if you intend to reboot immediately.

This patch depends on:

http://lkml.kernel.org/r/[email protected]

Please fold this into that and resend the patch series. Please add the needed update to Documentation/kernel-parameters.txt.

Done:

http://lkml.kernel.org/r/[email protected]

#5 lore raw

Re: [PATCH] panic, vt: do not force oops output when panic_timeout < 0

In reply to Mandeep Singh Baines
Quoted 3 lines

a serial port. When I disabled the serial out, my machine started to get wedged on a panic. I guess screen_unblank was in bust_spinlocks for a reason. It probably bust some spin_locks somewhere.

No something else is wrong here. The console panic should be reliably breaking the locks but a quick test of taking the console lock and BUG() on a current kernel shows something has broken this.

Quoted 2 lines

Below is a replacement for this patch which calls screen_unblank but does not force output when the panic timeout is negative (no wait).

The on screen console is not always just a vt, and some people log remote management console output so we really really don't want to do this.

Instead the bug in the lock busting needs fixing. To start with it will be hiding a ton of other oopses/bugs as hangs.

Alan

#6 lore raw

Re: [PATCH] panic, vt: do not force oops output when panic_timeout < 0

Quoted 8 lines · Alan Cox
Quoted 3 lines

a serial port. When I disabled the serial out, my machine started to get wedged on a panic. I guess screen_unblank was in bust_spinlocks for a reason. It probably bust some spin_locks somewhere.

No something else is wrong here. The console panic should be reliably breaking the locks but a quick test of taking the console lock and BUG() on a current kernel shows something has broken this.

Root caused to the issue I reported earlier with unblank_screen:

http://lkml.org/lkml/2011/6/20/394

console_unblank()
-> c_unblank()

    -> unblank_screen()
      -> ...
        -> mutex_lock()
Quoted 6 lines
Quoted 2 lines

Below is a replacement for this patch which calls screen_unblank but does not force output when the panic timeout is negative (no wait).

The on screen console is not always just a vt, and some people log remote management console output so we really really don't want to do this.

In this patch, I'm disabling the functionality enabled by vc->vc_panic_force_write if panic_timeout < 0 (i.e. no timeout). vc_panic_force_write is only enabled for fb video consoles if the FBINFO_CAN_FORCE_OUTPUT flag is set.

For our application, we're using ram_oops to preserved the panic in memory. We want to reliably, and as fast as possible, machine_restart. The vc_panic_force_write flag results in a bunch of graphics driver code to be invoked which slows down restart and decreases reliability. Since we're already storing the panic in RAM and are going to reboot immediately, there is no benefit in mode switching back to the vc in order to display the panic output. The log buffer will get flushed by the console_unblank() call so remote management consoles should see all output.

Quoted 4 lines

Instead the bug in the lock busting needs fixing. To start with it will be hiding a ton of other oopses/bugs as hangs.

Alan

#7 lore raw

Re: [PATCH] panic, vt: do not force oops output when panic_timeout < 0

Quoted 5 lines · On Fri, 15 Jul 2011 14:39:27 -0700 Mandeep Singh Baines <[email protected]>…
Quoted 4 lines · Alan Cox
Quoted 3 lines

a serial port. When I disabled the serial out, my machine started to get wedged on a panic. I guess screen_unblank was in bust_spinlocks for a reason. It probably bust some spin_locks somewhere.

Quoted 8 lines
Quoted 4 lines

No something else is wrong here. The console panic should be reliably breaking the locks but a quick test of taking the console lock and BUG() on a current kernel shows something has broken this.

Root caused to the issue I reported earlier with unblank_screen:

http://lkml.org/lkml/2011/6/20/394

Thanks - I missed that at the time and I'll take a look at it.

#8 lore raw
In reply to Mandeep Singh Baines
Quoted 6 lines · Mandeep Singh Baines

From: Hugh Dickins <[email protected]>

When kernel BUG or oops occurs, ChromeOS intends to panic and immediately reboot, with stacktrace and other messages preserved in RAM across reboot. But the longer we delay, the more likely the user is to poweroff and lose the info.

I have no strong opinion here, but:

Is delaying one second (instead of say 180 like on powerpc) such a big deal if the system is dead anyway?

Olaf

#9 lore raw
Quoted 9 lines · Olaf Hering
Quoted 6 lines · Mandeep Singh Baines

From: Hugh Dickins <[email protected]>

When kernel BUG or oops occurs, ChromeOS intends to panic and immediately reboot, with stacktrace and other messages preserved in RAM across reboot. But the longer we delay, the more likely the user is to poweroff and lose the info.

Quoted 5 lines

I have no strong opinion here, but:

Is delaying one second (instead of say 180 like on powerpc) such a big deal if the system is dead anyway?

Our kernel is configured to preserve the panic in RAM. So we don't get any benefit in waiting. On the reboot following the crash, the panic gets logged. If the user hits the power button instead of waiting for the panic, we lose the crash data. For this reason, we even set our lockup thresholds as low as we can.

Our system is almost stateless and our boot time is 8 seconds so a panic reboot cycle is not so bad. But the quicker we can get the system back up, the better.

Regards,
Mandeep

Quoted 7 lines

Olaf
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/