watchdog: softdog.c: enhancement to optionally invoke panic instead of reboot on timer expiry

This is needed for determining the reason for failure when a softdog
timeout occurs.

We use softdog to watch for critical application failures and at the
minimum a snapshot of the system would help to determine the cause. In
such a scenario the application could fail but there isn't a softlockup as
such, hence the detect softlockup feature does not help.

The patch adds a module parameter soft_panic which when set to 1 causes
softdog to invoke panic instead of reboot when the softdog timer expires.
By invoking panic we execute kdump if it is configured and the vmcore
generated by kdump should provide atleast a minimal idea of the reason for
failure.

Based on an original patch by Ken Sugawara <sugaken.r3@gmail.com>
Signed-off-by: Anithra P J <anithra@linux.vnet.ibm.com>
Reviewed-by: WANG Cong <xiyou.wangcong@gmail.com>
Acked-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by Anithra P Janakiraman and committed by Wim Van Sebroeck 7fff4beb 708d4247

+13 -3
+13 -3
drivers/watchdog/softdog.c
··· 48 48 #include <linux/init.h> 49 49 #include <linux/jiffies.h> 50 50 #include <linux/uaccess.h> 51 + #include <linux/kernel.h> 51 52 52 53 #define PFX "SoftDog: " 53 54 ··· 76 75 "Softdog action, set to 1 to ignore reboots, 0 to reboot " 77 76 "(default depends on ONLY_TESTING)"); 78 77 78 + static int soft_panic; 79 + module_param(soft_panic, int, 0); 80 + MODULE_PARM_DESC(soft_panic, 81 + "Softdog action, set to 1 to panic, 0 to reboot (default=0)"); 82 + 79 83 /* 80 84 * Our timer 81 85 */ ··· 104 98 105 99 if (soft_noboot) 106 100 printk(KERN_CRIT PFX "Triggered - Reboot ignored.\n"); 107 - else { 101 + else if (soft_panic) { 102 + printk(KERN_CRIT PFX "Initiating panic.\n"); 103 + panic("Software Watchdog Timer expired."); 104 + } else { 108 105 printk(KERN_CRIT PFX "Initiating system reboot.\n"); 109 106 emergency_restart(); 110 107 printk(KERN_CRIT PFX "Reboot didn't ?????\n"); ··· 276 267 }; 277 268 278 269 static char banner[] __initdata = KERN_INFO "Software Watchdog Timer: 0.07 " 279 - "initialized. soft_noboot=%d soft_margin=%d sec (nowayout= %d)\n"; 270 + "initialized. soft_noboot=%d soft_margin=%d sec soft_panic=%d " 271 + "(nowayout= %d)\n"; 280 272 281 273 static int __init watchdog_init(void) 282 274 { ··· 308 298 return ret; 309 299 } 310 300 311 - printk(banner, soft_noboot, soft_margin, nowayout); 301 + printk(banner, soft_noboot, soft_margin, soft_panic, nowayout); 312 302 313 303 return 0; 314 304 }