From: cheloha Date: Sat, 9 Sep 2023 17:07:59 +0000 (+0000) Subject: clockintr_advance: tweak logic to eliminate early-return X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=4c22523632d7150cbb4e9b2b45274c0d19f182a7;p=openbsd clockintr_advance: tweak logic to eliminate early-return With the switch to clockintr_schedule_locked(), clockintr_advance() is now much shorter and the early-return from the non-mutex path doesn't make the function any easier to read. Move the mutex path into the else branch and always return 'count' at the end of the function. --- diff --git a/sys/kern/kern_clockintr.c b/sys/kern/kern_clockintr.c index e6d65659c16..d9418141053 100644 --- a/sys/kern/kern_clockintr.c +++ b/sys/kern/kern_clockintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clockintr.c,v 1.44 2023/09/09 16:59:01 cheloha Exp $ */ +/* $OpenBSD: kern_clockintr.c,v 1.45 2023/09/09 17:07:59 cheloha Exp $ */ /* * Copyright (c) 2003 Dale Rahn * Copyright (c) 2020 Mark Kettenis @@ -326,14 +326,13 @@ clockintr_advance(struct clockintr *cl, uint64_t period) if (cl == &cq->cq_shadow) { count = nsec_advance(&cl->cl_expiration, period, cq->cq_uptime); SET(cl->cl_flags, CLST_SHADOW_PENDING); - return count; + } else { + mtx_enter(&cq->cq_mtx); + expiration = cl->cl_expiration; + count = nsec_advance(&expiration, period, nsecuptime()); + clockintr_schedule_locked(cl, expiration); + mtx_leave(&cq->cq_mtx); } - - mtx_enter(&cq->cq_mtx); - expiration = cl->cl_expiration; - count = nsec_advance(&expiration, period, nsecuptime()); - clockintr_schedule_locked(cl, expiration); - mtx_leave(&cq->cq_mtx); return count; }