Skip to contentSkip to conversation

Introduce softpanic

PATCH In review Bodo Eggert 6 participants 10 messages Jan 25, 2008 – Feb 2, 2008 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Introduce softpanic

Enabling this option changes a hard panic on boot errors to a soft panic, which does not stop the system completely. You can still scroll the screen and read the messages.

include/linux/kernel.h +6 -0
diff -pruN -X dontdiff linux-2.6.24.pure/include/linux/kernel.h linux-2.6.24.softpanic/include/linux/kernel.h
@@ -130,6 +130,12 @@ extern struct atomic_notifier_head panic
 extern long (*panic_blink)(long time);
 NORET_TYPE void panic(const char * fmt, ...)
 	__attribute__ ((NORET_AND format (printf, 1, 2))) __cold;
+#ifdef SOFTPANIC
+NORET_TYPE void softpanic(const char *fmt, ...)
+	__attribute__ ((NORET_AND format (printf, 1, 2))) __cold;
+#else
+# define softpanic(...) do { panic(__VA_ARGS__); } while (0)
+#endif
 extern void oops_enter(void);
 extern void oops_exit(void);
 extern int oops_may_print(void);
init/Kconfig +8 -0
diff -pruN -X dontdiff linux-2.6.24.pure/init/Kconfig linux-2.6.24.softpanic/init/Kconfig
@@ -526,6 +526,14 @@ config BUG
           option for embedded systems with no facilities for reporting errors.
           Just say Y.
 
+config SOFTPANIC
+	bool "Enable softpanic for boot errors" if EMBEDDED
+	default y
+	help
+		Enabling this option changes a hard panic on boot errors to a
+		soft panic, which does not stop the system completely.
+		You can still scroll the screen and read the messages.
+
 config ELF_CORE
 	default y
 	bool "Enable ELF core dumps" if EMBEDDED
init/do_mounts.c +2 -2
diff -pruN -X dontdiff linux-2.6.24.pure/init/do_mounts.c linux-2.6.24.softpanic/init/do_mounts.c
@@ -330,7 +330,7 @@ retry:
 		printk("Please append a correct \"root=\" boot option; here are the available partitions:\n");
 
 		printk_all_partitions();
-		panic("VFS: Unable to mount root fs on %s", b);
+		softpanic("VFS: Unable to mount root fs on %s", b);
 	}
 
 	printk("List of all partitions:\n");
@@ -342,7 +342,7 @@ retry:
 #ifdef CONFIG_BLOCK
 	__bdevname(ROOT_DEV, b);
 #endif
-	panic("VFS: Unable to mount root fs on %s", b);
+	softpanic("VFS: Unable to mount root fs on %s", b);
 out:
 	putname(fs_names);
 }
init/main.c +2 -2
diff -pruN -X dontdiff linux-2.6.24.pure/init/main.c linux-2.6.24.softpanic/init/main.c
@@ -585,7 +585,7 @@ asmlinkage void __init start_kernel(void
 	 */
 	console_init();
 	if (panic_later)
-		panic(panic_later, panic_param);
+		softpanic(panic_later, panic_param);
 
 	lockdep_info();
 
@@ -800,7 +800,7 @@ static int noinline init_post(void)
 	run_init_process("/bin/init");
 	run_init_process("/bin/sh");
 
-	panic("No init found.  Try passing init= option to kernel.");
+	softpanic("No init found.  Try passing init= option to kernel.");
 }
 
 static int __init kernel_init(void * unused)
kernel/panic.c +60 -0

66 lines not on this page · raw message

Signature · 2 lines
Top 100 things you don't want the sysadmin to say:
21. where did you say those backup tapes were kept?
#1 lore raw
Quoted 3 lines · Bodo Eggert

Enabling this option changes a hard panic on boot errors to a soft panic, which does not stop the system completely. You can still scroll the screen and read the messages.

I don't think it's a good idea to keep the network running in the soft panic. A lot of people have set ups that use ping was a watchdog and with nfsroot/ip=dhcp ping does work quite well before mounting root and then the watchdog might not pick up the soft panic.

Using a polled keyboard driver after panic seems to be the better option to me, but if you want softpanic you should probably at least add a suitable panic notifier to the network stack to shut it all down.

-Andi

#2 lore raw
Quoted 11 lines · Andi Kleen
Quoted 3 lines · Bodo Eggert

Enabling this option changes a hard panic on boot errors to a soft panic, which does not stop the system completely. You can still scroll the screen and read the messages.

I don't think it's a good idea to keep the network running in the soft panic. A lot of people have set ups that use ping was a watchdog and with nfsroot/ip=dhcp ping does work quite well before mounting root and then the watchdog might not pick up the soft panic.

If the machine goes oops and softlocks (e.g. bug in root filesystem, lock held but not released, box essentially dead), ping also still works even though you'd probably want to trigger the watchdog too.

Quoted 4 lines

Using a polled keyboard driver after panic seems to be the better option to me, but if you want softpanic you should probably at least add a suitable panic notifier to the network stack to shut it all down.

or that.

#3 lore raw
In reply to Andi Kleen
Quoted 12 lines · Andi Kleen
Quoted 3 lines · Bodo Eggert

Enabling this option changes a hard panic on boot errors to a soft panic, which does not stop the system completely. You can still scroll the screen and read the messages.

I don't think it's a good idea to keep the network running in the soft panic. A lot of people have set ups that use ping was a watchdog and with nfsroot/ip=dhcp ping does work quite well before mounting root and then the watchdog might not pick up the soft panic.

Quoted 4 lines

Using a polled keyboard driver after panic seems to be the better option to me, but if you want softpanic you should probably at least add a suitable panic notifier to the network stack to shut it all down.

I have no idea on how to do it. If somebody has a big red arrow pointing to a HOWTO, I can give it a try.

OTOH, I think the panic timeout should do the job nicely.

Signature · 4 lines
If you talk about race, it does not make you a racist. If you see distinctions
between the genders, it does not make you a sexist. If you think critically
about a denomination, it does not make you anti-religion. If you accept but
don't celebrate homosexuality, it does not make you a homophobe.Charlton Heston
#4 lore raw
In reply to Andi Kleen
Quoted 12 lines · Andi Kleen
Quoted 3 lines · Bodo Eggert

Enabling this option changes a hard panic on boot errors to a soft panic, which does not stop the system completely. You can still scroll the screen and read the messages.

I don't think it's a good idea to keep the network running in the soft panic. A lot of people have set ups that use ping was a watchdog and with nfsroot/ip=dhcp ping does work quite well before mounting root and then the watchdog might not pick up the soft panic.

Quoted 4 lines

Using a polled keyboard driver after panic seems to be the better option to me, but if you want softpanic you should probably at least add a suitable panic notifier to the network stack to shut it all down.

OTOH this will allow netconsole/sysrq over it to still work after softpanic, which is good. Lets not over engineer it, I think current code is fine.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#6 lore raw
Quoted 5 lines · Jan Engelhardt
Quoted 1 line · Bodo Eggert

+#ifdef SOFTPANIC

#ifdef CONFIG_SOFTPANIC?

Thanks. I remember having fixed it ...

Signature · 1 line
Professionals are predictable, it's the amateurs that are dangerous.
#7 lore raw

PATCH 1/1 Introduce softpanic V.2

Enabling this option changes a hard panic on boot errors to a soft panic, which does not stop the system completely. You can still scroll the screen and read the messages.

---

Fixed: s/SOFTPANIC/CONFIG_SOFTPANIC/

I did not implement shutting down the network on panic, which was requested to let the watchdog reboot the machine. For this purpose, you should use "panic=$n".

include/linux/kernel.h +6 -0
diff -pruN -X dontdiff linux-2.6.24.pure/include/linux/kernel.h linux-2.6.24.softpanic/include/linux/kernel.h
@@ -130,6 +130,12 @@ extern struct atomic_notifier_head panic
 extern long (*panic_blink)(long time);
 NORET_TYPE void panic(const char * fmt, ...)
 	__attribute__ ((NORET_AND format (printf, 1, 2))) __cold;
+#ifdef SOFTPANIC
+NORET_TYPE void softpanic(const char *fmt, ...)
+	__attribute__ ((NORET_AND format (printf, 1, 2))) __cold;
+#else
+# define softpanic(...) do { panic(__VA_ARGS__); } while (0)
+#endif
 extern void oops_enter(void);
 extern void oops_exit(void);
 extern int oops_may_print(void);
init/Kconfig +8 -0
diff -pruN -X dontdiff linux-2.6.24.pure/init/Kconfig linux-2.6.24.softpanic/init/Kconfig
@@ -526,6 +526,14 @@ config BUG
           option for embedded systems with no facilities for reporting errors.
           Just say Y.
 
+config SOFTPANIC
+	bool "Enable softpanic for boot errors" if EMBEDDED
+	default y
+	help
+		Enabling this option changes a hard panic on boot errors to a
+		soft panic, which does not stop the system completely.
+		You can still scroll the screen and read the messages.
+
 config ELF_CORE
 	default y
 	bool "Enable ELF core dumps" if EMBEDDED
init/do_mounts.c +2 -2
diff -pruN -X dontdiff linux-2.6.24.pure/init/do_mounts.c linux-2.6.24.softpanic/init/do_mounts.c
@@ -330,7 +330,7 @@ retry:
 		printk("Please append a correct \"root=\" boot option; here are the available partitions:\n");
 
 		printk_all_partitions();
-		panic("VFS: Unable to mount root fs on %s", b);
+		softpanic("VFS: Unable to mount root fs on %s", b);
 	}
 
 	printk("List of all partitions:\n");
@@ -342,7 +342,7 @@ retry:
 #ifdef CONFIG_BLOCK
 	__bdevname(ROOT_DEV, b);
 #endif
-	panic("VFS: Unable to mount root fs on %s", b);
+	softpanic("VFS: Unable to mount root fs on %s", b);
 out:
 	putname(fs_names);
 }
init/main.c +2 -2
diff -pruN -X dontdiff linux-2.6.24.pure/init/main.c linux-2.6.24.softpanic/init/main.c
@@ -585,7 +585,7 @@ asmlinkage void __init start_kernel(void
 	 */
 	console_init();
 	if (panic_later)
-		panic(panic_later, panic_param);
+		softpanic(panic_later, panic_param);
 
 	lockdep_info();
 
@@ -800,7 +800,7 @@ static int noinline init_post(void)
 	run_init_process("/bin/init");
 	run_init_process("/bin/sh");
 
-	panic("No init found.  Try passing init= option to kernel.");
+	softpanic("No init found.  Try passing init= option to kernel.");
 }
 
 static int __init kernel_init(void * unused)
kernel/panic.c +60 -0

66 lines not on this page · raw message

Signature · 2 lines
Top 100 things you don't want the sysadmin to say:
15. now it's funny you should ask that, because I don't know either
#8 lore raw
In reply to Bodo Eggert
Quoted 3 lines · Bodo Eggert

Enabling this option changes a hard panic on boot errors to a soft panic, which does not stop the system completely. You can still scroll the screen and read the messages.

Hi Bodo,

if you are willing to put some effort into the ability to scroll the console after panic, it might be worthwile to look making the keyboard driver work even after panic (i.e. poll the keyboard, rather than relying on interrupts).

That has significantly smaller potential of breaking because the system is expected to be dead after panic (watchdogs, broken data structures in memory, etc).

Signature · 1 line
Jiri Kosina
#9 lore raw
Quoted 8 lines · Jiri Kosina
Quoted 3 lines · Bodo Eggert

Enabling this option changes a hard panic on boot errors to a soft panic, which does not stop the system completely. You can still scroll the screen and read the messages.

Hi Bodo,

Quoted 8 lines

if you are willing to put some effort into the ability to scroll the console after panic, it might be worthwile to look making the keyboard driver work even after panic (i.e. poll the keyboard, rather than relying on interrupts).

That has significantly smaller potential of breaking because the system is expected to be dead after panic (watchdogs, broken data structures in memory, etc).

I think Bodo is trying to address one specific (but quite common) corner case, where we currently panic() only because there's nothing else that makes sense - if we can't find the root fs, we're hosed. But (barring *other* oops/etc issues), we're still up and running, our data structures are intact, and there's no real reason we can't use such kernel services as we want (such as the screen scroller) to help the sysadmin figure out what he misconfigured.

If we were trying to do a *general case* handler for post-panic, yes, we'd want to do the polled keyboard and all that....