2011-06-20 23:22:48

by Mandeep Singh Baines

[permalink] [raw]
Subject: [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).

Signed-off-by: Hugh Dickins <[email protected]>
Signed-off-by: Mandeep Singh Baines <[email protected]>
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(-)

diff --git a/kernel/panic.c b/kernel/panic.c
index 6923167..d7bb697 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -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
--
1.7.3.1


2011-06-20 23:25:06

by Mandeep Singh Baines

[permalink] [raw]
Subject: [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.

Signed-off-by: Mandeep Singh Baines <[email protected]>
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(-)

diff --git a/lib/bust_spinlocks.c b/lib/bust_spinlocks.c
index 9681d54..6a5c7e0 100644
--- a/lib/bust_spinlocks.c
+++ b/lib/bust_spinlocks.c
@@ -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)
--
1.7.3.1

2011-06-22 09:39:10

by Olaf Hering

[permalink] [raw]
Subject: Re: [PATCH 1/2] panic: panic=-1 for immediate reboot

On Mon, Jun 20, Mandeep Singh Baines wrote:

> 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

2011-06-22 22:18:07

by Mandeep Singh Baines

[permalink] [raw]
Subject: Re: [PATCH 1/2] panic: panic=-1 for immediate reboot

On Wed, Jun 22, 2011 at 2:39 AM, Olaf Hering <[email protected]> wrote:
> On Mon, Jun 20, Mandeep Singh Baines wrote:
>
>> 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?
>

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

> 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/
>

2011-06-22 22:31:40

by Mandeep Singh Baines

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

Mandeep Singh Baines ([email protected]) wrote:
> 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
Signed-off-by: Mandeep Singh Baines <[email protected]>
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(-)

diff --git a/include/linux/vt_kern.h b/include/linux/vt_kern.h
index 4d05e14..c2164fa 100644
--- a/include/linux/vt_kern.h
+++ b/include/linux/vt_kern.h
@@ -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;
}
--
1.7.3.1