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