Skip to contentSkip to conversation

panic: keep blinking in spite of long spin timer mode

PATCH Superseded TAMUKI Shoichi 2 participants 3 messages Jun 17, 2010 – Jun 20, 2010

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 panic: keep blinking in spite of long spin timer mode

To keep panic_timeout accuracy when running under a hypervisor, the current implementation only spins on long time (1 second) calls to mdelay. That brings a good effect, but the problem is the keyboard LEDs don't blink at all on that situation.

This patch changes to call to panic_blink_enter() between every mdelay and keeps blinking in spite of long spin timer mode.

The default time to call to mdelay is 1ms. It will be switched to longer if the CONFIG_PANIC_LONGSPIN_TIMER kernel configuration option is enabled. This feature is helpful when running under a hypervisor.

---
Changes since v2.1:
- get rid of panicblink= kernel parameter
- introduce new kernel config option CONFIG_PANIC_LONGSPIN_TIMER

 Documentation/kernel-parameters.txt |    3 -
 arch/arm/mach-s3c2440/mach-gta02.c  |   17 +-----
 drivers/input/serio/i8042.c         |   25 +--------
 include/linux/kernel.h              |    2 
 init/Kconfig                        |   15 +++++
 kernel/panic.c                      |   68 ++++++++++++++++----------
 6 files changed, 68 insertions(+), 62 deletions(-)
Documentation/kernel-parameters.txt +0 -3
index fa2f098..fd8a873 100644
@@ -911,9 +911,6 @@ and is between 256 and 4096 characters. It is defined in the file
 			     controller
 	i8042.nopnp	[HW] Don't use ACPIPnP / PnPBIOS to discover KBD/AUX
 			     controllers
-	i8042.panicblink=
-			[HW] Frequency with which keyboard LEDs should blink
-			     when kernel panics (default is 0.5 sec)
 	i8042.reset	[HW] Reset the controller during init and cleanup
 	i8042.unlock	[HW] Unlock (ignore) the keylock
 
arch/arm/mach-s3c2440/mach-gta02.c +5 -12
index 9e39faa..deaabe8 100644
@@ -90,24 +90,17 @@
 static struct pcf50633 *gta02_pcf;
 
 /*
- * This gets called every 1ms when we paniced.
+ * This gets called frequently when we paniced.
  */
 
-static long gta02_panic_blink(long count)
+static long gta02_panic_blink(int state)
 {
 	long delay = 0;
-	static long last_blink;
-	static char led;
+	char led;
 
-	/* Fast blink: 200ms period. */
-	if (count - last_blink < 100)
-		return 0;
-
-	led ^= 1;
+	led = (state) ? 1 : 0;
 	gpio_direction_output(GTA02_GPIO_AUX_LED, led);
 
-	last_blink = count;
-
 	return delay;
 }
 
@@ -556,7 +549,7 @@ static void gta02_poweroff(void)
 
 static void __init gta02_machine_init(void)
 {
-	/* Set the panic callback to make AUX LED blink at ~5Hz. */
+	/* Set the panic callback to turn AUX LED on or off. */
 	panic_blink = gta02_panic_blink;
 
 	s3c_pm_init();
drivers/input/serio/i8042.c +5 -20
index 6440a8f..c32d9b3 100644
@@ -61,10 +61,6 @@ static bool i8042_noloop;
 module_param_named(noloop, i8042_noloop, bool, 0);
 MODULE_PARM_DESC(noloop, "Disable the AUX Loopback command while probing for the AUX port");
 
-static unsigned int i8042_blink_frequency = 500;
-module_param_named(panicblink, i8042_blink_frequency, uint, 0600);
-MODULE_PARM_DESC(panicblink, "Frequency with which keyboard LEDs should blink when kernel panics");
-
 #ifdef CONFIG_X86
 static bool i8042_dritek;
 module_param_named(dritek, i8042_dritek, bool, 0);
@@ -1032,8 +1028,8 @@ static void i8042_controller_reset(void)
 
 
 /*
- * i8042_panic_blink() will flash the keyboard LEDs and is called when
- * kernel panics. Flashing LEDs is useful for users running X who may
+ * i8042_panic_blink() will turn the keyboard LEDs on or off and is called
+ * when kernel panics. Flashing LEDs is useful for users running X who may
  * not see the console and will help distingushing panics from "real"
  * lockups.
  *
@@ -1043,22 +1039,12 @@ static void i8042_controller_reset(void)
 
 #define DELAY do { mdelay(1); if (++delay > 10) return delay; } while(0)
 
-static long i8042_panic_blink(long count)
+static long i8042_panic_blink(int state)
 {
 	long delay = 0;
-	static long last_blink;
-	static char led;
-
-	/*
-	 * We expect frequency to be about 1/2s. KDB uses about 1s.
-	 * Make sure they are different.
-	 */
-	if (!i8042_blink_frequency)
-		return 0;
-	if (count - last_blink < i8042_blink_frequency)
-		return 0;
+	char led;
 
-	led ^= 0x01 | 0x04;
+	led = (state) ? 0x01 | 0x04 : 0;
 	while (i8042_read_status() & I8042_STR_IBF)
 		DELAY;
 	dbg("%02x -> i8042 (panic blink)", 0xed);
@@ -1071,7 +1057,6 @@ static long i8042_panic_blink(long count)
 	dbg("%02x -> i8042 (panic blink)", led);
 	i8042_write_data(led);
 	DELAY;
-	last_blink = count;
 	return delay;
 }
 
include/linux/kernel.h +1 -1
index 8317ec4..7d4552a 100644
@@ -172,7 +172,7 @@ static inline void might_fault(void)
 #endif
 
 extern struct atomic_notifier_head panic_notifier_list;
-extern long (*panic_blink)(long time);
+extern long (*panic_blink)(int state);
 NORET_TYPE void panic(const char * fmt, ...)
 	__attribute__ ((NORET_AND format (printf, 1, 2))) __cold;
 extern void oops_enter(void);
init/Kconfig +15 -0
index 05e932e..b37f6a6 100644
@@ -1171,6 +1171,21 @@ config SLOW_WORK_DEBUG
 
 	  See Documentation/slow-work.txt.
 
+config PANIC_LONGSPIN_TIMER
+	bool "Enable long spin timer mode when kernel panics"
+	default n
+	help
+	  On certain shared processor partitions, panic_timeout will be
+	  wildly inaccurate (a 3 minute panic_timeout taking 30 minutes).
+
+	  The fact is we loop on mdelay(1) and with a 1ms in 10ms hyper-
+	  visor timeslice each of these will take 10ms (i.e. 10x) longer.
+	  If you say Y here, spin on long time calls to mdelay to avoid
+	  this.
+
+	  This feature is helpful when running under such a special case
+	  like a hypervisor.  If unsure, say N.
+
 endmenu		# General setup
 
 config HAVE_GENERIC_DMA_COHERENT
kernel/panic.c +42 -26

106 lines not on this page · raw message

#1 lore raw
Quoted 12 lines · On Fri, 18 Jun 2010 06:36:31 +0900 TAMUKI Shoichi <[email protected]> wrote:

To keep panic_timeout accuracy when running under a hypervisor, the current implementation only spins on long time (1 second) calls to mdelay. That brings a good effect, but the problem is the keyboard LEDs don't blink at all on that situation.

This patch changes to call to panic_blink_enter() between every mdelay and keeps blinking in spite of long spin timer mode.

The default time to call to mdelay is 1ms. It will be switched to longer if the CONFIG_PANIC_LONGSPIN_TIMER kernel configuration option is enabled. This feature is helpful when running under a hypervisor.

Quoted 6 lines

---
Changes since v2.1:
- get rid of panicblink= kernel parameter
- introduce new kernel config option CONFIG_PANIC_LONGSPIN_TIMER

I still don't get it :(

Why can't we simply do

	for (i = 0; ; i++) {
		(*panic_blink)(i & 1);
		mdelay(250);
		touch_nmi_watchdog();
	}

on all kernels, regardless of virtualisation, etc?

#2 lore raw

Hello,

Quoted 22 lines · On Thu, 17 Jun 2010 15:20:17 -0700 Andrew Morton wrote:
Quoted 12 lines

To keep panic_timeout accuracy when running under a hypervisor, the current implementation only spins on long time (1 second) calls to mdelay. That brings a good effect, but the problem is the keyboard LEDs don't blink at all on that situation.

This patch changes to call to panic_blink_enter() between every mdelay and keeps blinking in spite of long spin timer mode.

The default time to call to mdelay is 1ms. It will be switched to longer if the CONFIG_PANIC_LONGSPIN_TIMER kernel configuration option is enabled. This feature is helpful when running under a hypervisor.

Quoted 5 lines

---
Changes since v2.1:
- get rid of panicblink= kernel parameter
- introduce new kernel config option CONFIG_PANIC_LONGSPIN_TIMER

I still don't get it :(

Why can't we simply do

Quoted 7 lines
	for (i = 0; ; i++) {
		(*panic_blink)(i & 1);
		mdelay(250);
		touch_nmi_watchdog();
	}

on all kernels, regardless of virtualisation, etc?

OK, I will commonize the time to call to mdelay() on the native case and the hypervisor case, and get rid of the kernel config option. I will adjust it to 100ms so as to keep the interval to call to touch_ nmi_watchdog() or touch_softlockup_watchdog() as much as possible. Even this change will keep panic_timeout accuracy enough when running under a hypervisor.

Thank you for the suggestion. See you next PATCH v4.

Regards,
TAMUKI Shoichi