* [PATCHv3] watchdog: Add stop_on_reboot parameter to control reboot policy
@ 2020-02-23 11:49 Dmitry Safonov
2020-02-23 14:09 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Safonov @ 2020-02-23 11:49 UTC (permalink / raw)
To: linux-kernel
Cc: Dmitry Safonov, Dmitry Safonov, Guenter Roeck, Wim Van Sebroeck,
linux-watchdog
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 <linux@roeck-us.net>
Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
Cc: linux-watchdog@vger.kernel.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
Changes:
v3: Make module parameter read-only in runtime (Thanks Guenter for
spotting the typo!)
v2: Add module parameter instead of ioctl()
drivers/watchdog/watchdog_core.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
index 861daf4f37b2..423844757812 100644
--- a/drivers/watchdog/watchdog_core.c
+++ b/drivers/watchdog/watchdog_core.c
@@ -39,6 +39,10 @@
static DEFINE_IDA(watchdog_ida);
+static int stop_on_reboot = -1;
+module_param(stop_on_reboot, int, 0444);
+MODULE_PARM_DESC(stop_on_reboot, "Stop watchdogs on reboot (0=keep watching, 1=stop)");
+
/*
* Deferred Registration infrastructure.
*
@@ -254,6 +258,14 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
}
}
+ /* Module parameter to force watchdog policy on reboot. */
+ if (stop_on_reboot != -1) {
+ if (stop_on_reboot)
+ set_bit(WDOG_STOP_ON_REBOOT, &wdd->status);
+ else
+ clear_bit(WDOG_STOP_ON_REBOOT, &wdd->status);
+ }
+
if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status)) {
wdd->reboot_nb.notifier_call = watchdog_reboot_notifier;
--
2.25.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCHv3] watchdog: Add stop_on_reboot parameter to control reboot policy
2020-02-23 11:49 [PATCHv3] watchdog: Add stop_on_reboot parameter to control reboot policy Dmitry Safonov
@ 2020-02-23 14:09 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2020-02-23 14:09 UTC (permalink / raw)
To: Dmitry Safonov, linux-kernel
Cc: Dmitry Safonov, Wim Van Sebroeck, linux-watchdog
On 2/23/20 3:49 AM, Dmitry Safonov wrote:
> 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 <linux@roeck-us.net>
> Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
> Cc: linux-watchdog@vger.kernel.org
> Signed-off-by: Dmitry Safonov <dima@arista.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> Changes:
> v3: Make module parameter read-only in runtime (Thanks Guenter for
> spotting the typo!)
> v2: Add module parameter instead of ioctl()
>
> drivers/watchdog/watchdog_core.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
> index 861daf4f37b2..423844757812 100644
> --- a/drivers/watchdog/watchdog_core.c
> +++ b/drivers/watchdog/watchdog_core.c
> @@ -39,6 +39,10 @@
>
> static DEFINE_IDA(watchdog_ida);
>
> +static int stop_on_reboot = -1;
> +module_param(stop_on_reboot, int, 0444);
> +MODULE_PARM_DESC(stop_on_reboot, "Stop watchdogs on reboot (0=keep watching, 1=stop)");
> +
> /*
> * Deferred Registration infrastructure.
> *
> @@ -254,6 +258,14 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
> }
> }
>
> + /* Module parameter to force watchdog policy on reboot. */
> + if (stop_on_reboot != -1) {
> + if (stop_on_reboot)
> + set_bit(WDOG_STOP_ON_REBOOT, &wdd->status);
> + else
> + clear_bit(WDOG_STOP_ON_REBOOT, &wdd->status);
> + }
> +
> if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status)) {
> wdd->reboot_nb.notifier_call = watchdog_reboot_notifier;
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-02-23 14:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-23 11:49 [PATCHv3] watchdog: Add stop_on_reboot parameter to control reboot policy Dmitry Safonov
2020-02-23 14:09 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).