From: cheloha Date: Wed, 19 Apr 2023 14:30:35 +0000 (+0000) Subject: clockintr: rename CL_CPU_* flags to CQ_* flags X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a866e8937551d7e1cff144834931a5d2e475d536;p=openbsd clockintr: rename CL_CPU_* flags to CQ_* flags The CL_CPU_* flags were originally so-named because they were set from clockintr_cpu_init(), which was itself named before I had named the clockintr_queue struct. It makes more for the flag namespace to match the struct namespace, so CQ_* is a better flag prefix than CL_CPU_*. While we're at it, move the CQ_* flag definitions up so they immediately follow the clockintr_queue structure definition in sys/clockintr.h. --- diff --git a/sys/kern/kern_clockintr.c b/sys/kern/kern_clockintr.c index d683e65ce9e..c163df71ab0 100644 --- a/sys/kern/kern_clockintr.c +++ b/sys/kern/kern_clockintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clockintr.c,v 1.10 2023/04/16 21:19:26 cheloha Exp $ */ +/* $OpenBSD: kern_clockintr.c,v 1.11 2023/04/19 14:30:35 cheloha Exp $ */ /* * Copyright (c) 2003 Dale Rahn * Copyright (c) 2020 Mark Kettenis @@ -113,14 +113,14 @@ clockintr_cpu_init(const struct intrclock *ic) KASSERT(ISSET(clockintr_flags, CL_INIT)); - if (!ISSET(cq->cq_flags, CL_CPU_INIT)) { + if (!ISSET(cq->cq_flags, CQ_INIT)) { cq->cq_shadow.cl_queue = cq; mtx_init(&cq->cq_mtx, IPL_CLOCK); TAILQ_INIT(&cq->cq_est); TAILQ_INIT(&cq->cq_pend); if (ic != NULL) { cq->cq_intrclock = *ic; - SET(cq->cq_flags, CL_CPU_INTRCLOCK); + SET(cq->cq_flags, CQ_INTRCLOCK); } cq->cq_gen = 1; @@ -148,7 +148,7 @@ clockintr_cpu_init(const struct intrclock *ic) * anyway. The primary CPU's starting offset is always zero, so * leave the multiplier zero. */ - if (!CPU_IS_PRIMARY(ci) && ISSET(cq->cq_flags, CL_CPU_INTRCLOCK)) + if (!CPU_IS_PRIMARY(ci) && ISSET(cq->cq_flags, CQ_INTRCLOCK)) multiplier = CPU_INFO_UNIT(ci); cq->cq_uptime = nsecuptime(); @@ -161,7 +161,7 @@ clockintr_cpu_init(const struct intrclock *ic) */ offset = hardclock_period / ncpus * multiplier; clockintr_schedule(cq->cq_hardclock, offset); - if (!CPU_IS_PRIMARY(ci) || ISSET(cq->cq_flags, CL_CPU_INIT)) + if (!CPU_IS_PRIMARY(ci) || ISSET(cq->cq_flags, CQ_INIT)) clockintr_advance(cq->cq_hardclock, hardclock_period); /* @@ -176,7 +176,7 @@ clockintr_cpu_init(const struct intrclock *ic) clockintr_advance(cq->cq_schedclock, schedclock_period); } - SET(cq->cq_flags, CL_CPU_INIT); + SET(cq->cq_flags, CQ_INIT); } /* @@ -187,9 +187,9 @@ clockintr_trigger(void) { struct clockintr_queue *cq = &curcpu()->ci_queue; - KASSERT(ISSET(cq->cq_flags, CL_CPU_INIT)); + KASSERT(ISSET(cq->cq_flags, CQ_INIT)); - if (ISSET(cq->cq_flags, CL_CPU_INTRCLOCK)) + if (ISSET(cq->cq_flags, CQ_INTRCLOCK)) intrclock_trigger(&cq->cq_intrclock); } @@ -210,7 +210,7 @@ clockintr_dispatch(void *frame) cq->cq_dispatch = 1; splassert(IPL_CLOCK); - KASSERT(ISSET(cq->cq_flags, CL_CPU_INIT)); + KASSERT(ISSET(cq->cq_flags, CQ_INIT)); mtx_enter(&cq->cq_mtx); @@ -265,7 +265,7 @@ clockintr_dispatch(void *frame) */ rearm: /* Rearm the interrupt clock if we have one. */ - if (ISSET(cq->cq_flags, CL_CPU_INTRCLOCK)) { + if (ISSET(cq->cq_flags, CQ_INTRCLOCK)) { if (!TAILQ_EMPTY(&cq->cq_pend)) { intrclock_rearm(&cq->cq_intrclock, clockqueue_next(cq) - cq->cq_uptime); @@ -602,7 +602,7 @@ sysctl_clockintr(int *name, u_int namelen, void *oldp, size_t *oldlenp, memset(&sum, 0, sizeof sum); CPU_INFO_FOREACH(cii, ci) { cq = &ci->ci_queue; - if (!ISSET(cq->cq_flags, CL_CPU_INIT)) + if (!ISSET(cq->cq_flags, CQ_INIT)) continue; do { gen = cq->cq_gen; @@ -650,7 +650,7 @@ db_show_all_clockintr(db_expr_t addr, int haddr, db_expr_t count, char *modif) db_printf("\n"); db_printf("%20s %5s %3s %s\n", "EXPIRATION", "STATE", "CPU", "NAME"); CPU_INFO_FOREACH(cii, ci) { - if (ISSET(ci->ci_queue.cq_flags, CL_CPU_INIT)) + if (ISSET(ci->ci_queue.cq_flags, CQ_INIT)) db_show_clockintr_cpu(ci); } } diff --git a/sys/sys/clockintr.h b/sys/sys/clockintr.h index d3c431c07b5..536bccf18c6 100644 --- a/sys/sys/clockintr.h +++ b/sys/sys/clockintr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: clockintr.h,v 1.5 2023/04/16 21:19:26 cheloha Exp $ */ +/* $OpenBSD: clockintr.h,v 1.6 2023/04/19 14:30:35 cheloha Exp $ */ /* * Copyright (c) 2020-2022 Scott Cheloha * @@ -103,9 +103,13 @@ struct clockintr_queue { struct clockintr_stat cq_stat; /* [o] dispatch statistics */ volatile u_int cq_gen; /* [o] cq_stat update generation */ volatile u_int cq_dispatch; /* [o] dispatch is running */ - u_int cq_flags; /* [I] local state flags */ + u_int cq_flags; /* [I] CQ_* flags; see below */ }; +#define CQ_INIT 0x00000001 /* clockintr_cpu_init() done */ +#define CQ_INTRCLOCK 0x00000002 /* intrclock installed */ +#define CQ_STATE_MASK 0x00000003 + /* Global state flags. */ #define CL_INIT 0x00000001 /* global init done */ #define CL_STATCLOCK 0x00000002 /* statclock variables set */ @@ -116,11 +120,6 @@ struct clockintr_queue { #define CL_RNDSTAT 0x80000000 /* randomized statclock */ #define CL_FLAG_MASK 0x80000000 -/* Per-CPU state flags. */ -#define CL_CPU_INIT 0x00000001 /* CPU is ready for dispatch */ -#define CL_CPU_INTRCLOCK 0x00000002 /* CPU has intrclock */ -#define CL_CPU_STATE_MASK 0x00000003 - void clockintr_cpu_init(const struct intrclock *); int clockintr_dispatch(void *); void clockintr_init(u_int);