Index | Thread | Search

From:
Scott Cheloha <scottcheloha@gmail.com>
Subject:
kernel: disable hardclock() on secondary CPUs
To:
tech@openbsd.org
Cc:
claudio@openbsd.org, mlarkin@openbsd.org, mpi@openbsd.org
Date:
Fri, 9 Feb 2024 11:57:00 -0600

Download raw body.

Thread
Now that the dt(4) probe entry points are out of the hardclock() we
can disable it on secondary CPUs.  There is no useful work left for
them to do there.

This can wait a few days, just in case we need to back out the dt(4)
change.

Thoughts?

Index: kern_clock.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_clock.c,v
diff -u -p -r1.122 kern_clock.c
--- kern_clock.c	9 Feb 2024 17:42:18 -0000	1.122
+++ kern_clock.c	9 Feb 2024 17:51:12 -0000
@@ -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++;
Index: kern_clockintr.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_clockintr.c,v
diff -u -p -r1.66 kern_clockintr.c
--- kern_clockintr.c	9 Feb 2024 16:52:58 -0000	1.66
+++ kern_clockintr.c	9 Feb 2024 17:51:12 -0000
@@ -63,7 +63,7 @@ clockintr_cpu_init(const struct intrcloc
 		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 intrcloc
 			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);
 	}
 
 	/*