Patch: softdog and WDIOS_DISABLECARD
Hi,
I have found a potential problem with the current implementation of the software watchdog. I have CONFIG_WATCHDOG_NOWAYOUT set for a reliable watchdog. However, there are instances where I want to explicitly shut it down. The problem with disabling CONFIG_WATCHDOG_NOWAYOUT is that events other than an explicit shutdown can disable the timer. A SIGSEGV perhaps or the daemon being killed by the OOM handler. In cases like this, the system should reboot IMO.
This small patch adds the appropriate options to enable and disable the timer explicitly.
softdog.c renamed from softdog.c.orig +20 -0
@@ -130,6 +130,7 @@static struct watchdog_info ident = { identity:"Software Watchdog" , }; +int rv;switch (cmd) {default :return -ENOIOCTLCMD ;
@@ -140,6 +141,25 @@case WDIOC_GETSTATUS :case WDIOC_GETBOOTSTATUS :return put_user (0 ,(int *)arg); +case WDIOC_SETOPTIONS : +if (copy_from_user (&rv, (int *) arg,sizeof (int ))) +return -EFAULT ; + +if (rv &WDIOS_DISABLECARD ) { +lock_kernel (); +del_timer (&watchdog_ticktock); +unlock_kernel (); +return 0 ; + } + +if (rv &WDIOS_ENABLECARD ) { +lock_kernel (); +mod_timer (&watchdog_ticktock, jiffies + + (soft_margin *HZ )); +unlock_kernel (); +return 0 ; + } +case WDIOC_KEEPALIVE :mod_timer (&watchdog_ticktock, jiffies+(soft_margin*HZ ));return 0 ;
Signature · 5 lines
Shane Wegner: [email protected] http://www.cm.nu/~shane/ PGP: 1024D/FFE3035D A0ED DAC4 77EC D674 5487 5B5C 4F89 9A4E FFE3 035D
Quoted 5 lines
I have found a potential problem with the current implementation of the software watchdog. I have
CONFIG_WATCHDOG_NOWAYOUTset for a reliable watchdog. However, there are instances where I want to explicitly shut it down. The problem with disabling
It is intentional you cannot shut it down. The whole point of that mode of operation is that you can make definitive statements about your watchdogs.
You can swap the watchdog process with any simple program that keeps it ticking while you do other work, then swap back.