From 2298d1a8a8b6e5f0218eb7258f4da0805ba10381 Mon Sep 17 00:00:00 2001 From: cheloha Date: Thu, 15 Jun 2023 22:18:06 +0000 Subject: [PATCH] all platforms, main(): call clockqueue_init() just before sched_init_cpu() Move the clockqueue_init() call out of clockintr_cpu_init() and up just before the sched_init_cpu() call for a given CPU. This will allow sched_init_cpu() to allocate clockintr handles for a given CPU's scheduler in a later patch. Link: https://marc.info/?l=openbsd-tech&m=168661507607622&w=2 ok kettenis@, claudio@ --- sys/arch/alpha/alpha/cpu.c | 3 ++- sys/arch/amd64/amd64/cpu.c | 3 ++- sys/arch/arm/arm/cpu.c | 3 ++- sys/arch/arm64/arm64/cpu.c | 3 ++- sys/arch/hppa/dev/cpu.c | 3 ++- sys/arch/i386/i386/cpu.c | 3 ++- sys/arch/luna88k/luna88k/machdep.c | 3 ++- sys/arch/macppc/macppc/cpu.c | 3 ++- sys/arch/mips64/mips64/cpu.c | 3 ++- sys/arch/powerpc64/powerpc64/cpu.c | 3 ++- sys/arch/riscv64/riscv64/cpu.c | 3 ++- sys/arch/sparc64/sparc64/cpu.c | 3 ++- sys/kern/init_main.c | 4 +++- sys/kern/kern_clockintr.c | 4 +--- sys/sys/clockintr.h | 3 ++- 15 files changed, 30 insertions(+), 17 deletions(-) diff --git a/sys/arch/alpha/alpha/cpu.c b/sys/arch/alpha/alpha/cpu.c index e2c1671497e..03d035c3100 100644 --- a/sys/arch/alpha/alpha/cpu.c +++ b/sys/arch/alpha/alpha/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.46 2022/12/10 15:02:29 cheloha Exp $ */ +/* $OpenBSD: cpu.c,v 1.47 2023/06/15 22:18:06 cheloha Exp $ */ /* $NetBSD: cpu.c,v 1.44 2000/05/23 05:12:53 thorpej Exp $ */ /*- @@ -597,6 +597,7 @@ cpu_hatch(struct cpu_info *ci) ALPHA_TBIA(); alpha_pal_imb(); + clockqueue_init(&ci->ci_queue); KERNEL_LOCK(); sched_init_cpu(ci); nanouptime(&ci->ci_schedstate.spc_runtime); diff --git a/sys/arch/amd64/amd64/cpu.c b/sys/arch/amd64/amd64/cpu.c index ab5013e6591..e2c4067d0e1 100644 --- a/sys/arch/amd64/amd64/cpu.c +++ b/sys/arch/amd64/amd64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.168 2023/04/24 09:04:03 dv Exp $ */ +/* $OpenBSD: cpu.c,v 1.169 2023/06/15 22:18:06 cheloha Exp $ */ /* $NetBSD: cpu.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */ /*- @@ -664,6 +664,7 @@ cpu_attach(struct device *parent, struct device *self, void *aux) #if defined(MULTIPROCESSOR) cpu_intr_init(ci); cpu_start_secondary(ci); + clockqueue_init(&ci->ci_queue); sched_init_cpu(ci); ncpus++; if (ci->ci_flags & CPUF_PRESENT) { diff --git a/sys/arch/arm/arm/cpu.c b/sys/arch/arm/arm/cpu.c index 9c1b78c9af5..0383d68f3d4 100644 --- a/sys/arch/arm/arm/cpu.c +++ b/sys/arch/arm/arm/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.57 2022/03/12 14:40:41 mpi Exp $ */ +/* $OpenBSD: cpu.c,v 1.58 2023/06/15 22:18:06 cheloha Exp $ */ /* $NetBSD: cpu.c,v 1.56 2004/04/14 04:01:49 bsh Exp $ */ @@ -391,6 +391,7 @@ cpu_attach(struct device *parent, struct device *dev, void *aux) "cpu-release-addr", 0); } + clockqueue_init(&ci->ci_queue); sched_init_cpu(ci); if (cpu_hatch_secondary(ci, spinup_method, spinup_data)) { atomic_setbits_int(&ci->ci_flags, CPUF_IDENTIFY); diff --git a/sys/arch/arm64/arm64/cpu.c b/sys/arch/arm64/arm64/cpu.c index ba65a237025..3a59d5d33bb 100644 --- a/sys/arch/arm64/arm64/cpu.c +++ b/sys/arch/arm64/arm64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.94 2023/06/11 21:42:01 kettenis Exp $ */ +/* $OpenBSD: cpu.c,v 1.95 2023/06/15 22:18:07 cheloha Exp $ */ /* * Copyright (c) 2016 Dale Rahn @@ -875,6 +875,7 @@ cpu_attach(struct device *parent, struct device *dev, void *aux) "cpu-release-addr", 0); } + clockqueue_init(&ci->ci_queue); sched_init_cpu(ci); if (cpu_start_secondary(ci, spinup_method, spinup_data)) { atomic_setbits_int(&ci->ci_flags, CPUF_IDENTIFY); diff --git a/sys/arch/hppa/dev/cpu.c b/sys/arch/hppa/dev/cpu.c index 91dd7dd263c..bc778f69d12 100644 --- a/sys/arch/hppa/dev/cpu.c +++ b/sys/arch/hppa/dev/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.44 2022/12/06 00:40:09 cheloha Exp $ */ +/* $OpenBSD: cpu.c,v 1.45 2023/06/15 22:18:07 cheloha Exp $ */ /* * Copyright (c) 1998-2003 Michael Shalayeff @@ -202,6 +202,7 @@ cpu_boot_secondary_processors(void) ci->ci_randseed = (arc4random() & 0x7fffffff) + 1; + clockqueue_init(&ci->ci_queue); sched_init_cpu(ci); /* Release the specified CPU by triggering an EIR{0}. */ diff --git a/sys/arch/i386/i386/cpu.c b/sys/arch/i386/i386/cpu.c index 1baf2c7f9bc..c0b989e0df3 100644 --- a/sys/arch/i386/i386/cpu.c +++ b/sys/arch/i386/i386/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.111 2023/01/30 10:49:04 jsg Exp $ */ +/* $OpenBSD: cpu.c,v 1.112 2023/06/15 22:18:07 cheloha Exp $ */ /* $NetBSD: cpu.c,v 1.1.2.7 2000/06/26 02:04:05 sommerfeld Exp $ */ /*- @@ -360,6 +360,7 @@ cpu_attach(struct device *parent, struct device *self, void *aux) #endif cpu_tsx_disable(ci); identifycpu(ci); + clockqueue_init(&ci->ci_queue); sched_init_cpu(ci); ci->ci_next = cpu_info_list->ci_next; cpu_info_list->ci_next = ci; diff --git a/sys/arch/luna88k/luna88k/machdep.c b/sys/arch/luna88k/luna88k/machdep.c index 3a629d879f7..fd4c41212c4 100644 --- a/sys/arch/luna88k/luna88k/machdep.c +++ b/sys/arch/luna88k/luna88k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.142 2022/12/10 02:41:56 aoyama Exp $ */ +/* $OpenBSD: machdep.c,v 1.143 2023/06/15 22:18:07 cheloha Exp $ */ /* * Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -762,6 +762,7 @@ secondary_main() cpu_configuration_print(0); ncpus++; + clockqueue_init(&ci->ci_queue); sched_init_cpu(ci); nanouptime(&ci->ci_schedstate.spc_runtime); ci->ci_curproc = NULL; diff --git a/sys/arch/macppc/macppc/cpu.c b/sys/arch/macppc/macppc/cpu.c index f40443a0650..8a1ca0684a0 100644 --- a/sys/arch/macppc/macppc/cpu.c +++ b/sys/arch/macppc/macppc/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.85 2022/03/13 12:33:01 mpi Exp $ */ +/* $OpenBSD: cpu.c,v 1.86 2023/06/15 22:18:07 cheloha Exp $ */ /* * Copyright (c) 1997 Per Fogelstrom @@ -670,6 +670,7 @@ cpu_boot_secondary_processors(void) continue; ci->ci_randseed = (arc4random() & 0x7fffffff) + 1; + clockqueue_init(&ci->ci_queue); sched_init_cpu(ci); cpu_spinup(NULL, ci); diff --git a/sys/arch/mips64/mips64/cpu.c b/sys/arch/mips64/mips64/cpu.c index 83f75fb8c4d..4e4a89976dc 100644 --- a/sys/arch/mips64/mips64/cpu.c +++ b/sys/arch/mips64/mips64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.82 2022/04/06 18:59:26 naddy Exp $ */ +/* $OpenBSD: cpu.c,v 1.83 2023/06/15 22:18:07 cheloha Exp $ */ /* * Copyright (c) 1997-2004 Opsycon AB (www.opsycon.se) @@ -395,6 +395,7 @@ cpu_boot_secondary_processors(void) continue; ci->ci_randseed = (arc4random() & 0x7fffffff) + 1; + clockqueue_init(&ci->ci_queue); sched_init_cpu(ci); cpu_boot_secondary(ci); } diff --git a/sys/arch/powerpc64/powerpc64/cpu.c b/sys/arch/powerpc64/powerpc64/cpu.c index f8f10741264..922d34489c1 100644 --- a/sys/arch/powerpc64/powerpc64/cpu.c +++ b/sys/arch/powerpc64/powerpc64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.25 2023/01/25 09:53:53 kettenis Exp $ */ +/* $OpenBSD: cpu.c,v 1.26 2023/06/15 22:18:07 cheloha Exp $ */ /* * Copyright (c) 2020 Mark Kettenis @@ -189,6 +189,7 @@ cpu_attach(struct device *parent, struct device *dev, void *aux) if (dev->dv_unit != 0) { int timeout = 10000; + clockqueue_init(&ci->ci_queue); sched_init_cpu(ci); ncpus++; diff --git a/sys/arch/riscv64/riscv64/cpu.c b/sys/arch/riscv64/riscv64/cpu.c index 4996f3a25fa..6825a6b3424 100644 --- a/sys/arch/riscv64/riscv64/cpu.c +++ b/sys/arch/riscv64/riscv64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.13 2022/04/06 18:59:27 naddy Exp $ */ +/* $OpenBSD: cpu.c,v 1.14 2023/06/15 22:18:08 cheloha Exp $ */ /* * Copyright (c) 2016 Dale Rahn @@ -193,6 +193,7 @@ cpu_attach(struct device *parent, struct device *dev, void *aux) if (ci->ci_flags & CPUF_AP) { int timeout = 10000; + clockqueue_init(&ci->ci_queue); sched_init_cpu(ci); if (cpu_hatch_secondary(ci)) { atomic_setbits_int(&ci->ci_flags, CPUF_IDENTIFY); diff --git a/sys/arch/sparc64/sparc64/cpu.c b/sys/arch/sparc64/sparc64/cpu.c index 8907bb75698..be893f6b191 100644 --- a/sys/arch/sparc64/sparc64/cpu.c +++ b/sys/arch/sparc64/sparc64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.73 2021/10/24 17:05:04 mpi Exp $ */ +/* $OpenBSD: cpu.c,v 1.74 2023/06/15 22:18:08 cheloha Exp $ */ /* $NetBSD: cpu.c,v 1.13 2001/05/26 21:27:15 chs Exp $ */ /* @@ -185,6 +185,7 @@ alloc_cpuinfo(struct mainbus_attach_args *ma) cpi->ci_self = cpi; cpi->ci_node = ma->ma_node; + clockqueue_init(&cpi->ci_queue); sched_init_cpu(cpi); /* diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 31e2e31f78a..4cf78a2f60d 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.320 2023/01/01 07:00:51 jsg Exp $ */ +/* $OpenBSD: init_main.c,v 1.321 2023/06/15 22:18:06 cheloha Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -313,6 +314,7 @@ main(void *framep) /* Initialize run queues */ sched_init_runqueues(); sleep_queue_init(); + clockqueue_init(&curcpu()->ci_queue); sched_init_cpu(curcpu()); p->p_cpu->ci_randseed = (arc4random() & 0x7fffffff) + 1; diff --git a/sys/kern/kern_clockintr.c b/sys/kern/kern_clockintr.c index 2732e0f95ec..bcd583c193c 100644 --- a/sys/kern/kern_clockintr.c +++ b/sys/kern/kern_clockintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clockintr.c,v 1.21 2023/04/23 00:08:36 cheloha Exp $ */ +/* $OpenBSD: kern_clockintr.c,v 1.22 2023/06/15 22:18:06 cheloha Exp $ */ /* * Copyright (c) 2003 Dale Rahn * Copyright (c) 2020 Mark Kettenis @@ -66,7 +66,6 @@ void clockintr_schedule(struct clockintr *, uint64_t); void clockintr_schedule_locked(struct clockintr *, uint64_t); void clockintr_statclock(struct clockintr *, void *); void clockintr_statvar_init(int, uint32_t *, uint32_t *, uint32_t *); -void clockqueue_init(struct clockintr_queue *); uint64_t clockqueue_next(const struct clockintr_queue *); void clockqueue_reset_intrclock(struct clockintr_queue *); uint64_t nsec_advance(uint64_t *, uint64_t, uint64_t); @@ -114,7 +113,6 @@ clockintr_cpu_init(const struct intrclock *ic) KASSERT(ISSET(clockintr_flags, CL_INIT)); - clockqueue_init(cq); if (ic != NULL && !ISSET(cq->cq_flags, CQ_INTRCLOCK)) { cq->cq_intrclock = *ic; SET(cq->cq_flags, CQ_INTRCLOCK); diff --git a/sys/sys/clockintr.h b/sys/sys/clockintr.h index 19fa5459a7e..c6e3659d0af 100644 --- a/sys/sys/clockintr.h +++ b/sys/sys/clockintr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: clockintr.h,v 1.7 2023/04/20 14:51:28 cheloha Exp $ */ +/* $OpenBSD: clockintr.h,v 1.8 2023/06/15 22:18:06 cheloha Exp $ */ /* * Copyright (c) 2020-2022 Scott Cheloha * @@ -129,6 +129,7 @@ void clockintr_trigger(void); * Kernel API */ +void clockqueue_init(struct clockintr_queue *); int sysctl_clockintr(int *, u_int, void *, size_t *, void *, size_t); #endif /* _KERNEL */ -- 2.20.1