From 00ef33eaacfea5d478edc1ba519b644a985cd4c2 Mon Sep 17 00:00:00 2001 From: cheloha Date: Sun, 10 Sep 2023 01:41:16 +0000 Subject: [PATCH] clockintr_dispatch: add intermediate pointer for clockintr_queue.cq_shadow Adding an intermediate pointer lets me shortens "cq->cq_shadow" to just "shadow". I think it makes the dispatch loop logic a little easier to read. While here, add a clarifying comment. --- sys/kern/kern_clockintr.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/sys/kern/kern_clockintr.c b/sys/kern/kern_clockintr.c index d9418141053..6edc5d09018 100644 --- a/sys/kern/kern_clockintr.c +++ b/sys/kern/kern_clockintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clockintr.c,v 1.45 2023/09/09 17:07:59 cheloha Exp $ */ +/* $OpenBSD: kern_clockintr.c,v 1.46 2023/09/10 01:41:16 cheloha Exp $ */ /* * Copyright (c) 2003 Dale Rahn * Copyright (c) 2020 Mark Kettenis @@ -219,7 +219,7 @@ clockintr_dispatch(void *frame) { uint64_t lateness, run = 0, start; struct cpu_info *ci = curcpu(); - struct clockintr *cl; + struct clockintr *cl, *shadow; struct clockintr_queue *cq = &ci->ci_queue; uint32_t ogen; @@ -257,24 +257,29 @@ clockintr_dispatch(void *frame) if (cq->cq_uptime < cl->cl_expiration) break; } + + /* + * This clockintr has expired. Initialize a shadow copy + * and execute it. + */ clockqueue_pend_delete(cq, cl); - cq->cq_shadow.cl_expiration = cl->cl_expiration; - cq->cq_shadow.cl_func = cl->cl_func; + shadow = &cq->cq_shadow; + shadow->cl_expiration = cl->cl_expiration; + shadow->cl_func = cl->cl_func; cq->cq_running = cl; mtx_leave(&cq->cq_mtx); - cq->cq_shadow.cl_func(&cq->cq_shadow, frame); + shadow->cl_func(shadow, frame); mtx_enter(&cq->cq_mtx); cq->cq_running = NULL; if (ISSET(cl->cl_flags, CLST_IGNORE_SHADOW)) { CLR(cl->cl_flags, CLST_IGNORE_SHADOW); - CLR(cq->cq_shadow.cl_flags, CLST_SHADOW_PENDING); + CLR(shadow->cl_flags, CLST_SHADOW_PENDING); } - if (ISSET(cq->cq_shadow.cl_flags, CLST_SHADOW_PENDING)) { - CLR(cq->cq_shadow.cl_flags, CLST_SHADOW_PENDING); - clockqueue_pend_insert(cq, cl, - cq->cq_shadow.cl_expiration); + if (ISSET(shadow->cl_flags, CLST_SHADOW_PENDING)) { + CLR(shadow->cl_flags, CLST_SHADOW_PENDING); + clockqueue_pend_insert(cq, cl, shadow->cl_expiration); } run++; } -- 2.20.1