From 89af9044153fe1e4eb7e6e4f686f8640b95c8ec5 Mon Sep 17 00:00:00 2001 From: cheloha Date: Sun, 23 Apr 2023 00:01:40 +0000 Subject: [PATCH] clockintr_advance: don't use cached uptime when called outside of dispatch When clockintr_advance() is eventually used by outside callers, there will be no way to know how fresh cq_uptime is. If we're not running in the dispatch loop, we need to call nsecuptime(9) to get a high-res uptime before advancing a clockintr. --- sys/kern/kern_clockintr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_clockintr.c b/sys/kern/kern_clockintr.c index 7908d270151..df824f1c4ce 100644 --- a/sys/kern/kern_clockintr.c +++ b/sys/kern/kern_clockintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clockintr.c,v 1.19 2023/04/22 23:51:27 cheloha Exp $ */ +/* $OpenBSD: kern_clockintr.c,v 1.20 2023/04/23 00:01:40 cheloha Exp $ */ /* * Copyright (c) 2003 Dale Rahn * Copyright (c) 2020 Mark Kettenis @@ -328,7 +328,7 @@ clockintr_advance(struct clockintr *cl, uint64_t period) mtx_enter(&cq->cq_mtx); expiration = cl->cl_expiration; - count = nsec_advance(&expiration, period, cq->cq_uptime); + count = nsec_advance(&expiration, period, nsecuptime()); if (ISSET(cl->cl_flags, CLST_PENDING)) clockintr_cancel_locked(cl); clockintr_schedule_locked(cl, expiration); -- 2.20.1