From: cheloha Date: Thu, 14 Sep 2023 22:27:09 +0000 (+0000) Subject: clockintr: move hz(9)-based initialization out to initclocks() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=061f668f8b0f1681065e7f34e5a11c06f054ac68;p=openbsd clockintr: move hz(9)-based initialization out to initclocks() To separate the hardclock from the clock interrupt subsystem we'll need to move all related state out first. hz(9) is set when we return from cpu_initclocks(), so it's safe to move hardclock_period and roundrobin_period initialization out into initclocks(). Move hardclock_period itself out into kern_clock.c alongside the statclock variables. --- diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index b3fbbb49da6..22c62f1f064 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clock.c,v 1.118 2023/09/14 20:58:51 cheloha Exp $ */ +/* $OpenBSD: kern_clock.c,v 1.119 2023/09/14 22:27:09 cheloha Exp $ */ /* $NetBSD: kern_clock.c,v 1.34 1996/06/09 04:51:03 briggs Exp $ */ /*- @@ -87,6 +87,7 @@ int ticks = INT_MAX - (15 * 60 * HZ); /* Don't force early wrap around, triggers bug in inteldrm */ volatile unsigned long jiffies; +uint32_t hardclock_period; /* [I] hardclock period (ns) */ uint32_t statclock_avg; /* [I] average statclock period (ns) */ uint32_t statclock_min; /* [I] minimum statclock period (ns) */ uint32_t statclock_mask; /* [I] set of allowed offsets */ @@ -105,6 +106,10 @@ initclocks(void) */ cpu_initclocks(); + KASSERT(hz > 0 && hz <= 1000000000); + hardclock_period = 1000000000 / hz; + roundrobin_period = hardclock_period * 10; + KASSERT(stathz >= 1 && stathz <= 1000000000); /* diff --git a/sys/kern/kern_clockintr.c b/sys/kern/kern_clockintr.c index e5eaac3cca0..11d44a93676 100644 --- a/sys/kern/kern_clockintr.c +++ b/sys/kern/kern_clockintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clockintr.c,v 1.51 2023/09/14 22:07:11 cheloha Exp $ */ +/* $OpenBSD: kern_clockintr.c,v 1.52 2023/09/14 22:27:09 cheloha Exp $ */ /* * Copyright (c) 2003 Dale Rahn * Copyright (c) 2020 Mark Kettenis @@ -37,7 +37,6 @@ * I Immutable after initialization. */ uint32_t clockintr_flags; /* [I] global state + behavior flags */ -uint32_t hardclock_period; /* [I] hardclock period (ns) */ void clockintr_hardclock(struct clockintr *, void *, void *); void clockintr_schedule(struct clockintr *, uint64_t); @@ -61,10 +60,6 @@ clockintr_init(uint32_t flags) KASSERT(clockintr_flags == 0); KASSERT(!ISSET(flags, ~CL_FLAG_MASK)); - KASSERT(hz > 0 && hz <= 1000000000); - hardclock_period = 1000000000 / hz; - roundrobin_period = hardclock_period * 10; - SET(clockintr_flags, flags | CL_INIT); }