Skip to contentSkip to conversation

watchdog: only print critical log when the watchdog fails to be stopped

PATCH liuchao (CR) 2 participants 3 messages Feb 5, 2025 Watchdog device drivers

lore
Share & tools
lore
#0 lore raw
Quoted 43 lines · Guenter Roeck
Quoted 28 lines · liuchao (CR)
Quoted 24 lines · Guenter Roeck
Quoted 6 lines · liuchao (CR)
Quoted 5 lines · Guenter Roeck
Quoted 3 lines · Liu Chao

Every time the user echoes 0 > /dev/watchdog0, meaningless critical log is printed.

Quoted 6 lines
Quoted 2 lines

It is not meaningless, and it will still be displayed after this change, making the change pointless.

The change is not pointless. For example, the softdog driver does not invoke watchdog_stop or print logs in the watchdog_release.

It seems to me that is a problem in the softdog driver.

The change is actually worse than I initially thought.
The message is _supposed_ to be displayed if watchdog_stop() is not called while the watchdog is running (i.e., if err == -EBUSY). Otherwise it would not be displayed for real hardware watchdogs which are not stopped because they were running and watchdog_stop() is not called because WDIOF_MAGICCLOSE is set in the driver and the magic release byte was not written.

Quoted 2 lines

Specifically, the softdog driver has WDIOF_MAGICCLOSE set. It is not supposed to be unloadable (or unloaded) while the watchdog is running.

Quoted 7 lines

When echo to /dev/watchdog0, The watchdog_open, watchdog_write, and watchdog_release functions are invoked in sequence. Do you mean the softdog driver should not call watchdog_release?

After the user opens /dev/watchdog0, the user feeds the watchdog through ioctl WDIOC_KEEPALIVE and never closes. Is this the correct usage?

I tried softdog. It works as advertised. Yes, "echo 0 > watchdog0" triggers the message.
"sudo modprobe -r softdog" then fails with

modprobe: FATAL: Module softdog is in use.

Quoted 8 lines

and, as expected, one minute later (or whatever the timeout is set to) the system reboots.

There is nothing wrong with the message. The softdog _does_ refuse to be unloaded while running, and it _does_ reboot the system after the timeout expired. This is all perfectly as expected. The log is not meaningless. Instead, it tells the user that the system will reboot after the watchdog expired. Which it does.

User creates a process and echoes every time to ensure that the system is normal, the process can be executed properly. Otherwise, the system reboots. So the critical message keeps printing.

Is it reasonable to change it to info level?

Quoted 2 lines

Guenter

maintainer
#1 lore raw
Quoted 53 lines · liuchao (CR)
Quoted 43 lines · Guenter Roeck
Quoted 28 lines · liuchao (CR)
Quoted 24 lines · Guenter Roeck
Quoted 6 lines · liuchao (CR)
Quoted 5 lines · Guenter Roeck
Quoted 3 lines · Liu Chao

Every time the user echoes 0 > /dev/watchdog0, meaningless critical log is printed.

Quoted 6 lines
Quoted 2 lines

It is not meaningless, and it will still be displayed after this change, making the change pointless.

The change is not pointless. For example, the softdog driver does not invoke watchdog_stop or print logs in the watchdog_release.

It seems to me that is a problem in the softdog driver.

The change is actually worse than I initially thought.
The message is _supposed_ to be displayed if watchdog_stop() is not called while the watchdog is running (i.e., if err == -EBUSY). Otherwise it would not be displayed for real hardware watchdogs which are not stopped because they were running and watchdog_stop() is not called because WDIOF_MAGICCLOSE is set in the driver and the magic release byte was not written.

Quoted 2 lines

Specifically, the softdog driver has WDIOF_MAGICCLOSE set. It is not supposed to be unloadable (or unloaded) while the watchdog is running.

Quoted 7 lines

When echo to /dev/watchdog0, The watchdog_open, watchdog_write, and watchdog_release functions are invoked in sequence. Do you mean the softdog driver should not call watchdog_release?

After the user opens /dev/watchdog0, the user feeds the watchdog through ioctl WDIOC_KEEPALIVE and never closes. Is this the correct usage?

I tried softdog. It works as advertised. Yes, "echo 0 > watchdog0" triggers the message.
"sudo modprobe -r softdog" then fails with

modprobe: FATAL: Module softdog is in use.

Quoted 8 lines

and, as expected, one minute later (or whatever the timeout is set to) the system reboots.

There is nothing wrong with the message. The softdog _does_ refuse to be unloaded while running, and it _does_ reboot the system after the timeout expired. This is all perfectly as expected. The log is not meaningless. Instead, it tells the user that the system will reboot after the watchdog expired. Which it does.

Quoted 6 lines

User creates a process and echoes every time to ensure that the system is normal, the process can be executed properly. Otherwise, the system reboots. So the critical message keeps printing.

Is it reasonable to change it to info level?

No. The user needs to echo the magic character instead of "0".

Guenter

maintainer
#2 lore raw
Quoted 10 lines · Guenter Roeck
Quoted 7 lines

User creates a process and echoes every time to ensure that the system is normal, the process can be executed properly. Otherwise, the system reboots. So the critical message keeps printing.

Is it reasonable to change it to info level?

No. The user needs to echo the magic character instead of "0".

Actually, the underlying problem is that the user keeps closing the watchdog device, which is not the intended use since the watchdog is supposed to only run while the watchdog device is open. That is why applications like watchdogd are normally used to manage and control a watchdog.

The problem here is that the user insists in doing something wrong, and you want the kernel to adjust to that wrong usage. In a sense, this is like persistently driving above the speed limit, and instead of paying the resulting fines (or reducing the speed), the user wants the penalties to go away or to have them replaced with an informational notice. That is not how it works, sorry.

If the user insists on their current approach, they will have to live with the consequences.

Guenter