From: cheloha Date: Thu, 14 Sep 2023 22:07:11 +0000 (+0000) Subject: clockintr, scheduler: move statclock handle from clockintr_queue to schedstate_percpu X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a332869ab2345858bff8ccd1725674b106eafb6f;p=openbsd clockintr, scheduler: move statclock handle from clockintr_queue to schedstate_percpu Move the statclock handle from clockintr_queue.cq_statclock to schedstate_percpu.spc_statclock. Establish spc_statclock during sched_init_cpu() alongside the other scheduler clock interrupts. Thread: https://marc.info/?l=openbsd-tech&m=169428749720476&w=2 --- diff --git a/sys/kern/kern_clockintr.c b/sys/kern/kern_clockintr.c index 62bb81a6ba0..e5eaac3cca0 100644 --- a/sys/kern/kern_clockintr.c +++ b/sys/kern/kern_clockintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clockintr.c,v 1.50 2023/09/14 20:58:51 cheloha Exp $ */ +/* $OpenBSD: kern_clockintr.c,v 1.51 2023/09/14 22:07:11 cheloha Exp $ */ /* * Copyright (c) 2003 Dale Rahn * Copyright (c) 2020 Mark Kettenis @@ -87,18 +87,13 @@ clockintr_cpu_init(const struct intrclock *ic) if (ic != NULL) clockqueue_intrclock_install(cq, ic); - /* TODO: Remove these from struct clockintr_queue. */ + /* TODO: Remove this from struct clockintr_queue. */ if (cq->cq_hardclock == NULL) { cq->cq_hardclock = clockintr_establish(ci, clockintr_hardclock, NULL); if (cq->cq_hardclock == NULL) panic("%s: failed to establish hardclock", __func__); } - if (cq->cq_statclock == NULL) { - cq->cq_statclock = clockintr_establish(ci, statclock, NULL); - if (cq->cq_statclock == NULL) - panic("%s: failed to establish statclock", __func__); - } /* * Mask CQ_INTRCLOCK while we're advancing the internal clock @@ -144,12 +139,12 @@ clockintr_cpu_init(const struct intrclock *ic) * stagger a randomized statclock. */ if (!statclock_is_randomized) { - if (cq->cq_statclock->cl_expiration == 0) { - clockintr_stagger(cq->cq_statclock, statclock_avg, + if (spc->spc_statclock->cl_expiration == 0) { + clockintr_stagger(spc->spc_statclock, statclock_avg, multiplier, MAXCPUS); } } - clockintr_advance(cq->cq_statclock, statclock_avg); + clockintr_advance(spc->spc_statclock, statclock_avg); /* * XXX Need to find a better place to do this. We can't do it in diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c index ea1b874a5c5..8d043f5dc68 100644 --- a/sys/kern/kern_sched.c +++ b/sys/kern/kern_sched.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sched.c,v 1.90 2023/09/10 03:08:05 cheloha Exp $ */ +/* $OpenBSD: kern_sched.c,v 1.91 2023/09/14 22:07:11 cheloha Exp $ */ /* * Copyright (c) 2007, 2008 Artur Grabowski * @@ -97,6 +97,9 @@ sched_init_cpu(struct cpu_info *ci) spc->spc_roundrobin = clockintr_establish(ci, roundrobin, NULL); if (spc->spc_roundrobin == NULL) panic("%s: clockintr_establish roundrobin", __func__); + spc->spc_statclock = clockintr_establish(ci, statclock, NULL); + if (spc->spc_statclock == NULL) + panic("%s: clockintr_establish statclock", __func__); kthread_create_deferred(sched_kthreads_create, ci); diff --git a/sys/sys/clockintr.h b/sys/sys/clockintr.h index 223e028471b..34eb2d22089 100644 --- a/sys/sys/clockintr.h +++ b/sys/sys/clockintr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: clockintr.h,v 1.15 2023/09/14 19:51:18 cheloha Exp $ */ +/* $OpenBSD: clockintr.h,v 1.16 2023/09/14 22:07:11 cheloha Exp $ */ /* * Copyright (c) 2020-2022 Scott Cheloha * @@ -98,7 +98,6 @@ struct clockintr_queue { TAILQ_HEAD(, clockintr) cq_pend;/* [m] pending clockintr list */ struct clockintr *cq_running; /* [m] running clockintr */ struct clockintr *cq_hardclock; /* [o] hardclock handle */ - struct clockintr *cq_statclock; /* [o] statclock handle */ struct intrclock cq_intrclock; /* [I] local interrupt clock */ struct clockintr_stat cq_stat; /* [o] dispatch statistics */ volatile uint32_t cq_gen; /* [o] cq_stat update generation */ diff --git a/sys/sys/sched.h b/sys/sys/sched.h index cc2b4dc6e2e..a54a8f77e1d 100644 --- a/sys/sys/sched.h +++ b/sys/sys/sched.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sched.h,v 1.63 2023/09/10 03:08:05 cheloha Exp $ */ +/* $OpenBSD: sched.h,v 1.64 2023/09/14 22:07:11 cheloha Exp $ */ /* $NetBSD: sched.h,v 1.2 1999/02/28 18:14:58 ross Exp $ */ /*- @@ -109,6 +109,7 @@ struct schedstate_percpu { struct clockintr *spc_itimer; /* [o] itimer_update handle */ struct clockintr *spc_profclock; /* [o] profclock handle */ struct clockintr *spc_roundrobin; /* [o] roundrobin handle */ + struct clockintr *spc_statclock; /* [o] statclock handle */ u_int spc_nrun; /* procs on the run queues */