Skip to content

Commit fef2c9b

Browse files
dzickusrhtorvalds
authored andcommitted
kernel/watchdog.c: allow hardlockup to panic by default
When a cpu is considered stuck, instead of limping along and just printing a warning, it is sometimes preferred to just panic, let kdump capture the vmcore and reboot. This gets the machine back into a stable state quickly while saving the info that got it into a stuck state to begin with. Add a Kconfig option to allow users to set the hardlockup to panic by default. Also add in a 'nmi_watchdog=nopanic' to override this. [[email protected]: fix strncmp length] Signed-off-by: Don Zickus <[email protected]> Acked-by: Peter Zijlstra <[email protected]> Reviewed-by: WANG Cong <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent b1b5f65 commit fef2c9b

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

Documentation/kernel-parameters.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -1597,11 +1597,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
15971597
Format: [state][,regs][,debounce][,die]
15981598

15991599
nmi_watchdog= [KNL,BUGS=X86] Debugging features for SMP kernels
1600-
Format: [panic,][num]
1600+
Format: [panic,][nopanic,][num]
16011601
Valid num: 0
16021602
0 - turn nmi_watchdog off
16031603
When panic is specified, panic when an NMI watchdog
1604-
timeout occurs.
1604+
timeout occurs (or 'nopanic' to override the opposite
1605+
default).
16051606
This is useful when you use a panic=... timeout and
16061607
need the box quickly up again.
16071608

kernel/watchdog.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,15 @@ static DEFINE_PER_CPU(struct perf_event *, watchdog_ev);
4848
* Should we panic when a soft-lockup or hard-lockup occurs:
4949
*/
5050
#ifdef CONFIG_HARDLOCKUP_DETECTOR
51-
static int hardlockup_panic;
51+
static int hardlockup_panic =
52+
CONFIG_BOOTPARAM_HARDLOCKUP_PANIC_VALUE;
5253

5354
static int __init hardlockup_panic_setup(char *str)
5455
{
5556
if (!strncmp(str, "panic", 5))
5657
hardlockup_panic = 1;
58+
else if (!strncmp(str, "nopanic", 7))
59+
hardlockup_panic = 0;
5760
else if (!strncmp(str, "0", 1))
5861
watchdog_enabled = 0;
5962
return 1;

lib/Kconfig.debug

+17
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,23 @@ config HARDLOCKUP_DETECTOR
171171
def_bool LOCKUP_DETECTOR && PERF_EVENTS && HAVE_PERF_EVENTS_NMI && \
172172
!ARCH_HAS_NMI_WATCHDOG
173173

174+
config BOOTPARAM_HARDLOCKUP_PANIC
175+
bool "Panic (Reboot) On Hard Lockups"
176+
depends on LOCKUP_DETECTOR
177+
help
178+
Say Y here to enable the kernel to panic on "hard lockups",
179+
which are bugs that cause the kernel to loop in kernel
180+
mode with interrupts disabled for more than 60 seconds.
181+
182+
Say N if unsure.
183+
184+
config BOOTPARAM_HARDLOCKUP_PANIC_VALUE
185+
int
186+
depends on LOCKUP_DETECTOR
187+
range 0 1
188+
default 0 if !BOOTPARAM_HARDLOCKUP_PANIC
189+
default 1 if BOOTPARAM_HARDLOCKUP_PANIC
190+
174191
config BOOTPARAM_SOFTLOCKUP_PANIC
175192
bool "Panic (Reboot) On Soft Lockups"
176193
depends on LOCKUP_DETECTOR

0 commit comments

Comments
 (0)