Linux Watchdog driver development
 help / color / mirror / Atom feed
* [PATCH] watchdog: Inform about watchdog timeout.
@ 2024-07-14 15:46 Mathieu Othacehe
  2024-07-14 18:45 ` Guenter Roeck
  0 siblings, 1 reply; 3+ messages in thread
From: Mathieu Othacehe @ 2024-07-14 15:46 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: linux-watchdog, linux-kernel, Mathieu Othacehe

When the kernel stops feeding the watchdog, inform the user that it is
about to timeout in X seconds.

The message looks like: watchdog: watchdog0: timeout in 15 seconds

This is helpful to warn the user that, most likely,
CONFIG_WATCHDOG_OPEN_TIMEOUT seconds have elapsed and the userspace hasn't
start feeding the watchdog.

Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
---
 drivers/watchdog/watchdog_dev.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index e2bd266b1b5b3..0d95c91365993 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -104,6 +104,7 @@ static ktime_t watchdog_next_keepalive(struct watchdog_device *wdd)
 	ktime_t last_heartbeat, latest_heartbeat;
 	ktime_t virt_timeout;
 	unsigned int hw_heartbeat_ms;
+	int delta_to_timeout;
 
 	if (watchdog_active(wdd))
 		virt_timeout = ktime_add(wd_data->last_keepalive,
@@ -121,6 +122,17 @@ static ktime_t watchdog_next_keepalive(struct watchdog_device *wdd)
 	 */
 	last_heartbeat = ktime_sub(virt_timeout, ms_to_ktime(hw_heartbeat_ms));
 	latest_heartbeat = ktime_sub(last_heartbeat, ktime_get());
+
+	/*
+	 * If we are past the last heartbeat, inform the user that we are
+	 * about to timeout.
+	 */
+	delta_to_timeout =
+		(int)ktime_ms_delta(virt_timeout, ktime_get()) / MSEC_PER_SEC;
+	if (latest_heartbeat <= 0 && delta_to_timeout > 0)
+		pr_info("watchdog%d: timeout in %d seconds\n", wdd->id,
+			delta_to_timeout);
+
 	if (ktime_before(latest_heartbeat, keepalive_interval))
 		return latest_heartbeat;
 	return keepalive_interval;
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] watchdog: Inform about watchdog timeout.
  2024-07-14 15:46 [PATCH] watchdog: Inform about watchdog timeout Mathieu Othacehe
@ 2024-07-14 18:45 ` Guenter Roeck
  2024-07-18 18:22   ` Wim Van Sebroeck
  0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2024-07-14 18:45 UTC (permalink / raw)
  To: Mathieu Othacehe, Wim Van Sebroeck; +Cc: linux-watchdog, linux-kernel

On 7/14/24 08:46, Mathieu Othacehe wrote:
> When the kernel stops feeding the watchdog, inform the user that it is
> about to timeout in X seconds.
> 
> The message looks like: watchdog: watchdog0: timeout in 15 seconds
> 
> This is helpful to warn the user that, most likely,
> CONFIG_WATCHDOG_OPEN_TIMEOUT seconds have elapsed and the userspace hasn't
> start feeding the watchdog.
> 
> Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>

I don't like noisiness in the kernel, and I don't see value in this message.

Maybe Wim thinks otherwise, but for me this is NACK.

Guenter


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] watchdog: Inform about watchdog timeout.
  2024-07-14 18:45 ` Guenter Roeck
@ 2024-07-18 18:22   ` Wim Van Sebroeck
  0 siblings, 0 replies; 3+ messages in thread
From: Wim Van Sebroeck @ 2024-07-18 18:22 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Mathieu Othacehe, Wim Van Sebroeck, linux-watchdog, linux-kernel

 Hi Mathieu, Guenter,

> On 7/14/24 08:46, Mathieu Othacehe wrote:
> >When the kernel stops feeding the watchdog, inform the user that it is
> >about to timeout in X seconds.
> >
> >The message looks like: watchdog: watchdog0: timeout in 15 seconds
> >
> >This is helpful to warn the user that, most likely,
> >CONFIG_WATCHDOG_OPEN_TIMEOUT seconds have elapsed and the userspace hasn't
> >start feeding the watchdog.
> >
> >Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
> 
> I don't like noisiness in the kernel, and I don't see value in this message.
> 
> Maybe Wim thinks otherwise, but for me this is NACK.

No, I was thinking the same. So also NACK for me.

Kind regards,
Wim.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-18 18:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-14 15:46 [PATCH] watchdog: Inform about watchdog timeout Mathieu Othacehe
2024-07-14 18:45 ` Guenter Roeck
2024-07-18 18:22   ` Wim Van Sebroeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox