-/* $OpenBSD: kern_clockintr.c,v 1.11 2023/04/19 14:30:35 cheloha Exp $ */
+/* $OpenBSD: kern_clockintr.c,v 1.12 2023/04/20 00:24:11 cheloha Exp $ */
/*
* Copyright (c) 2003 Dale Rahn <drahn@openbsd.org>
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
uint64_t multiplier = 0, offset;
struct cpu_info *ci = curcpu();
struct clockintr_queue *cq = &ci->ci_queue;
+ int reset_cq_intrclock = 0;
KASSERT(ISSET(clockintr_flags, CL_INIT));
}
}
+ /*
+ * Mask CQ_INTRCLOCK while we're advancing the internal clock
+ * interrupts. We don't want the intrclock to fire until this
+ * thread reaches clockintr_trigger().
+ */
+ if (ISSET(cq->cq_flags, CQ_INTRCLOCK)) {
+ CLR(cq->cq_flags, CQ_INTRCLOCK);
+ reset_cq_intrclock = 1;
+ }
+
/*
* Until we understand scheduler lock contention better, stagger
* the hardclock and statclock so they don't all happen at once.
clockintr_advance(cq->cq_schedclock, schedclock_period);
}
+ if (reset_cq_intrclock)
+ SET(cq->cq_flags, CQ_INTRCLOCK);
+
SET(cq->cq_flags, CQ_INIT);
}