heartbeat(9): Move #ifdef HEARTBEAT to sys/heartbeat.h.
Less error-prone this way, and the callers are less cluttered.
This commit is contained in:
parent
c0abd507e0
commit
792ae95f90
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 *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();
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue