Module Name:    src
Committed By:   riastradh
Date:           Sat Sep  2 17:44:59 UTC 2023

Modified Files:
        src/sys/dev: cons.c
        src/sys/kern: init_main.c kern_clock.c kern_cpu.c
        src/sys/sys: heartbeat.h

Log Message:
heartbeat(9): Move #ifdef HEARTBEAT to sys/heartbeat.h.

Less error-prone this way, and the callers are less cluttered.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/dev/cons.c
cvs rdiff -u -r1.542 -r1.543 src/sys/kern/init_main.c
cvs rdiff -u -r1.150 -r1.151 src/sys/kern/kern_clock.c
cvs rdiff -u -r1.96 -r1.97 src/sys/kern/kern_cpu.c
cvs rdiff -u -r1.1 -r1.2 src/sys/sys/heartbeat.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/dev/cons.c
diff -u src/sys/dev/cons.c:1.94 src/sys/dev/cons.c:1.95
--- src/sys/dev/cons.c:1.94	Sat Sep  2 17:44:12 2023
+++ src/sys/dev/cons.c	Sat Sep  2 17:44:59 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: cons.c,v 1.94 2023/09/02 17:44:12 riastradh Exp $	*/
+/*	$NetBSD: cons.c,v 1.95 2023/09/02 17:44:59 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,11 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.94 2023/09/02 17:44:12 riastradh Exp $");
-
-#ifdef _KERNEL_OPT
-#include "opt_heartbeat.h"
-#endif
+__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.95 2023/09/02 17:44:59 riastradh Exp $");
 
 #include <sys/param.h>
 
@@ -423,7 +419,6 @@ cnpollc(int on)
 	if (!on)
 		--refcount;
 	if (refcount == 0) {
-#ifdef HEARTBEAT
 		if (on) {
 			/*
 			 * Bind to the current CPU by disabling
@@ -437,14 +432,11 @@ cnpollc(int on)
 			kpreempt_disable();
 			heartbeat_suspend();
 		}
-#endif
 		(*cn_tab->cn_pollc)(cn_tab->cn_dev, on);
-#ifdef HEARTBEAT
 		if (!on) {
 			heartbeat_resume();
 			kpreempt_enable();
 		}
-#endif
 	}
 	if (on)
 		++refcount;

Index: src/sys/kern/init_main.c
diff -u src/sys/kern/init_main.c:1.542 src/sys/kern/init_main.c:1.543
--- src/sys/kern/init_main.c:1.542	Fri Jul  7 12:34:50 2023
+++ src/sys/kern/init_main.c	Sat Sep  2 17:44:59 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: init_main.c,v 1.542 2023/07/07 12:34:50 riastradh Exp $	*/
+/*	$NetBSD: init_main.c,v 1.543 2023/09/02 17:44:59 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009, 2019 The NetBSD Foundation, Inc.
@@ -97,11 +97,10 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.542 2023/07/07 12:34:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.543 2023/09/02 17:44:59 riastradh Exp $");
 
 #include "opt_cnmagic.h"
 #include "opt_ddb.h"
-#include "opt_heartbeat.h"
 #include "opt_inet.h"
 #include "opt_ipsec.h"
 #include "opt_modular.h"
@@ -559,13 +558,11 @@ main(void)
 	/* Once all CPUs are detected, initialize the per-CPU cprng_fast.  */
 	cprng_fast_init();
 
-#ifdef HEARTBEAT
 	/*
 	 * Now that softints can be established, start monitoring
 	 * system heartbeat on all CPUs.
 	 */
 	heartbeat_start();
-#endif
 
 	ssp_init();
 

Index: src/sys/kern/kern_clock.c
diff -u src/sys/kern/kern_clock.c:1.150 src/sys/kern/kern_clock.c:1.151
--- src/sys/kern/kern_clock.c:1.150	Fri Jul  7 12:34:50 2023
+++ src/sys/kern/kern_clock.c	Sat Sep  2 17:44:59 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_clock.c,v 1.150 2023/07/07 12:34:50 riastradh Exp $	*/
+/*	$NetBSD: kern_clock.c,v 1.151 2023/09/02 17:44:59 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,12 +69,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.150 2023/07/07 12:34:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.151 2023/09/02 17:44:59 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dtrace.h"
 #include "opt_gprof.h"
-#include "opt_heartbeat.h"
 #include "opt_multiprocessor.h"
 #endif
 
@@ -337,12 +336,10 @@ hardclock(struct clockframe *frame)
 		tc_ticktock();
 	}
 
-#ifdef HEARTBEAT
 	/*
 	 * Make sure the CPUs and timecounter are making progress.
 	 */
 	heartbeat();
-#endif
 
 	/*
 	 * Update real-time timeout queue.

Index: src/sys/kern/kern_cpu.c
diff -u src/sys/kern/kern_cpu.c:1.96 src/sys/kern/kern_cpu.c:1.97
--- src/sys/kern/kern_cpu.c:1.96	Sat Sep  2 17:43:28 2023
+++ src/sys/kern/kern_cpu.c	Sat Sep  2 17:44:59 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_cpu.c,v 1.96 2023/09/02 17:43:28 riastradh Exp $	*/
+/*	$NetBSD: kern_cpu.c,v 1.97 2023/09/02 17:44:59 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2010, 2012, 2019 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.96 2023/09/02 17:43:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.97 2023/09/02 17:44:59 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_cpu_ucode.h"
@@ -370,9 +370,7 @@ cpu_xc_offline(struct cpu_info *ci, void
 	pcu_save_all_on_cpu();
 #endif
 
-#ifdef HEARTBEAT
 	heartbeat_suspend();
-#endif
 
 #ifdef __HAVE_MD_CPU_OFFLINE
 	cpu_offline_md();
@@ -391,9 +389,7 @@ cpu_xc_online(struct cpu_info *ci, void 
 	struct schedstate_percpu *spc;
 	int s;
 
-#ifdef HEARTBEAT
 	heartbeat_resume();
-#endif
 
 	spc = &ci->ci_schedstate;
 	s = splsched();

Index: src/sys/sys/heartbeat.h
diff -u src/sys/sys/heartbeat.h:1.1 src/sys/sys/heartbeat.h:1.2
--- src/sys/sys/heartbeat.h:1.1	Fri Jul  7 12:34:50 2023
+++ src/sys/sys/heartbeat.h	Sat Sep  2 17:44:59 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: heartbeat.h,v 1.1 2023/07/07 12:34:50 riastradh Exp $	*/
+/*	$NetBSD: heartbeat.h,v 1.2 2023/09/02 17:44:59 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -48,6 +48,28 @@ void	heartbeat_resume(void);
 
 void	heartbeat_dump(void);
 
+#else
+
+static inline void
+heartbeat_start(void)
+{
+}
+
+static inline void
+heartbeat(void)
+{
+}
+
+static inline void
+heartbeat_suspend(void)
+{
+}
+
+static inline void
+heartbeat_resume(void)
+{
+}
+
 #endif
 
 #endif	/* _SYS_HEARTBEAT_H */

Reply via email to