summaryrefslogtreecommitdiff
path: root/sys/kern/kern_clock.c
diff options
context:
space:
mode:
authorriastradh <riastradh@NetBSD.org>2023-07-07 12:34:49 +0000
committerriastradh <riastradh@NetBSD.org>2023-07-07 12:34:49 +0000
commitde09df2fbee768e9082e19034d75860393b1d8c7 (patch)
treea400ee5f81acf1799478f682b860d75aeb65baa3 /sys/kern/kern_clock.c
parent54c2f318891feaaffe6b1d657fbfc309137b174e (diff)
heartbeat(9): New mechanism to check progress of kernel.
This uses hard interrupts to check progress of low-priority soft interrupts, and one CPU to check progress of another CPU. If no progress has been made after a configurable number of seconds (kern.heartbeat.max_period, default 15), then the system panics -- preferably on the CPU that is stuck so we get a stack trace in dmesg of where it was stuck, but if the stuckness was detected by another CPU and the stuck CPU doesn't acknowledge the request to panic within one second, the detecting CPU panics instead. This doesn't supplant hardware watchdog timers. It is possible for hard interrupts to be stuck on all CPUs for some reason too; in that case heartbeat(9) has no opportunity to complete. Downside: heartbeat(9) relies on hardclock to run at a reasonably consistent rate, which might cause trouble for the glorious tickless future. However, it could be adapted to take a parameter for an approximate number of units that have elapsed since the last call on the current CPU, rather than treating that as a constant 1. XXX kernel revbump -- changes struct cpu_info layout
Diffstat (limited to 'sys/kern/kern_clock.c')
-rw-r--r--sys/kern/kern_clock.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c
index 53fa4ed7554..791301f8d6a 100644
--- a/sys/kern/kern_clock.c
+++ b/sys/kern/kern_clock.c
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_clock.c,v 1.149 2023/06/30 21:42:05 riastradh Exp $ */
+/* $NetBSD: kern_clock.c,v 1.150 2023/07/07 12:34:50 riastradh Exp $ */
/*-
* Copyright (c) 2000, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,11 +69,12 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.149 2023/06/30 21:42:05 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.150 2023/07/07 12:34:50 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_dtrace.h"
#include "opt_gprof.h"
+#include "opt_heartbeat.h"
#include "opt_multiprocessor.h"
#endif
@@ -92,6 +93,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.149 2023/06/30 21:42:05 riastradh E
#include <sys/cpu.h>
#include <sys/atomic.h>
#include <sys/rndsource.h>
+#include <sys/heartbeat.h>
#ifdef GPROF
#include <sys/gmon.h>
@@ -335,6 +337,13 @@ hardclock(struct clockframe *frame)
tc_ticktock();
}
+#ifdef HEARTBEAT
+ /*
+ * Make sure the CPUs and timecounter are making progress.
+ */
+ heartbeat();
+#endif
+
/*
* Update real-time timeout queue.
*/