-/* $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 <drahn@openbsd.org>
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
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;
* 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();
*/
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);
/*
clockintr_advance(cq->cq_schedclock, schedclock_period);
}
- SET(cq->cq_flags, CL_CPU_INIT);
+ SET(cq->cq_flags, CQ_INIT);
}
/*
{
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);
}
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);
*/
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);
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;
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);
}
}
-/* $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 <cheloha@openbsd.org>
*
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 */
#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);