From: cheloha Date: Sat, 9 Sep 2023 16:20:48 +0000 (+0000) Subject: clockintr_schedule: refactor reusable code into clockintr_schedule_locked() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7f1ddf074b2d51a9e36d5b661473a26f5149c139;p=openbsd clockintr_schedule: refactor reusable code into clockintr_schedule_locked() Move the code common to clockintr_advance() and clockintr_schedule() from clockintr_schedule() into a new function, clockintr_schedule_locked(). In a subsequent commit we will replace that code in clockintr_advance() with a call to clockintr_schedule_locked(). --- diff --git a/sys/kern/kern_clockintr.c b/sys/kern/kern_clockintr.c index b91c7b6a483..ffaf1567ea0 100644 --- a/sys/kern/kern_clockintr.c +++ b/sys/kern/kern_clockintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clockintr.c,v 1.41 2023/09/09 03:03:45 cheloha Exp $ */ +/* $OpenBSD: kern_clockintr.c,v 1.42 2023/09/09 16:20:48 cheloha Exp $ */ /* * Copyright (c) 2003 Dale Rahn * Copyright (c) 2020 Mark Kettenis @@ -45,6 +45,7 @@ uint32_t statclock_mask; /* [I] set of allowed offsets */ uint64_t clockintr_advance_random(struct clockintr *, uint64_t, uint32_t); void clockintr_hardclock(struct clockintr *, void *); 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 *); @@ -423,6 +424,17 @@ clockintr_schedule(struct clockintr *cl, uint64_t expiration) } mtx_enter(&cq->cq_mtx); + clockintr_schedule_locked(cl, expiration); + mtx_leave(&cq->cq_mtx); +} + +void +clockintr_schedule_locked(struct clockintr *cl, uint64_t expiration) +{ + struct clockintr_queue *cq = cl->cl_queue; + + MUTEX_ASSERT_LOCKED(&cq->cq_mtx); + if (ISSET(cl->cl_flags, CLST_PENDING)) clockqueue_pend_delete(cq, cl); clockqueue_pend_insert(cq, cl, expiration); @@ -434,7 +446,6 @@ clockintr_schedule(struct clockintr *cl, uint64_t expiration) } if (cl == cq->cq_running) SET(cl->cl_flags, CLST_IGNORE_SHADOW); - mtx_leave(&cq->cq_mtx); } void