Module Name: src
Committed By: matt
Date: Sat Dec 11 22:27:53 UTC 2010
Modified Files:
src/sys/kern: kern_hook.c
src/sys/sys: systm.h
Log Message:
Add critpoll (critical polling) hooks. These are keep things like watchdogs
from firing when the system is doing stuff like waiting at a ddb prompt or
the kernel is doing a lot of printing.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/kern/kern_hook.c
cvs rdiff -u -r1.242 -r1.243 src/sys/sys/systm.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/kern_hook.c
diff -u src/sys/kern/kern_hook.c:1.3 src/sys/kern/kern_hook.c:1.4
--- src/sys/kern/kern_hook.c:1.3 Sun Jan 31 09:27:40 2010
+++ src/sys/kern/kern_hook.c Sat Dec 11 22:27:53 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_hook.c,v 1.3 2010/01/31 09:27:40 martin Exp $ */
+/* $NetBSD: kern_hook.c,v 1.4 2010/12/11 22:27:53 matt Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_hook.c,v 1.3 2010/01/31 09:27:40 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_hook.c,v 1.4 2010/12/11 22:27:53 matt Exp $");
#include <sys/param.h>
#include <sys/malloc.h>
@@ -279,6 +279,33 @@
}
}
+static hook_list_t critpollhook_list = LIST_HEAD_INITIALIZER(critpollhook_list);
+
+void *
+critpollhook_establish(void (*fn)(void *), void *arg)
+{
+ return hook_establish(&critpollhook_list, fn, arg);
+}
+
+void
+critpollhook_disestablish(void *vhook)
+{
+ hook_disestablish(&critpollhook_list, vhook);
+}
+
+/*
+ * Run critical polling hooks.
+ */
+void
+docritpollhooks(void)
+{
+ struct hook_desc *hd;
+
+ LIST_FOREACH(hd, &critpollhook_list, hk_list) {
+ (*hd->hk_fn)(hd->hk_arg);
+ }
+}
+
/*
* "Power hook" types, functions, and variables.
* The list of power hooks is kept ordered with the last registered hook
Index: src/sys/sys/systm.h
diff -u src/sys/sys/systm.h:1.242 src/sys/sys/systm.h:1.243
--- src/sys/sys/systm.h:1.242 Sun Sep 12 16:07:40 2010
+++ src/sys/sys/systm.h Sat Dec 11 22:27:53 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: systm.h,v 1.242 2010/09/12 16:07:40 drochner Exp $ */
+/* $NetBSD: systm.h,v 1.243 2010/12/11 22:27:53 matt Exp $ */
/*-
* Copyright (c) 1982, 1988, 1991, 1993
@@ -322,6 +322,14 @@
void setstatclockrate(int);
/*
+ * Critical polling hooks. Functions to be run while the kernel stays
+ * elevated IPL for a "long" time. (watchdogs).
+ */
+void *critpollhook_establish(void (*)(void *), void *);
+void critpollhook_disestablish(void *);
+void docritpollhooks(void);
+
+/*
* Shutdown hooks. Functions to be run with all interrupts disabled
* immediately before the system is halted or rebooted.
*/