diff options
author | Scott Soule Cheloha <cheloha@cvs.openbsd.org> | 2023-08-26 22:21:01 +0000 |
---|---|---|
committer | Scott Soule Cheloha <cheloha@cvs.openbsd.org> | 2023-08-26 22:21:01 +0000 |
commit | 01532b73cd4a07a98be2fce87de02f75bf5843b6 (patch) | |
tree | 767b37ce49379628ae4d22176b8ae860ea8e1354 /sys/kern | |
parent | 6879c9c5ff5f05557f98008633d4115068525c16 (diff) |
clockintr: add clockqueue_intrclock_install()
At some point, clockintr_cpu_init() is going to go away. However,
there will still need to be a way to add an intrclock to a struct
clockintr_queue.
Add a new internal interface, clockqueue_intrclock_install(). If the
given clockintr_queue does not yet have an intrclock installed, it
copies the contents of the given intrclock to the clockintr_queue's
private intrclock (cq_intrclock) and sets CQ_INTRCLOCK in cq_flags.
I'm using the verb "install" here instead of "attach" because an
intrclock is really just a vtable that we copy into the
clockintr_queue. The original intrclock is in no way "bound" or
"affixed" to a particular clockintr_queue: it's more akin to a stamp
that can be reused to initialize any number of individual
clockintr_queue structs.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_clockintr.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/sys/kern/kern_clockintr.c b/sys/kern/kern_clockintr.c index 48fb0def3f7..1f234f15b97 100644 --- a/sys/kern/kern_clockintr.c +++ b/sys/kern/kern_clockintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clockintr.c,v 1.32 2023/08/21 17:22:04 cheloha Exp $ */ +/* $OpenBSD: kern_clockintr.c,v 1.33 2023/08/26 22:21:00 cheloha Exp $ */ /* * Copyright (c) 2003 Dale Rahn <drahn@openbsd.org> * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -49,6 +49,8 @@ uint64_t clockintr_nsecuptime(const struct clockintr *); void clockintr_schedule(struct clockintr *, uint64_t); void clockintr_schedule_locked(struct clockintr *, uint64_t); void clockintr_statclock(struct clockintr *, void *); +void clockqueue_intrclock_install(struct clockintr_queue *, + const struct intrclock *); uint64_t clockqueue_next(const struct clockintr_queue *); void clockqueue_reset_intrclock(struct clockintr_queue *); uint64_t nsec_advance(uint64_t *, uint64_t, uint64_t); @@ -106,10 +108,8 @@ clockintr_cpu_init(const struct intrclock *ic) KASSERT(ISSET(clockintr_flags, CL_INIT)); - if (ic != NULL && !ISSET(cq->cq_flags, CQ_INTRCLOCK)) { - cq->cq_intrclock = *ic; - SET(cq->cq_flags, CQ_INTRCLOCK); - } + if (ic != NULL) + clockqueue_intrclock_install(cq, ic); /* TODO: Remove these from struct clockintr_queue. */ if (cq->cq_hardclock == NULL) { @@ -533,6 +533,18 @@ clockqueue_init(struct clockintr_queue *cq) SET(cq->cq_flags, CQ_INIT); } +void +clockqueue_intrclock_install(struct clockintr_queue *cq, + const struct intrclock *ic) +{ + mtx_enter(&cq->cq_mtx); + if (!ISSET(cq->cq_flags, CQ_INTRCLOCK)) { + cq->cq_intrclock = *ic; + SET(cq->cq_flags, CQ_INTRCLOCK); + } + mtx_leave(&cq->cq_mtx); +} + uint64_t clockqueue_next(const struct clockintr_queue *cq) { |