diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index 8bc47e58c685..ffda0465c971 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -292,6 +292,10 @@ topo_probe_0x4(void) static void topo_probe(void) { + static int cpu_topo_probed = 0; + + if (cpu_topo_probed) + return; logical_cpus = logical_cpus_mask = 0; if (cpu_high >= 0xb) @@ -299,9 +303,10 @@ topo_probe(void) else if (cpu_high) topo_probe_0x4(); if (cpu_cores == 0) - cpu_cores = mp_ncpus; + cpu_cores = mp_ncpus > 0 ? mp_ncpus : 1; if (cpu_logical == 0) cpu_logical = 1; + cpu_topo_probed = 1; } struct cpu_group * @@ -313,6 +318,7 @@ cpu_topo(void) * Determine whether any threading flags are * necessry. */ + topo_probe(); if (cpu_logical > 1 && hyperthreading_cpus) cg_flags = CG_FLAG_HTT; else if (cpu_logical > 1) diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index ab15ffb3d614..ceb5a7753b87 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -345,6 +345,10 @@ topo_probe_0x4(void) static void topo_probe(void) { + static int cpu_topo_probed = 0; + + if (cpu_topo_probed) + return; logical_cpus = logical_cpus_mask = 0; if (cpu_high >= 0xb) @@ -352,9 +356,10 @@ topo_probe(void) else if (cpu_high) topo_probe_0x4(); if (cpu_cores == 0) - cpu_cores = mp_ncpus; + cpu_cores = mp_ncpus > 0 ? mp_ncpus : 1; if (cpu_logical == 0) cpu_logical = 1; + cpu_topo_probed = 1; } struct cpu_group * @@ -366,6 +371,7 @@ cpu_topo(void) * Determine whether any threading flags are * necessry. */ + topo_probe(); if (cpu_logical > 1 && hyperthreading_cpus) cg_flags = CG_FLAG_HTT; else if (cpu_logical > 1)