Skip to content

Commit

Permalink
watchdog: softdog.c: enhancement to optionally invoke panic instead o…
Browse files Browse the repository at this point in the history
…f 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>
  • Loading branch information
Anithra P Janakiraman authored and Wim Van Sebroeck committed Mar 29, 2011
1 parent 708d424 commit 7fff4be
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions drivers/watchdog/softdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include <linux/init.h>
#include <linux/jiffies.h>
#include <linux/uaccess.h>
#include <linux/kernel.h>

#define PFX "SoftDog: "

Expand Down Expand Up @@ -75,6 +76,11 @@ MODULE_PARM_DESC(soft_noboot,
"Softdog action, set to 1 to ignore reboots, 0 to reboot "
"(default depends on ONLY_TESTING)");

static int soft_panic;
module_param(soft_panic, int, 0);
MODULE_PARM_DESC(soft_panic,
"Softdog action, set to 1 to panic, 0 to reboot (default=0)");

/*
* Our timer
*/
Expand All @@ -98,7 +104,10 @@ static void watchdog_fire(unsigned long data)

if (soft_noboot)
printk(KERN_CRIT PFX "Triggered - Reboot ignored.\n");
else {
else if (soft_panic) {
printk(KERN_CRIT PFX "Initiating panic.\n");
panic("Software Watchdog Timer expired.");
} else {
printk(KERN_CRIT PFX "Initiating system reboot.\n");
emergency_restart();
printk(KERN_CRIT PFX "Reboot didn't ?????\n");
Expand Down Expand Up @@ -267,7 +276,8 @@ static struct notifier_block softdog_notifier = {
};

static char banner[] __initdata = KERN_INFO "Software Watchdog Timer: 0.07 "
"initialized. soft_noboot=%d soft_margin=%d sec (nowayout= %d)\n";
"initialized. soft_noboot=%d soft_margin=%d sec soft_panic=%d "
"(nowayout= %d)\n";

static int __init watchdog_init(void)
{
Expand Down Expand Up @@ -298,7 +308,7 @@ static int __init watchdog_init(void)
return ret;
}

printk(banner, soft_noboot, soft_margin, nowayout);
printk(banner, soft_noboot, soft_margin, soft_panic, nowayout);

return 0;
}
Expand Down

0 comments on commit 7fff4be

Please sign in to comment.