diff options
author | Scott Soule Cheloha <cheloha@cvs.openbsd.org> | 2023-09-14 19:39:49 +0000 |
---|---|---|
committer | Scott Soule Cheloha <cheloha@cvs.openbsd.org> | 2023-09-14 19:39:49 +0000 |
commit | 23d4dbc72605b1f0fa928f1a867d23f4130148de (patch) | |
tree | e6d8a4f068fedbe8cc4c573a15fe4545651d42ff /sys | |
parent | 05d6d03a7d1d98b3c545a840954ab5e68b0e9ac7 (diff) |
clockintr: replace CL_RNDSTAT with global variable statclock_is_randomized
In order to separate the statclock from the clock interrupt subsystem
we need to move all statclock state out into the broader kernel.
Start by replacing the CL_RNDSTAT flag with a new global variable,
"statclock_is_randomized", in kern_clock.c. Update all clockintr_init()
callers to set the boolean instead of passing the flag.
Thread: https://marc.info/?l=openbsd-tech&m=169428749720476&w=2
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/amd64/lapic.c | 5 | ||||
-rw-r--r-- | sys/arch/arm/cortex/agtimer.c | 5 | ||||
-rw-r--r-- | sys/arch/arm/cortex/amptimer.c | 5 | ||||
-rw-r--r-- | sys/arch/arm64/dev/agtimer.c | 5 | ||||
-rw-r--r-- | sys/arch/armv7/omap/dmtimer.c | 5 | ||||
-rw-r--r-- | sys/arch/armv7/omap/gptimer.c | 5 | ||||
-rw-r--r-- | sys/arch/armv7/sunxi/sxitimer.c | 5 | ||||
-rw-r--r-- | sys/arch/hppa/dev/clock.c | 5 | ||||
-rw-r--r-- | sys/arch/i386/i386/lapic.c | 5 | ||||
-rw-r--r-- | sys/arch/loongson/dev/glxclk.c | 5 | ||||
-rw-r--r-- | sys/arch/macppc/macppc/clock.c | 5 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/clock.c | 5 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/clock.c | 5 | ||||
-rw-r--r-- | sys/arch/riscv64/riscv64/clock.c | 5 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/clock.c | 5 | ||||
-rw-r--r-- | sys/kern/kern_clock.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_clockintr.c | 6 | ||||
-rw-r--r-- | sys/sys/clockintr.h | 5 | ||||
-rw-r--r-- | sys/sys/systm.h | 3 |
19 files changed, 55 insertions, 38 deletions
diff --git a/sys/arch/amd64/amd64/lapic.c b/sys/arch/amd64/amd64/lapic.c index 4e7182ecb5e..6f9c2ace887 100644 --- a/sys/arch/amd64/amd64/lapic.c +++ b/sys/arch/amd64/amd64/lapic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lapic.c,v 1.69 2023/08/23 01:55:46 cheloha Exp $ */ +/* $OpenBSD: lapic.c,v 1.70 2023/09/14 19:39:47 cheloha Exp $ */ /* $NetBSD: lapic.c,v 1.2 2003/05/08 01:04:35 fvdl Exp $ */ /*- @@ -498,7 +498,8 @@ lapic_initclocks(void) stathz = hz; profhz = stathz * 10; - clockintr_init(CL_RNDSTAT); + statclock_is_randomized = 1; + clockintr_init(0); } diff --git a/sys/arch/arm/cortex/agtimer.c b/sys/arch/arm/cortex/agtimer.c index 88e201abe8a..106cb4804c0 100644 --- a/sys/arch/arm/cortex/agtimer.c +++ b/sys/arch/arm/cortex/agtimer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agtimer.c,v 1.19 2023/08/23 01:55:46 cheloha Exp $ */ +/* $OpenBSD: agtimer.c,v 1.20 2023/09/14 19:39:47 cheloha Exp $ */ /* * Copyright (c) 2011 Dale Rahn <drahn@openbsd.org> * Copyright (c) 2013 Patrick Wildt <patrick@blueri.se> @@ -230,7 +230,8 @@ agtimer_cpu_initclocks(void) stathz = hz; profhz = stathz * 10; - clockintr_init(CL_RNDSTAT); + statclock_is_randomized = 1; + clockintr_init(0); if (sc->sc_ticks_per_second != agtimer_frequency) { agtimer_set_clockrate(agtimer_frequency); diff --git a/sys/arch/arm/cortex/amptimer.c b/sys/arch/arm/cortex/amptimer.c index 299f9fe8c61..1fb5695c00b 100644 --- a/sys/arch/arm/cortex/amptimer.c +++ b/sys/arch/arm/cortex/amptimer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: amptimer.c,v 1.18 2023/08/23 01:55:46 cheloha Exp $ */ +/* $OpenBSD: amptimer.c,v 1.19 2023/09/14 19:39:47 cheloha Exp $ */ /* * Copyright (c) 2011 Dale Rahn <drahn@openbsd.org> * @@ -287,7 +287,8 @@ amptimer_cpu_initclocks(void) stathz = hz; profhz = hz * 10; - clockintr_init(CL_RNDSTAT); + statclock_is_randomized = 1; + clockintr_init(0); if (sc->sc_ticks_per_second != amptimer_frequency) { amptimer_set_clockrate(amptimer_frequency); diff --git a/sys/arch/arm64/dev/agtimer.c b/sys/arch/arm64/dev/agtimer.c index 14fb14f0088..12b21c2a79b 100644 --- a/sys/arch/arm64/dev/agtimer.c +++ b/sys/arch/arm64/dev/agtimer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agtimer.c,v 1.26 2023/08/23 01:55:46 cheloha Exp $ */ +/* $OpenBSD: agtimer.c,v 1.27 2023/09/14 19:39:47 cheloha Exp $ */ /* * Copyright (c) 2011 Dale Rahn <drahn@openbsd.org> * Copyright (c) 2013 Patrick Wildt <patrick@blueri.se> @@ -293,7 +293,8 @@ agtimer_cpu_initclocks(void) stathz = hz; profhz = stathz * 10; - clockintr_init(CL_RNDSTAT); + statclock_is_randomized = 1; + clockintr_init(0); if (sc->sc_ticks_per_second != agtimer_frequency) { agtimer_set_clockrate(agtimer_frequency); diff --git a/sys/arch/armv7/omap/dmtimer.c b/sys/arch/armv7/omap/dmtimer.c index 985428bd6d3..5aaee39405c 100644 --- a/sys/arch/armv7/omap/dmtimer.c +++ b/sys/arch/armv7/omap/dmtimer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dmtimer.c,v 1.20 2023/08/23 01:55:46 cheloha Exp $ */ +/* $OpenBSD: dmtimer.c,v 1.21 2023/09/14 19:39:47 cheloha Exp $ */ /* * Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org> * Copyright (c) 2013 Raphael Graf <r@undefined.ch> @@ -232,7 +232,8 @@ dmtimer_cpu_initclocks(void) stathz = hz; profhz = stathz * 10; - clockintr_init(CL_RNDSTAT); + statclock_is_randomized = 1; + clockintr_init(0); sc->sc_ticks_per_second = TIMER_FREQUENCY; /* 32768 */ sc->sc_nsec_cycle_ratio = diff --git a/sys/arch/armv7/omap/gptimer.c b/sys/arch/armv7/omap/gptimer.c index 72cf3e0566a..8ca887098fd 100644 --- a/sys/arch/armv7/omap/gptimer.c +++ b/sys/arch/armv7/omap/gptimer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gptimer.c,v 1.21 2023/08/23 01:55:46 cheloha Exp $ */ +/* $OpenBSD: gptimer.c,v 1.22 2023/09/14 19:39:47 cheloha Exp $ */ /* * Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org> * @@ -198,7 +198,8 @@ gptimer_cpu_initclocks(void) { stathz = hz; profhz = stathz * 10; - clockintr_init(CL_RNDSTAT); + statclock_is_randomized = 1; + clockintr_init(0); gptimer_nsec_cycle_ratio = TIMER_FREQUENCY * (1ULL << 32) / 1000000000; gptimer_nsec_max = UINT64_MAX / gptimer_nsec_cycle_ratio; diff --git a/sys/arch/armv7/sunxi/sxitimer.c b/sys/arch/armv7/sunxi/sxitimer.c index 81b36f9c23b..9bee18a9e19 100644 --- a/sys/arch/armv7/sunxi/sxitimer.c +++ b/sys/arch/armv7/sunxi/sxitimer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sxitimer.c,v 1.22 2023/08/23 01:55:46 cheloha Exp $ */ +/* $OpenBSD: sxitimer.c,v 1.23 2023/09/14 19:39:47 cheloha Exp $ */ /* * Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org> * Copyright (c) 2013 Raphael Graf <r@undefined.ch> @@ -180,7 +180,8 @@ sxitimer_attach(struct device *parent, struct device *self, void *aux) stathz = hz; profhz = stathz * 10; - clockintr_init(CL_RNDSTAT); + statclock_is_randomized = 1; + clockintr_init(0); /* stop timer, and set clk src */ bus_space_write_4(sxitimer_iot, sxitimer_ioh, diff --git a/sys/arch/hppa/dev/clock.c b/sys/arch/hppa/dev/clock.c index 2bae218e3c8..3e54c5034ca 100644 --- a/sys/arch/hppa/dev/clock.c +++ b/sys/arch/hppa/dev/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.37 2023/08/23 01:55:46 cheloha Exp $ */ +/* $OpenBSD: clock.c,v 1.38 2023/09/14 19:39:48 cheloha Exp $ */ /* * Copyright (c) 1998-2003 Michael Shalayeff @@ -116,7 +116,8 @@ cpu_initclocks(void) stathz = hz; profhz = stathz * 10; - clockintr_init(CL_RNDSTAT); + statclock_is_randomized = 1; + clockintr_init(0); itmr_nsec_cycle_ratio = itmr_freq * (1ULL << 32) / 1000000000; itmr_nsec_max = UINT64_MAX / itmr_nsec_cycle_ratio; diff --git a/sys/arch/i386/i386/lapic.c b/sys/arch/i386/i386/lapic.c index 49d9dfcfe89..97cfb45979a 100644 --- a/sys/arch/i386/i386/lapic.c +++ b/sys/arch/i386/i386/lapic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lapic.c,v 1.56 2023/08/23 01:55:46 cheloha Exp $ */ +/* $OpenBSD: lapic.c,v 1.57 2023/09/14 19:39:48 cheloha Exp $ */ /* $NetBSD: lapic.c,v 1.1.2.8 2000/02/23 06:10:50 sommerfeld Exp $ */ /*- @@ -326,7 +326,8 @@ lapic_initclocks(void) stathz = hz; profhz = stathz * 10; - clockintr_init(CL_RNDSTAT); + statclock_is_randomized = 1; + clockintr_init(0); } extern int gettick(void); /* XXX put in header file */ diff --git a/sys/arch/loongson/dev/glxclk.c b/sys/arch/loongson/dev/glxclk.c index 652462d534f..d3df7cf941c 100644 --- a/sys/arch/loongson/dev/glxclk.c +++ b/sys/arch/loongson/dev/glxclk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: glxclk.c,v 1.9 2023/08/26 09:37:43 visa Exp $ */ +/* $OpenBSD: glxclk.c,v 1.10 2023/09/14 19:39:48 cheloha Exp $ */ /* * Copyright (c) 2013 Paul Irofti. @@ -189,10 +189,11 @@ glxclk_initclock(void) */ stathz = hz = 128; profhz = hz * 10; + statclock_is_randomized = 1; tick = 1000000 / hz; tick_nsec = 1000000000 / hz; - clockintr_init(CL_RNDSTAT); + clockintr_init(0); } void diff --git a/sys/arch/macppc/macppc/clock.c b/sys/arch/macppc/macppc/clock.c index 93084b0573a..a9bed56a627 100644 --- a/sys/arch/macppc/macppc/clock.c +++ b/sys/arch/macppc/macppc/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.56 2023/08/23 01:55:47 cheloha Exp $ */ +/* $OpenBSD: clock.c,v 1.57 2023/09/14 19:39:48 cheloha Exp $ */ /* $NetBSD: clock.c,v 1.1 1996/09/30 16:34:40 ws Exp $ */ /* @@ -195,7 +195,8 @@ cpu_initclocks(void) stathz = hz; profhz = stathz * 10; - clockintr_init(CL_RNDSTAT); + statclock_is_randomized = 1; + clockintr_init(0); dec_nsec_cycle_ratio = ticks_per_sec * (1ULL << 32) / 1000000000; dec_nsec_max = UINT64_MAX / dec_nsec_cycle_ratio; diff --git a/sys/arch/mips64/mips64/clock.c b/sys/arch/mips64/mips64/clock.c index afcf68c509b..0afc2e7c73d 100644 --- a/sys/arch/mips64/mips64/clock.c +++ b/sys/arch/mips64/mips64/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.51 2023/08/23 01:55:47 cheloha Exp $ */ +/* $OpenBSD: clock.c,v 1.52 2023/09/14 19:39:48 cheloha Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -241,7 +241,8 @@ cp0_initclock(void) stathz = hz; profhz = stathz * 10; - clockintr_init(CL_RNDSTAT); + statclock_is_randomized = 1; + clockintr_init(0); } /* diff --git a/sys/arch/powerpc64/powerpc64/clock.c b/sys/arch/powerpc64/powerpc64/clock.c index 39cab54e93c..7de2ac52c2e 100644 --- a/sys/arch/powerpc64/powerpc64/clock.c +++ b/sys/arch/powerpc64/powerpc64/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.12 2023/08/23 01:55:47 cheloha Exp $ */ +/* $OpenBSD: clock.c,v 1.13 2023/09/14 19:39:48 cheloha Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -94,7 +94,8 @@ cpu_initclocks(void) stathz = hz; profhz = stathz * 10; - clockintr_init(CL_RNDSTAT); + statclock_is_randomized = 1; + clockintr_init(0); evcount_attach(&clock_count, "clock", NULL); } diff --git a/sys/arch/riscv64/riscv64/clock.c b/sys/arch/riscv64/riscv64/clock.c index cd8c8ec6da6..5685e9c4d85 100644 --- a/sys/arch/riscv64/riscv64/clock.c +++ b/sys/arch/riscv64/riscv64/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.11 2023/08/23 01:55:47 cheloha Exp $ */ +/* $OpenBSD: clock.c,v 1.12 2023/09/14 19:39:48 cheloha Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -92,7 +92,8 @@ cpu_initclocks(void) stathz = hz; profhz = stathz * 10; - clockintr_init(CL_RNDSTAT); + statclock_is_randomized = 1; + clockintr_init(0); riscv_intc_intr_establish(IRQ_TIMER_SUPERVISOR, 0, clock_intr, NULL, NULL); diff --git a/sys/arch/sparc64/sparc64/clock.c b/sys/arch/sparc64/sparc64/clock.c index 9255d571a2e..84ec8404d6e 100644 --- a/sys/arch/sparc64/sparc64/clock.c +++ b/sys/arch/sparc64/sparc64/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.80 2023/08/23 01:55:47 cheloha Exp $ */ +/* $OpenBSD: clock.c,v 1.81 2023/09/14 19:39:48 cheloha Exp $ */ /* $NetBSD: clock.c,v 1.41 2001/07/24 19:29:25 eeh Exp $ */ /* @@ -501,7 +501,8 @@ cpu_initclocks(void) stathz = hz; profhz = stathz * 10; - clockintr_init(CL_RNDSTAT); + statclock_is_randomized = 1; + clockintr_init(0); /* Make sure we have a sane cpu_clockrate -- we'll need it */ if (!cpu_clockrate) diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 1c8da764a31..e23ab3e9833 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clock.c,v 1.116 2023/09/09 18:19:03 cheloha Exp $ */ +/* $OpenBSD: kern_clock.c,v 1.117 2023/09/14 19:39:47 cheloha Exp $ */ /* $NetBSD: kern_clock.c,v 1.34 1996/06/09 04:51:03 briggs Exp $ */ /*- @@ -86,6 +86,8 @@ int ticks = INT_MAX - (15 * 60 * HZ); /* Don't force early wrap around, triggers bug in inteldrm */ volatile unsigned long jiffies; +int statclock_is_randomized; /* [I] fixed or pseudorandom period? */ + /* * Initialize clock frequencies and start both clocks running. */ diff --git a/sys/kern/kern_clockintr.c b/sys/kern/kern_clockintr.c index aeeb7ed9158..ad92d10cddf 100644 --- a/sys/kern/kern_clockintr.c +++ b/sys/kern/kern_clockintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clockintr.c,v 1.47 2023/09/10 03:08:05 cheloha Exp $ */ +/* $OpenBSD: kern_clockintr.c,v 1.48 2023/09/14 19:39:47 cheloha Exp $ */ /* * Copyright (c) 2003 Dale Rahn <drahn@openbsd.org> * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -169,7 +169,7 @@ clockintr_cpu_init(const struct intrclock *ic) * We can always advance the statclock. There is no reason to * stagger a randomized statclock. */ - if (!ISSET(clockintr_flags, CL_RNDSTAT)) { + if (!statclock_is_randomized) { if (cq->cq_statclock->cl_expiration == 0) { clockintr_stagger(cq->cq_statclock, statclock_avg, multiplier, MAXCPUS); @@ -475,7 +475,7 @@ clockintr_statclock(struct clockintr *cl, void *frame, void *arg) { uint64_t count, i; - if (ISSET(clockintr_flags, CL_RNDSTAT)) { + if (statclock_is_randomized) { count = clockintr_advance_random(cl, statclock_min, statclock_mask); } else { diff --git a/sys/sys/clockintr.h b/sys/sys/clockintr.h index b4dceefa59a..3de42b6d436 100644 --- a/sys/sys/clockintr.h +++ b/sys/sys/clockintr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: clockintr.h,v 1.13 2023/09/10 03:08:05 cheloha Exp $ */ +/* $OpenBSD: clockintr.h,v 1.14 2023/09/14 19:39:47 cheloha Exp $ */ /* * Copyright (c) 2020-2022 Scott Cheloha <cheloha@openbsd.org> * @@ -115,8 +115,7 @@ struct clockintr_queue { #define CL_STATE_MASK 0x00000001 /* Global behavior flags. */ -#define CL_RNDSTAT 0x80000000 /* randomized statclock */ -#define CL_FLAG_MASK 0x80000000 +#define CL_FLAG_MASK 0x00000000 void clockintr_cpu_init(const struct intrclock *); int clockintr_dispatch(void *); diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 9a095f7d255..6d8a65bdb77 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: systm.h,v 1.165 2023/08/23 01:55:45 cheloha Exp $ */ +/* $OpenBSD: systm.h,v 1.166 2023/09/14 19:39:47 cheloha Exp $ */ /* $NetBSD: systm.h,v 1.50 1996/06/09 04:55:09 briggs Exp $ */ /*- @@ -234,6 +234,7 @@ int tstohz(const struct timespec *); void realitexpire(void *); extern uint32_t hardclock_period; +extern int statclock_is_randomized; struct clockframe; void hardclock(struct clockframe *); |