History

softlockup: allow panic on lockup

allow users to configure the softlockup detector to generate a panic instead of a warning message. high-availability systems might opt for this strict method (combined with panic_timeout= boot option/sysctl), instead of generating softlockup warnings ad infinitum. also, automated tests work better if the system reboots reliably (into a safe kernel) in case of a lockup. The full spectrum of configurability is supported: boot option, sysctl option and Kconfig option. it's default-disabled.

Ingo Molnar committed 18 years ago

Commit 9c44bc01 parent 75d3bce5 files · +62 −2Browse files

Unified · Split

5 files
  1. Documentation/kernel-parameters.txt +3 −0
  2. include/linux/sched.h +2 −1
  3. kernel/softlockup.c +21 −0
  4. kernel/sysctl.c +11 −0
  5. lib/Kconfig.debug +25 −1
Documentation/kernel-parameters.txt+3−0
@@ -1971,6 +1971,9 @@ and is between 256 and 4096 characters. It is defined in the file · 1970 unmodified lines
19711971
19721972 snd-ymfpci= [HW,ALSA]
19731973
1974+ softlockup_panic=
1975+ [KNL] Should the soft-lockup detector generate panics.
1976+
19741977 sonypi.*= [HW] Sony Programmable I/O Control Device driver
19751978 See Documentation/sonypi.txt
19761979
include/linux/sched.h+2−1
@@ -294,7 +294,8 @@ extern void softlockup_tick(void); · 293 unmodified lines
294294 extern void spawn_softlockup_task(void);
295295 extern void touch_softlockup_watchdog(void);
296296 extern void touch_all_softlockup_watchdogs(void);
297−extern unsigned long softlockup_thresh;
297+extern unsigned int softlockup_panic;
298+extern unsigned long softlockup_thresh;
298299 extern unsigned long sysctl_hung_task_check_count;
299300 extern unsigned long sysctl_hung_task_timeout_secs;
300301 extern unsigned long sysctl_hung_task_warnings;
kernel/softlockup.c+21−0
@@ -27,6 +27,21 @@ static DEFINE_PER_CPU(struct task_struct *, watchdog_task); · 26 unmodified lines
2727 static int __read_mostly did_panic;
2828 unsigned long __read_mostly softlockup_thresh = 60;
2929
30+/*
31+ * Should we panic (and reboot, if panic_timeout= is set) when a
32+ * soft-lockup occurs:
33+ */
34+unsigned int __read_mostly softlockup_panic =
35+ CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE;
36+
37+static int __init softlockup_panic_setup(char *str)
38+{
39+ softlockup_panic = simple_strtoul(str, NULL, 0);
40+
41+ return 1;
42+}
43+__setup("softlockup_panic=", softlockup_panic_setup);
44+
3045 static int
3146 softlock_panic(struct notifier_block *this, unsigned long event, void *ptr)
3247 {
@@ -120,6 +135,9 @@ void softlockup_tick(void) · 87 unmodified lines
120135 else
121136 dump_stack();
122137 spin_unlock(&print_lock);
138+
139+ if (softlockup_panic)
140+ panic("softlockup: hung tasks");
123141 }
124142
125143 /*
@@ -172,6 +190,9 @@ static void check_hung_task(struct task_struct *t, unsigned long now) · 46 unmodified lines
172190
173191 t->last_switch_timestamp = now;
174192 touch_nmi_watchdog();
193+
194+ if (softlockup_panic)
195+ panic("softlockup: blocked tasks");
175196 }
176197
177198 /*
kernel/sysctl.c+11−0
@@ -727,6 +727,17 @@ static struct ctl_table kern_table[] = { · 726 unmodified lines
727727 },
728728 #endif
729729 #ifdef CONFIG_DETECT_SOFTLOCKUP
730+ {
731+ .ctl_name = CTL_UNNUMBERED,
732+ .procname = "softlockup_panic",
733+ .data = &softlockup_panic,
734+ .maxlen = sizeof(int),
735+ .mode = 0644,
736+ .proc_handler = &proc_doulongvec_minmax,
737+ .strategy = &sysctl_intvec,
738+ .extra1 = &zero,
739+ .extra2 = &one,
740+ },
730741 {
731742 .ctl_name = CTL_UNNUMBERED,
732743 .procname = "softlockup_thresh",
lib/Kconfig.debug+25−1
@@ -147,7 +147,7 @@ config DETECT_SOFTLOCKUP · 146 unmodified lines
147147 help
148148 Say Y here to enable the kernel to detect "soft lockups",
149149 which are bugs that cause the kernel to loop in kernel
150− mode for more than 10 seconds, without giving other tasks a
150+ mode for more than 60 seconds, without giving other tasks a
151151 chance to run.
152152
153153 When a soft-lockup is detected, the kernel will print the
@@ -159,6 +159,30 @@ config DETECT_SOFTLOCKUP · 5 unmodified lines
159159 can be detected via the NMI-watchdog, on platforms that
160160 support it.)
161161
162+config BOOTPARAM_SOFTLOCKUP_PANIC
163+ bool "Panic (Reboot) On Soft Lockups"
164+ depends on DETECT_SOFTLOCKUP
165+ help
166+ Say Y here to enable the kernel to panic on "soft lockups",
167+ which are bugs that cause the kernel to loop in kernel
168+ mode for more than 60 seconds, without giving other tasks a
169+ chance to run.
170+
171+ The panic can be used in combination with panic_timeout,
172+ to cause the system to reboot automatically after a
173+ lockup has been detected. This feature is useful for
174+ high-availability systems that have uptime guarantees and
175+ where a lockup must be resolved ASAP.
176+
177+ Say N if unsure.
178+
179+config BOOTPARAM_SOFTLOCKUP_PANIC_VALUE
180+ int
181+ depends on DETECT_SOFTLOCKUP
182+ range 0 1
183+ default 0 if !BOOTPARAM_SOFTLOCKUP_PANIC
184+ default 1 if BOOTPARAM_SOFTLOCKUP_PANIC
185+
162186 config SCHED_DEBUG
163187 bool "Collect scheduler debugging info"
164188 depends on DEBUG_KERNEL && PROC_FS

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t