Module Name: src
Committed By: riastradh
Date: Fri Mar 8 23:34:03 UTC 2024
Modified Files:
src/sys/kern: kern_heartbeat.c
Log Message:
heartbeat(9): Return early if panicstr is set.
This way we avoid doing unnecessary work -- and print unnecessary
messages -- to _not_ trigger another panic anyway.
PR kern/58011
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/kern/kern_heartbeat.c
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_heartbeat.c
diff -u src/sys/kern/kern_heartbeat.c:1.12 src/sys/kern/kern_heartbeat.c:1.13
--- src/sys/kern/kern_heartbeat.c:1.12 Wed Feb 28 04:14:47 2024
+++ src/sys/kern/kern_heartbeat.c Fri Mar 8 23:34:03 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_heartbeat.c,v 1.12 2024/02/28 04:14:47 riastradh Exp $ */
+/* $NetBSD: kern_heartbeat.c,v 1.13 2024/03/08 23:34:03 riastradh Exp $ */
/*-
* Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -82,7 +82,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_heartbeat.c,v 1.12 2024/02/28 04:14:47 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_heartbeat.c,v 1.13 2024/03/08 23:34:03 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -627,11 +627,17 @@ heartbeat(void)
KASSERT(curcpu_stable());
+ /*
+ * If heartbeat checks are disabled globally, or if they are
+ * suspended locally, or if we're already panicking so it's not
+ * helpful to trigger more panics for more reasons, do nothing.
+ */
period_ticks = atomic_load_relaxed(&heartbeat_max_period_ticks);
period_secs = atomic_load_relaxed(&heartbeat_max_period_secs);
if (__predict_false(period_ticks == 0) ||
__predict_false(period_secs == 0) ||
- __predict_false(curcpu()->ci_heartbeat_suspend))
+ __predict_false(curcpu()->ci_heartbeat_suspend) ||
+ __predict_false(panicstr != NULL))
return;
/*