From 792ae95f9038548bbcfbca61d524784435176737 Mon Sep 17 00:00:00 2001 From: riastradh Date: Sat, 2 Sep 2023 17:44:59 +0000 Subject: [PATCH] heartbeat(9): Move #ifdef HEARTBEAT to sys/heartbeat.h. Less error-prone this way, and the callers are less cluttered. --- sys/dev/cons.c | 12 ++---------- sys/kern/init_main.c | 7 ++----- sys/kern/kern_clock.c | 7 ++----- sys/kern/kern_cpu.c | 8 ++------ sys/sys/heartbeat.h | 24 +++++++++++++++++++++++- 5 files changed, 31 insertions(+), 27 deletions(-) diff --git a/sys/dev/cons.c b/sys/dev/cons.c index 7a4836280a3c..f3a2387fbceb 100644 --- a/sys/dev/cons.c +++ b/sys/dev/cons.c @@ -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 -__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 @@ -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; diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 1d2dbd742fed..06fc706f0ff7 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -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 -__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(); diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 791301f8d6ac..72228c3ca994 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -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 -__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. diff --git a/sys/kern/kern_cpu.c b/sys/kern/kern_cpu.c index 6f8e1eb8a55b..38bd0d43b6de 100644 --- a/sys/kern/kern_cpu.c +++ b/sys/kern/kern_cpu.c @@ -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 -__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 *unused) 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 *unused) struct schedstate_percpu *spc; int s; -#ifdef HEARTBEAT heartbeat_resume(); -#endif spc = &ci->ci_schedstate; s = splsched(); diff --git a/sys/sys/heartbeat.h b/sys/sys/heartbeat.h index ef32feaf5ec6..1416cebe730b 100644 --- a/sys/sys/heartbeat.h +++ b/sys/sys/heartbeat.h @@ -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 */