-/* $OpenBSD: cpu.h,v 1.64 2021/06/02 00:39:26 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.65 2021/07/06 09:34:06 kettenis Exp $ */
/* $NetBSD: cpu.h,v 1.45 2000/08/21 02:03:12 thorpej Exp $ */
/*-
#define curcpu() ((struct cpu_info *)alpha_pal_rdval())
#define CPU_IS_PRIMARY(ci) ((ci)->ci_flags & CPUF_PRIMARY)
+#define CPU_IS_RUNNING(ci) ((ci)->ci_flags & CPUF_RUNNING)
void cpu_boot_secondary_processors(void);
#define curcpu() (&cpu_info_primary)
#define CPU_IS_PRIMARY(ci) 1
+#define CPU_IS_RUNNING(ci) 1
#define cpu_unidle(ci) do { /* nothing */ } while (0)
#define CPU_BUSY_CYCLE() do {} while (0)
-/* $OpenBSD: cpu.h,v 1.139 2021/06/18 06:17:28 guenther Exp $ */
+/* $OpenBSD: cpu.h,v 1.140 2021/07/06 09:34:06 kettenis Exp $ */
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/*-
#define cpu_number() (curcpu()->ci_cpuid)
#define CPU_IS_PRIMARY(ci) ((ci)->ci_flags & CPUF_PRIMARY)
+#define CPU_IS_RUNNING(ci) ((ci)->ci_flags & CPUF_RUNNING)
extern struct cpu_info *cpu_info[MAXCPUS];
*/
#define cpu_number() 0
#define CPU_IS_PRIMARY(ci) 1
+#define CPU_IS_RUNNING(ci) 1
#endif /* MULTIPROCESSOR */
-/* $OpenBSD: cpu.h,v 1.60 2021/06/02 00:39:26 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.61 2021/07/06 09:34:06 kettenis Exp $ */
/* $NetBSD: cpu.h,v 1.34 2003/06/23 11:01:08 martin Exp $ */
/*
#ifndef MULTIPROCESSOR
#define cpu_number() 0
#define CPU_IS_PRIMARY(ci) 1
+#define CPU_IS_RUNNING(ci) 1
#define CPU_INFO_ITERATOR int
#define CPU_INFO_FOREACH(cii, ci) \
for (cii = 0, ci = curcpu(); ci != NULL; ci = NULL)
#else
#define cpu_number() (curcpu()->ci_cpuid)
#define CPU_IS_PRIMARY(ci) ((ci) == &cpu_info_primary)
+#define CPU_IS_RUNNING(ci) ((ci)->ci_flags & CPUF_RUNNING)
#define CPU_INFO_ITERATOR int
#define CPU_INFO_FOREACH(cii, ci) for (cii = 0, ci = cpu_info_list; \
ci != NULL; ci = ci->ci_next)
-/* $OpenBSD: cpu.h,v 1.21 2021/06/02 00:39:26 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.22 2021/07/06 09:34:06 kettenis Exp $ */
/*
* Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com>
*
#ifndef MULTIPROCESSOR
#define cpu_number() 0
#define CPU_IS_PRIMARY(ci) 1
+#define CPU_IS_RUNNING(ci) 1
#define CPU_INFO_ITERATOR int
#define CPU_INFO_FOREACH(cii, ci) \
for (cii = 0, ci = curcpu(); ci != NULL; ci = NULL)
#else
#define cpu_number() (curcpu()->ci_cpuid)
#define CPU_IS_PRIMARY(ci) ((ci) == &cpu_info_primary)
+#define CPU_IS_RUNNING(ci) ((ci)->ci_flags & CPUF_RUNNING)
#define CPU_INFO_ITERATOR int
#define CPU_INFO_FOREACH(cii, ci) for (cii = 0, ci = cpu_info_list; \
ci != NULL; ci = ci->ci_next)
-/* $OpenBSD: cpu.h,v 1.94 2021/06/02 00:39:26 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.95 2021/07/06 09:34:06 kettenis Exp $ */
/*
* Copyright (c) 2000-2004 Michael Shalayeff
#define CPU_INFO_UNIT(ci) ((ci)->ci_dev ? (ci)->ci_dev->dv_unit : 0)
#define CPU_IS_PRIMARY(ci) ((ci)->ci_cpuid == 0)
+#define CPU_IS_RUNNING(ci) ((ci)->ci_flags & CPUF_RUNNING)
#define CPU_INFO_ITERATOR int
#define CPU_INFO_FOREACH(cii, ci) \
for (cii = 0, ci = &cpu_info[0]; cii < ncpus; cii++, ci++)
-/* $OpenBSD: cpu.h,v 1.174 2021/06/02 00:39:26 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.175 2021/07/06 09:34:06 kettenis Exp $ */
/* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */
/*-
#define cpu_number() (curcpu()->ci_cpuid)
#define CPU_IS_PRIMARY(ci) ((ci)->ci_flags & CPUF_PRIMARY)
+#define CPU_IS_RUNNING(ci) ((ci)->ci_flags & CPUF_RUNNING)
extern struct cpu_info *cpu_info[MAXCPUS];
#define curcpu() (&cpu_info_primary)
#define CPU_IS_PRIMARY(ci) 1
+#define CPU_IS_RUNNING(ci) 1
#define cpu_kick(ci)
#define cpu_unidle(ci)
-/* $OpenBSD: cpu.h,v 1.69 2021/06/02 00:39:26 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.70 2021/07/06 09:34:06 kettenis Exp $ */
/*
* Copyright (c) 1996 Nivas Madhur
* Copyright (c) 1992, 1993
}
#define CPU_IS_PRIMARY(ci) ((ci)->ci_flags & CIF_PRIMARY)
+#define CPU_IS_RUNNING(ci) ((ci)->ci_flags & CIF_ALIVE)
void cpu_boot_secondary_processors(void);
__dead void cpu_emergency_disable(void);
#define curcpu() (&m88k_cpus[0])
#define cpu_unidle(ci) do { /* nothing */ } while (0)
#define CPU_IS_PRIMARY(ci) 1
+#define CPU_IS_RUNNING(ci) 1
#endif /* MULTIPROCESSOR */
-/* $OpenBSD: cpu.h,v 1.134 2021/06/02 00:39:26 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.135 2021/07/06 09:34:06 kettenis Exp $ */
/*-
* Copyright (c) 1992, 1993
extern struct cpu_info *get_cpu_info(int);
#define curcpu() getcurcpu()
#define CPU_IS_PRIMARY(ci) ((ci)->ci_flags & CPUF_PRIMARY)
+#define CPU_IS_RUNNING(ci) ((ci)->ci_flags & CPUF_RUNNING)
#define cpu_number() (curcpu()->ci_cpuid)
extern struct cpuset cpus_running;
#define MAXCPUS 1
#define curcpu() (&cpu_info_primary)
#define CPU_IS_PRIMARY(ci) 1
+#define CPU_IS_RUNNING(ci) 1
#define cpu_number() 0UL
#define cpu_unidle(ci)
#define get_cpu_info(i) (&cpu_info_primary)
-/* $OpenBSD: cpu.h,v 1.69 2021/06/02 00:39:26 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.70 2021/07/06 09:34:06 kettenis Exp $ */
/* $NetBSD: cpu.h,v 1.1 1996/09/30 16:34:21 ws Exp $ */
/*
void cpu_boot_secondary_processors(void);
#define CPU_IS_PRIMARY(ci) ((ci)->ci_cpuid == 0)
+#define CPU_IS_RUNNING(ci) 1
#define CPU_INFO_ITERATOR int
#define CPU_INFO_FOREACH(cii, ci) \
for (cii = 0, ci = &cpu_info[0]; cii < ncpusfound; cii++, ci++)
#define cpu_number() 0
#define CPU_IS_PRIMARY(ci) 1
+#define CPU_IS_RUNNING(ci) 1
#define CPU_INFO_ITERATOR int
#define CPU_INFO_FOREACH(cii, ci) \
for (cii = 0, ci = curcpu(); ci != NULL; ci = NULL)
-/* $OpenBSD: cpu.h,v 1.30 2021/06/02 00:39:27 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.31 2021/07/06 09:34:07 kettenis Exp $ */
/*
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
#define MAXCPUS 1
#define CPU_IS_PRIMARY(ci) 1
+#define CPU_IS_RUNNING(ci) 1
#define cpu_number() 0
#define CPU_INFO_UNIT(ci) 0
#define MAXCPUS 48
#define CPU_IS_PRIMARY(ci) ((ci) == cpu_info_primary)
+#define CPU_IS_RUNNING(ci) ((ci)->ci_flags & CPUF_RUNNING)
#define cpu_number() (curcpu()->ci_cpuid)
#define CPU_INFO_UNIT(ci) ((ci)->ci_dev ? (ci)->ci_dev->dv_unit : 0)
-/* $OpenBSD: cpu.h,v 1.31 2021/06/02 00:39:27 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.32 2021/07/06 09:34:07 kettenis Exp $ */
/* $NetBSD: cpu.h,v 1.41 2006/01/21 04:24:12 uwe Exp $ */
/*-
#define curcpu() (&cpu_info_store)
#define cpu_number() 0
#define CPU_IS_PRIMARY(ci) 1
+#define CPU_IS_RUNNING(ci) 1
#define CPU_INFO_ITERATOR int
#define CPU_INFO_FOREACH(cii, ci) \
for (cii = 0, ci = curcpu(); ci != NULL; ci = NULL)
-/* $OpenBSD: cpu.h,v 1.97 2021/06/02 00:39:27 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.98 2021/07/06 09:34:07 kettenis Exp $ */
/* $NetBSD: cpu.h,v 1.28 2001/06/14 22:56:58 thorpej Exp $ */
/*
#define cpu_number() (__curcpu->ci_cpuid)
#define CPU_IS_PRIMARY(ci) ((ci)->ci_cpuid == 0)
+#define CPU_IS_RUNNING(ci) 1
#define CPU_INFO_ITERATOR int
#define CPU_INFO_FOREACH(cii, ci) \
for (cii = 0, ci = cpus; ci != NULL; ci = ci->ci_next)
#define cpu_number() 0
#define CPU_IS_PRIMARY(ci) 1
+#define CPU_IS_RUNNING(ci) 1
#define CPU_INFO_ITERATOR int
#define CPU_INFO_FOREACH(cii, ci) \
for (cii = 0, ci = curcpu(); ci != NULL; ci = NULL)
-/* $OpenBSD: kern_sched.c,v 1.71 2021/06/29 21:31:49 kettenis Exp $ */
+/* $OpenBSD: kern_sched.c,v 1.72 2021/07/06 09:34:07 kettenis Exp $ */
/*
* Copyright (c) 2007, 2008 Artur Grabowski <art@openbsd.org>
*
CPU_INFO_FOREACH(cii, ci) {
struct schedstate_percpu *spc = &ci->ci_schedstate;
- if (CPU_IS_PRIMARY(ci))
+ if (CPU_IS_PRIMARY(ci) || !CPU_IS_RUNNING(ci))
continue;
atomic_clearbits_int(&spc->spc_schedflags,
SPCF_SHOULDHALT | SPCF_HALTED);
CPU_INFO_FOREACH(cii, ci) {
struct schedstate_percpu *spc = &ci->ci_schedstate;
- if (CPU_IS_PRIMARY(ci))
+ if (CPU_IS_PRIMARY(ci) || !CPU_IS_RUNNING(ci))
continue;
cpuset_del(&sched_all_cpus, ci);
atomic_setbits_int(&spc->spc_schedflags, SPCF_SHOULDHALT);
struct schedstate_percpu *spc = &ci->ci_schedstate;
struct sleep_state sls;
- if (CPU_IS_PRIMARY(ci))
+ if (CPU_IS_PRIMARY(ci) || !CPU_IS_RUNNING(ci))
continue;
while ((spc->spc_schedflags & SPCF_HALTED) == 0) {
sleep_setup(&sls, spc, PZERO, "schedstate", 0);
sched_smt = newsmt;
CPU_INFO_FOREACH(cii, ci) {
- if (CPU_IS_PRIMARY(ci))
+ if (CPU_IS_PRIMARY(ci) || !CPU_IS_RUNNING(ci))
continue;
if (ci->ci_smt_id == 0)
continue;
-/* $OpenBSD: kern_smr.c,v 1.11 2021/06/29 21:31:49 kettenis Exp $ */
+/* $OpenBSD: kern_smr.c,v 1.12 2021/07/06 09:34:07 kettenis Exp $ */
/*
* Copyright (c) 2019-2020 Visa Hankala
curcpu()->ci_schedstate.spc_smrgp = smrgp;
CPU_INFO_FOREACH(cii, ci) {
+ if (!CPU_IS_RUNNING(ci))
+ continue;
if (READ_ONCE(ci->ci_schedstate.spc_smrgp) == smrgp)
continue;
sched_peg_curproc(ci);