From ae6209ab7d3a89efddabb67562af7d6f2b7eb38f Mon Sep 17 00:00:00 2001 From: cheloha Date: Tue, 10 Jan 2023 01:01:18 +0000 Subject: [PATCH] i386: identifycpu(): only calibrate_cyclecounter() on primary CPU On i386 during identifycpu(), we call calibrate_cyclecounter() for every CPU in the system. This is pointless: every new call clobbers the cpuspeed measured during the prior call. It is also extremely slow: every call to calibrate_cyclecounter() takes about 1 second. Instead, let's only call calibrate_cyclecounter() once, on the primary CPU. Multiprocessor i386 machines will now boot much faster. ok deraadt@ --- sys/arch/i386/i386/machdep.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index bbf214750f1..708893b00fc 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.659 2023/01/10 00:49:45 cheloha Exp $ */ +/* $OpenBSD: machdep.c,v 1.660 2023/01/10 01:01:18 cheloha Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -1861,7 +1861,8 @@ identifycpu(struct cpu_info *ci) } break; } - calibrate_cyclecounter(); + if (CPU_IS_PRIMARY(ci)) + calibrate_cyclecounter(); /* set cpuspeed */ } if (cpuid_level != -1) -- 2.20.1