From 99ddb99501db34324c4afe4f894a77318a02230d Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Sun, 15 May 2011 13:53:54 +0800 Subject: [PATCH] x86_64: Fix AP count after LAPIC enumeration While I'm here, add hw.ap_max to further limit the number of APs to be activated. --- sys/platform/pc64/apic/lapic.c | 15 ++++++++++++++- sys/platform/pc64/x86_64/mptable.c | 12 +----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/sys/platform/pc64/apic/lapic.c b/sys/platform/pc64/apic/lapic.c index 0c89c47a9f..d57221a0c0 100644 --- a/sys/platform/pc64/apic/lapic.c +++ b/sys/platform/pc64/apic/lapic.c @@ -705,7 +705,7 @@ int lapic_config(void) { struct lapic_enumerator *e; - int error, i, enable; + int error, i, enable, ap_max; for (i = 0; i < NAPICID; ++i) APICID_TO_CPUID(i) = -1; @@ -728,6 +728,19 @@ lapic_config(void) } e->lapic_enumerate(e); + + ap_max = MAXCPU - 1; + TUNABLE_INT_FETCH("hw.ap_max", &ap_max); + if (ap_max > MAXCPU - 1) + ap_max = MAXCPU - 1; + + if (mp_naps > ap_max) { + kprintf("LAPIC: Warning use only %d out of %d " + "available APs\n", + ap_max, mp_naps); + mp_naps = ap_max; + } + return 0; } diff --git a/sys/platform/pc64/x86_64/mptable.c b/sys/platform/pc64/x86_64/mptable.c index 407f504d70..ec1c4f0539 100644 --- a/sys/platform/pc64/x86_64/mptable.c +++ b/sys/platform/pc64/x86_64/mptable.c @@ -777,18 +777,8 @@ mptable_lapic_enumerate(struct lapic_enumerator *e) if (logical_cpus != 0) arg1.cpu_count *= logical_cpus; } - mp_naps = arg1.cpu_count; + mp_naps = arg1.cpu_count - 1; /* subtract the BSP */ - /* Qualify the numbers again, after possible HT fixup */ - if (mp_naps > MAXCPU) { - kprintf("Warning: only using %d of %d available CPUs!\n", - MAXCPU, mp_naps); - DELAY(1000000); - mp_naps = MAXCPU; - } - - --mp_naps; /* subtract the BSP */ - /* * Link logical CPU id to local apic id */ -- 2.41.0