public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] watchdog: add pretimeout ioctl
@ 2006-06-27 18:22 minyard
  2006-06-27 18:59 ` Alan Cox
  2006-06-28  0:29 ` Andrew Morton
  0 siblings, 2 replies; 6+ messages in thread
From: minyard @ 2006-06-27 18:22 UTC (permalink / raw)
  To: Linux Kernel; +Cc: Andrew Morton, OpenIPMI Developers, Wim Van Sebroeck


Some watchdog timers support the concept of a "pretimeout" which
occurs some time before the real timeout.  The pretimeout can
be delivered via an interrupt or NMI and can be used to panic
the system when it occurs (so you get useful information instead
of a blind reboot).

The IPMI watchdog has had this built in, but this creates a standard
mechanism for all watchdogs and switches the IPMI driver over to it.

Signed-off-by: Corey Minyard <minyard@acm.org>

Index: linux-2.6.16/Documentation/watchdog/watchdog-api.txt
===================================================================
--- linux-2.6.16.orig/Documentation/watchdog/watchdog-api.txt
+++ linux-2.6.16/Documentation/watchdog/watchdog-api.txt
@@ -107,7 +107,31 @@ current timeout using the GETTIMEOUT ioc
     ioctl(fd, WDIOC_GETTIMEOUT, &timeout);
     printf("The timeout was is %d seconds\n", timeout);
 
-Envinronmental monitoring:
+Pretimeouts:
+
+Some watchdog timers can be set to have a trigger go off before the
+actual time they will reset the system.  This can be done with an NMI,
+interrupt, or other mechanism.  This allows Linux to record useful
+information (like panic information and kernel coredumps) before it
+resets.
+
+    pretimeout = 10;
+    ioctl(fd, WDIOC_SETPRETIMEOUT, &pretimeout);
+
+Note that the pretimeout is the number of seconds before the time
+when the timeout will go off.  It is not the number of seconds until
+the pretimeout.  So, for instance, if you set the timeout to 60 seconds
+and the pretimeout to 10 seconds, the pretimout will go of in 50
+seconds.  Setting a pretimeout to zero disables it.
+
+There is also a get function for getting the pretimeout:
+
+    ioctl(fd, WDIOC_GETPRETIMEOUT, &timeout);
+    printf("The pretimeout was is %d seconds\n", timeout);
+
+Not all watchdog drivers will support a pretimeout.
+
+Environmental monitoring:
 
 All watchdog drivers are required return more information about the system,
 some do temperature, fan and power level monitoring, some can tell you
@@ -166,6 +190,10 @@ The watchdog saw a keepalive ping since 
 
 	WDIOF_SETTIMEOUT	Can set/get the timeout
 
+The watchdog can do pretimeouts.
+
+	WDIOF_PRETIMEOUT	Pretimeout (in seconds), get/set
+
 
 For those drivers that return any bits set in the option field, the
 GETSTATUS and GETBOOTSTATUS ioctls can be used to ask for the current
Index: linux-2.6.16/drivers/char/ipmi/ipmi_watchdog.c
===================================================================
--- linux-2.6.16.orig/drivers/char/ipmi/ipmi_watchdog.c
+++ linux-2.6.16/drivers/char/ipmi/ipmi_watchdog.c
@@ -122,16 +122,9 @@
 #define IPMI_WDOG_SET_TIMER		0x24
 #define IPMI_WDOG_GET_TIMER		0x25
 
-/* These are here until the real ones get into the watchdog.h interface. */
-#ifndef WDIOC_GETTIMEOUT
-#define	WDIOC_GETTIMEOUT        _IOW(WATCHDOG_IOCTL_BASE, 20, int)
-#endif
-#ifndef WDIOC_SET_PRETIMEOUT
-#define	WDIOC_SET_PRETIMEOUT     _IOW(WATCHDOG_IOCTL_BASE, 21, int)
-#endif
-#ifndef WDIOC_GET_PRETIMEOUT
-#define	WDIOC_GET_PRETIMEOUT     _IOW(WATCHDOG_IOCTL_BASE, 22, int)
-#endif
+/* These are here for backwards compatability for a while. */
+#define	WDIOC_OLD_IPMI_SET_PRETIMEOUT     _IOW(WATCHDOG_IOCTL_BASE, 21, int)
+#define	WDIOC_OLD_IPMI_GET_PRETIMEOUT     _IOW(WATCHDOG_IOCTL_BASE, 22, int)
 
 static int nowayout = WATCHDOG_NOWAYOUT;
 
@@ -598,7 +591,8 @@ static void panic_halt_ipmi_heartbeat(vo
 
 static struct watchdog_info ident =
 {
-	.options	= 0,	/* WDIOF_SETTIMEOUT, */
+	.options	= (WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE
+			   | WDIOF_PRETIMEOUT),
 	.firmware_version = 1,
 	.identity	= "IPMI"
 };
@@ -628,14 +622,16 @@ static int ipmi_ioctl(struct inode *inod
 			return -EFAULT;
 		return 0;
 
-	case WDIOC_SET_PRETIMEOUT:
+	case WDIOC_OLD_IPMI_SET_PRETIMEOUT:
+	case WDIOC_SETPRETIMEOUT:
 		i = copy_from_user(&val, argp, sizeof(int));
 		if (i)
 			return -EFAULT;
 		pretimeout = val;
 		return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY);
 
-	case WDIOC_GET_PRETIMEOUT:
+	case WDIOC_OLD_IPMI_GET_PRETIMEOUT:
+	case WDIOC_GETPRETIMEOUT:
 		i = copy_to_user(argp, &pretimeout, sizeof(pretimeout));
 		if (i)
 			return -EFAULT;
Index: linux-2.6.16/include/linux/watchdog.h
===================================================================
--- linux-2.6.16.orig/include/linux/watchdog.h
+++ linux-2.6.16/include/linux/watchdog.h
@@ -28,6 +28,8 @@ struct watchdog_info {
 #define	WDIOC_KEEPALIVE		_IOR(WATCHDOG_IOCTL_BASE, 5, int)
 #define	WDIOC_SETTIMEOUT        _IOWR(WATCHDOG_IOCTL_BASE, 6, int)
 #define	WDIOC_GETTIMEOUT        _IOR(WATCHDOG_IOCTL_BASE, 7, int)
+#define	WDIOC_SETPRETIMEOUT     _IOWR(WATCHDOG_IOCTL_BASE, 8, int)
+#define	WDIOC_GETPRETIMEOUT     _IOR(WATCHDOG_IOCTL_BASE, 9, int)
 
 #define	WDIOF_UNKNOWN		-1	/* Unknown flag error */
 #define	WDIOS_UNKNOWN		-1	/* Unknown status error */
@@ -41,6 +43,7 @@ struct watchdog_info {
 #define WDIOF_POWEROVER		0x0040	/* Power over voltage */
 #define WDIOF_SETTIMEOUT	0x0080  /* Set timeout (in seconds) */
 #define WDIOF_MAGICCLOSE	0x0100	/* Supports magic close char */
+#define WDIOF_PRETIMEOUT	0x0200  /* Pretimeout (in seconds), get/set */
 #define	WDIOF_KEEPALIVEPING	0x8000	/* Keep alive ping reply */
 
 #define	WDIOS_DISABLECARD	0x0001	/* Turn off the watchdog timer */

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] watchdog: add pretimeout ioctl
  2006-06-27 18:22 [PATCH] watchdog: add pretimeout ioctl minyard
@ 2006-06-27 18:59 ` Alan Cox
  2006-06-28  1:05   ` Corey Minyard
  2006-06-28  0:29 ` Andrew Morton
  1 sibling, 1 reply; 6+ messages in thread
From: Alan Cox @ 2006-06-27 18:59 UTC (permalink / raw)
  To: minyard; +Cc: Linux Kernel, Andrew Morton, OpenIPMI Developers,
	Wim Van Sebroeck

Ar Maw, 2006-06-27 am 13:22 -0500, ysgrifennodd minyard@acm.org:
> Some watchdog timers support the concept of a "pretimeout" which
> occurs some time before the real timeout.  The pretimeout can
> be delivered via an interrupt or NMI and can be used to panic
> the system when it occurs (so you get useful information instead
> of a blind reboot).

All watchdogs can do pre-timeouts in software so possibly this should
use a software fallback as well if you want good coverage ?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] watchdog: add pretimeout ioctl
  2006-06-27 18:22 [PATCH] watchdog: add pretimeout ioctl minyard
  2006-06-27 18:59 ` Alan Cox
@ 2006-06-28  0:29 ` Andrew Morton
  2006-06-28  0:38   ` Corey Minyard
  1 sibling, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2006-06-28  0:29 UTC (permalink / raw)
  To: minyard; +Cc: linux-kernel, openipmi-developer, wim

minyard@acm.org wrote:
>
> Some watchdog timers support the concept of a "pretimeout" which
> occurs some time before the real timeout.  The pretimeout can
> be delivered via an interrupt or NMI and can be used to panic
> the system when it occurs (so you get useful information instead
> of a blind reboot).
> 
> The IPMI watchdog has had this built in, but this creates a standard
> mechanism for all watchdogs and switches the IPMI driver over to it.

This patch seems to be kinda-sorta already half-present in Wim's
development tree.  Could you take a look at what's in 2.6.17-mm3, see if
any additional work is needed and if so, send a patch against that?

Then we can feed it all in when (or after) Wim does his 2.6.18 merge, which
is hopefully soon..

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] watchdog: add pretimeout ioctl
  2006-06-28  0:29 ` Andrew Morton
@ 2006-06-28  0:38   ` Corey Minyard
  0 siblings, 0 replies; 6+ messages in thread
From: Corey Minyard @ 2006-06-28  0:38 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, openipmi-developer, wim

Oops, my bad, yes, it's already there.  Sorry about that.

-Corey

Andrew Morton wrote:
> minyard@acm.org wrote:
>   
>> Some watchdog timers support the concept of a "pretimeout" which
>> occurs some time before the real timeout.  The pretimeout can
>> be delivered via an interrupt or NMI and can be used to panic
>> the system when it occurs (so you get useful information instead
>> of a blind reboot).
>>
>> The IPMI watchdog has had this built in, but this creates a standard
>> mechanism for all watchdogs and switches the IPMI driver over to it.
>>     
>
> This patch seems to be kinda-sorta already half-present in Wim's
> development tree.  Could you take a look at what's in 2.6.17-mm3, see if
> any additional work is needed and if so, send a patch against that?
>
> Then we can feed it all in when (or after) Wim does his 2.6.18 merge, which
> is hopefully soon..
>   


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] watchdog: add pretimeout ioctl
  2006-06-27 18:59 ` Alan Cox
@ 2006-06-28  1:05   ` Corey Minyard
  2006-06-28 10:27     ` Alan Cox
  0 siblings, 1 reply; 6+ messages in thread
From: Corey Minyard @ 2006-06-28  1:05 UTC (permalink / raw)
  To: Alan Cox; +Cc: Linux Kernel, Andrew Morton, OpenIPMI Developers,
	Wim Van Sebroeck

Alan Cox wrote:
> Ar Maw, 2006-06-27 am 13:22 -0500, ysgrifennodd minyard@acm.org:
>   
>> Some watchdog timers support the concept of a "pretimeout" which
>> occurs some time before the real timeout.  The pretimeout can
>> be delivered via an interrupt or NMI and can be used to panic
>> the system when it occurs (so you get useful information instead
>> of a blind reboot).
>>     
>
> All watchdogs can do pre-timeouts in software so possibly this should
> use a software fallback as well if you want good coverage ?
>   
I hadn't thought of that, but a software emulator could be used with
this interface, but it doesn't really help with hard lockups.  This is
primarily intended to set up watchdogs that can delver an NMI,
since even if the machine is hard-locked the NMI will come through.
Of course, there's all kinds of problems with getting the NMI to a
useful handler, but that's another story.

-Corey

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] watchdog: add pretimeout ioctl
  2006-06-28  1:05   ` Corey Minyard
@ 2006-06-28 10:27     ` Alan Cox
  0 siblings, 0 replies; 6+ messages in thread
From: Alan Cox @ 2006-06-28 10:27 UTC (permalink / raw)
  To: Corey Minyard
  Cc: Linux Kernel, Andrew Morton, OpenIPMI Developers,
	Wim Van Sebroeck

Ar Maw, 2006-06-27 am 20:05 -0500, ysgrifennodd Corey Minyard:
> since even if the machine is hard-locked the NMI will come through.

Don't bet on that. There are a considerable number of crash stall cases
where NMI will not be delivered, plus you can disable NMI if you are
really sneaky and want to.

The usual case NMI fails is crashed video cards. The PCI transaction
stalls forever on many boards and the CPU therefore never finishes the
instruction and never services the NMI


Alan

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-06-28 10:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-27 18:22 [PATCH] watchdog: add pretimeout ioctl minyard
2006-06-27 18:59 ` Alan Cox
2006-06-28  1:05   ` Corey Minyard
2006-06-28 10:27     ` Alan Cox
2006-06-28  0:29 ` Andrew Morton
2006-06-28  0:38   ` Corey Minyard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox