From 529ac4429f87505c3aab327b409d2c6e96e43621 Mon Sep 17 00:00:00 2001 From: cheloha Date: Wed, 6 Sep 2023 02:09:58 +0000 Subject: [PATCH] clockintr: clockintr_establish: change first argument to a cpu_info pointer All CPUs control a single clockintr_queue. clockintr_establish() callers don't need to know about the underlying clockintr_queue. Accepting a cpu_info pointer as argument simplifies the API. From mpi@. ok mpi@ --- sys/kern/kern_clockintr.c | 9 +++++---- sys/kern/kern_sched.c | 8 ++++---- sys/kern/subr_prof.c | 5 ++--- sys/sys/clockintr.h | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sys/kern/kern_clockintr.c b/sys/kern/kern_clockintr.c index b4e5901226d..40a0c5a0412 100644 --- a/sys/kern/kern_clockintr.c +++ b/sys/kern/kern_clockintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clockintr.c,v 1.36 2023/09/05 22:41:14 cheloha Exp $ */ +/* $OpenBSD: kern_clockintr.c,v 1.37 2023/09/06 02:09:58 cheloha Exp $ */ /* * Copyright (c) 2003 Dale Rahn * Copyright (c) 2020 Mark Kettenis @@ -112,12 +112,12 @@ clockintr_cpu_init(const struct intrclock *ic) /* TODO: Remove these from struct clockintr_queue. */ if (cq->cq_hardclock == NULL) { - cq->cq_hardclock = clockintr_establish(cq, clockintr_hardclock); + cq->cq_hardclock = clockintr_establish(ci, clockintr_hardclock); if (cq->cq_hardclock == NULL) panic("%s: failed to establish hardclock", __func__); } if (cq->cq_statclock == NULL) { - cq->cq_statclock = clockintr_establish(cq, clockintr_statclock); + cq->cq_statclock = clockintr_establish(ci, clockintr_statclock); if (cq->cq_statclock == NULL) panic("%s: failed to establish statclock", __func__); } @@ -403,10 +403,11 @@ clockintr_cancel_locked(struct clockintr *cl) } struct clockintr * -clockintr_establish(struct clockintr_queue *cq, +clockintr_establish(struct cpu_info *ci, void (*func)(struct clockintr *, void *)) { struct clockintr *cl; + struct clockintr_queue *cq = &ci->ci_queue; cl = malloc(sizeof *cl, M_DEVBUF, M_NOWAIT | M_ZERO); if (cl == NULL) diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c index 0d2deb5f47e..92b0da6ffa4 100644 --- a/sys/kern/kern_sched.c +++ b/sys/kern/kern_sched.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sched.c,v 1.88 2023/08/31 19:29:51 cheloha Exp $ */ +/* $OpenBSD: kern_sched.c,v 1.89 2023/09/06 02:09:58 cheloha Exp $ */ /* * Copyright (c) 2007, 2008 Artur Grabowski * @@ -88,13 +88,13 @@ sched_init_cpu(struct cpu_info *ci) spc->spc_idleproc = NULL; - spc->spc_itimer = clockintr_establish(&ci->ci_queue, itimer_update); + spc->spc_itimer = clockintr_establish(ci, itimer_update); if (spc->spc_itimer == NULL) panic("%s: clockintr_establish itimer_update", __func__); - spc->spc_profclock = clockintr_establish(&ci->ci_queue, profclock); + spc->spc_profclock = clockintr_establish(ci, profclock); if (spc->spc_profclock == NULL) panic("%s: clockintr_establish profclock", __func__); - spc->spc_roundrobin = clockintr_establish(&ci->ci_queue, roundrobin); + spc->spc_roundrobin = clockintr_establish(ci, roundrobin); if (spc->spc_roundrobin == NULL) panic("%s: clockintr_establish roundrobin", __func__); diff --git a/sys/kern/subr_prof.c b/sys/kern/subr_prof.c index 850e0fb3b09..10a9d9e2cac 100644 --- a/sys/kern/subr_prof.c +++ b/sys/kern/subr_prof.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_prof.c,v 1.36 2023/07/25 18:16:19 cheloha Exp $ */ +/* $OpenBSD: subr_prof.c,v 1.37 2023/09/06 02:09:58 cheloha Exp $ */ /* $NetBSD: subr_prof.c,v 1.12 1996/04/22 01:38:50 christos Exp $ */ /*- @@ -101,8 +101,7 @@ prof_init(void) /* Allocate and initialize one profiling buffer per CPU. */ CPU_INFO_FOREACH(cii, ci) { - ci->ci_gmonclock = clockintr_establish(&ci->ci_queue, - gmonclock); + ci->ci_gmonclock = clockintr_establish(ci, gmonclock); if (ci->ci_gmonclock == NULL) { printf("%s: clockintr_establish gmonclock\n", __func__); return; diff --git a/sys/sys/clockintr.h b/sys/sys/clockintr.h index 71e40931d8a..b886eff2621 100644 --- a/sys/sys/clockintr.h +++ b/sys/sys/clockintr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: clockintr.h,v 1.10 2023/08/21 17:22:04 cheloha Exp $ */ +/* $OpenBSD: clockintr.h,v 1.11 2023/09/06 02:09:58 cheloha Exp $ */ /* * Copyright (c) 2020-2022 Scott Cheloha * @@ -128,7 +128,7 @@ void clockintr_trigger(void); uint64_t clockintr_advance(struct clockintr *, uint64_t); void clockintr_cancel(struct clockintr *); -struct clockintr *clockintr_establish(struct clockintr_queue *, +struct clockintr *clockintr_establish(struct cpu_info *, void (*)(struct clockintr *, void *)); void clockintr_stagger(struct clockintr *, uint64_t, u_int, u_int); void clockqueue_init(struct clockintr_queue *); -- 2.20.1