From: cheloha Date: Mon, 12 Feb 2024 22:07:33 +0000 (+0000) Subject: kernel: disable hardclock() on secondary CPUs X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8434116fd2c22fec81b518e015e6bea3382f0e33;p=openbsd kernel: disable hardclock() on secondary CPUs There is no useful work left for secondary CPUs to do in hardclock(). Disable cq_hardclock on secondary CPUs and remove the now-unnecessary early-return from hardclock(). This change reduces every system's normal clock interrupt rate by (HZ - HZ/10) per secondary CPU. For example, an 8-core machine with a HZ=100 kernel should see its clock interrupt rate drop from ~1600 to ~960. Thread: https://marc.info/?l=openbsd-tech&m=170750140915898&w=2 ok kettenis@ --- diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index f6f98b7344d..f851089aaf2 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clock.c,v 1.122 2024/02/09 17:42:18 cheloha Exp $ */ +/* $OpenBSD: kern_clock.c,v 1.123 2024/02/12 22:07:33 cheloha Exp $ */ /* $NetBSD: kern_clock.c,v 1.34 1996/06/09 04:51:03 briggs Exp $ */ /*- @@ -140,13 +140,6 @@ initclocks(void) void hardclock(struct clockframe *frame) { - /* - * If we are not the primary CPU, we're not allowed to do - * any more work. - */ - if (CPU_IS_PRIMARY(curcpu()) == 0) - return; - tc_ticktock(); ticks++; jiffies++; diff --git a/sys/kern/kern_clockintr.c b/sys/kern/kern_clockintr.c index 4141a2bbeba..1a36e497531 100644 --- a/sys/kern/kern_clockintr.c +++ b/sys/kern/kern_clockintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clockintr.c,v 1.66 2024/02/09 16:52:58 cheloha Exp $ */ +/* $OpenBSD: kern_clockintr.c,v 1.67 2024/02/12 22:07:33 cheloha Exp $ */ /* * Copyright (c) 2003 Dale Rahn * Copyright (c) 2020 Mark Kettenis @@ -63,7 +63,7 @@ clockintr_cpu_init(const struct intrclock *ic) clockqueue_intrclock_install(cq, ic); /* TODO: Remove this from struct clockintr_queue. */ - if (cq->cq_hardclock.cl_expiration == 0) { + if (CPU_IS_PRIMARY(ci) && cq->cq_hardclock.cl_expiration == 0) { clockintr_bind(&cq->cq_hardclock, ci, clockintr_hardclock, NULL); } @@ -99,12 +99,6 @@ clockintr_cpu_init(const struct intrclock *ic) clockintr_schedule(&cq->cq_hardclock, 0); else clockintr_advance(&cq->cq_hardclock, hardclock_period); - } else { - if (cq->cq_hardclock.cl_expiration == 0) { - clockintr_stagger(&cq->cq_hardclock, hardclock_period, - multiplier, MAXCPUS); - } - clockintr_advance(&cq->cq_hardclock, hardclock_period); } /*