Page MenuHomeFreeBSD

D57140.diff
No OneTemporary

D57140.diff

diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c
--- a/sys/x86/x86/mp_x86.c
+++ b/sys/x86/x86/mp_x86.c
@@ -681,15 +681,17 @@
{
struct topo_node *node;
u_int smt_mask;
+ int ncpus;
int nhyper;
smt_mask = (1u << core_id_shift) - 1;
/*
* Assign CPU IDs to local APIC IDs and disable any CPUs
- * beyond MAXCPU. CPU 0 is always assigned to the BSP.
+ * beyond MAXCPU or the already-set mp_ncpus. CPU 0 is
+ * always assigned to the BSP.
*/
- mp_ncpus = 0;
+ ncpus = 0;
nhyper = 0;
TOPO_FOREACH(node, &topo_root) {
if (node->type != TOPO_TYPE_PU)
@@ -710,7 +712,7 @@
cpu_info[node->hwid].cpu_hyperthread)
cpu_info[node->hwid].cpu_disabled = 1;
- if (mp_ncpus >= MAXCPU)
+ if (ncpus >= mp_ncpus || ncpus >= MAXCPU)
cpu_info[node->hwid].cpu_disabled = 1;
if (cpu_info[node->hwid].cpu_disabled) {
@@ -721,10 +723,10 @@
if (cpu_info[node->hwid].cpu_hyperthread)
nhyper++;
- cpu_apic_ids[mp_ncpus] = node->hwid;
- apic_cpuids[node->hwid] = mp_ncpus;
- topo_set_pu_id(node, mp_ncpus);
- mp_ncpus++;
+ cpu_apic_ids[ncpus] = node->hwid;
+ apic_cpuids[node->hwid] = ncpus;
+ topo_set_pu_id(node, ncpus);
+ ncpus++;
}
KASSERT(mp_maxid >= mp_ncpus - 1,
@@ -1014,6 +1016,7 @@
void
cpu_mp_setmaxid(void)
{
+ int ncpu;
/*
* mp_ncpus and mp_maxid should be already set by calls to cpu_add().
@@ -1021,6 +1024,13 @@
*/
if (mp_ncpus == 0)
mp_ncpus = 1;
+
+ if (TUNABLE_INT_FETCH("hw.ncpu", &ncpu)) {
+ if (1 <= ncpu && ncpu <= mp_ncpus) {
+ mp_ncpus = ncpu;
+ mp_maxid = ncpu - 1;
+ }
+ }
}
int

File Metadata

Mime Type
text/plain
Expires
Thu, Jun 18, 8:36 PM (13 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33403653
Default Alt Text
D57140.diff (1 KB)

Event Timeline