Skip to content

Commit 9232c80

Browse files
0x7f454c46Wim Van Sebroeck
authored andcommitted
watchdog: Add stop_on_reboot parameter to control reboot policy
Many watchdog drivers use watchdog_stop_on_reboot() helper in order to stop the watchdog on system reboot. Unfortunately, this logic is coded in driver's probe function and doesn't allows user to decide what to do during shutdown/reboot. On the other side, Xen and Qemu watchdog drivers (xen_wdt and i6300esb) may be configured to either send NMI or turn off/reboot VM as the watchdog action. As the kernel may stuck at any state, sending NMIs can't reliably reboot the VM. At Arista, we benefited from the following set-up: the emulated watchdogs trigger VM reset and softdog is set to catch less severe conditions to generate vmcore. Just before reboot watchdog's timeout is increased to some good-enough value (3 mins). That keeps watchdog always running and guarantees that VM doesn't stuck. Provide new stop_on_reboot module parameter to let user control watchdog's reboot policy. Cc: Guenter Roeck <[email protected]> Cc: Wim Van Sebroeck <[email protected]> Cc: [email protected] Signed-off-by: Dmitry Safonov <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent 3f9d513 commit 9232c80

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/watchdog/watchdog_core.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939

4040
static DEFINE_IDA(watchdog_ida);
4141

42+
static int stop_on_reboot = -1;
43+
module_param(stop_on_reboot, int, 0444);
44+
MODULE_PARM_DESC(stop_on_reboot, "Stop watchdogs on reboot (0=keep watching, 1=stop)");
45+
4246
/*
4347
* Deferred Registration infrastructure.
4448
*
@@ -254,6 +258,14 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
254258
}
255259
}
256260

261+
/* Module parameter to force watchdog policy on reboot. */
262+
if (stop_on_reboot != -1) {
263+
if (stop_on_reboot)
264+
set_bit(WDOG_STOP_ON_REBOOT, &wdd->status);
265+
else
266+
clear_bit(WDOG_STOP_ON_REBOOT, &wdd->status);
267+
}
268+
257269
if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status)) {
258270
wdd->reboot_nb.notifier_call = watchdog_reboot_notifier;
259271

0 commit comments

Comments
 (0)