Changeset View
Changeset View
Standalone View
Standalone View
head/sys/x86/x86/mp_x86.c
Show First 20 Lines • Show All 601 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Assign logical CPU IDs to local APICs. | * Assign logical CPU IDs to local APICs. | ||||
*/ | */ | ||||
void | void | ||||
assign_cpu_ids(void) | assign_cpu_ids(void) | ||||
{ | { | ||||
struct topo_node *node; | struct topo_node *node; | ||||
u_int smt_mask; | u_int smt_mask; | ||||
int nhyper; | |||||
smt_mask = (1u << core_id_shift) - 1; | smt_mask = (1u << core_id_shift) - 1; | ||||
/* | /* | ||||
* Assign CPU IDs to local APIC IDs and disable any CPUs | * Assign CPU IDs to local APIC IDs and disable any CPUs | ||||
* beyond MAXCPU. CPU 0 is always assigned to the BSP. | * beyond MAXCPU. CPU 0 is always assigned to the BSP. | ||||
*/ | */ | ||||
mp_ncpus = 0; | mp_ncpus = 0; | ||||
nhyper = 0; | |||||
TOPO_FOREACH(node, &topo_root) { | TOPO_FOREACH(node, &topo_root) { | ||||
if (node->type != TOPO_TYPE_PU) | if (node->type != TOPO_TYPE_PU) | ||||
continue; | continue; | ||||
if ((node->hwid & smt_mask) != (boot_cpu_id & smt_mask)) | if ((node->hwid & smt_mask) != (boot_cpu_id & smt_mask)) | ||||
cpu_info[node->hwid].cpu_hyperthread = 1; | cpu_info[node->hwid].cpu_hyperthread = 1; | ||||
if (resource_disabled("lapic", node->hwid)) { | if (resource_disabled("lapic", node->hwid)) { | ||||
Show All 11 Lines | TOPO_FOREACH(node, &topo_root) { | ||||
if (mp_ncpus >= MAXCPU) | if (mp_ncpus >= MAXCPU) | ||||
cpu_info[node->hwid].cpu_disabled = 1; | cpu_info[node->hwid].cpu_disabled = 1; | ||||
if (cpu_info[node->hwid].cpu_disabled) { | if (cpu_info[node->hwid].cpu_disabled) { | ||||
disabled_cpus++; | disabled_cpus++; | ||||
continue; | continue; | ||||
} | } | ||||
if (cpu_info[node->hwid].cpu_hyperthread) | |||||
nhyper++; | |||||
cpu_apic_ids[mp_ncpus] = node->hwid; | cpu_apic_ids[mp_ncpus] = node->hwid; | ||||
apic_cpuids[node->hwid] = mp_ncpus; | apic_cpuids[node->hwid] = mp_ncpus; | ||||
topo_set_pu_id(node, mp_ncpus); | topo_set_pu_id(node, mp_ncpus); | ||||
mp_ncpus++; | mp_ncpus++; | ||||
} | } | ||||
KASSERT(mp_maxid >= mp_ncpus - 1, | KASSERT(mp_maxid >= mp_ncpus - 1, | ||||
("%s: counters out of sync: max %d, count %d", __func__, mp_maxid, | ("%s: counters out of sync: max %d, count %d", __func__, mp_maxid, | ||||
mp_ncpus)); | mp_ncpus)); | ||||
mp_ncores = mp_ncpus - nhyper; | |||||
smp_threads_per_core = mp_ncpus / mp_ncores; | |||||
} | } | ||||
/* | /* | ||||
* Print various information about the SMP system hardware and setup. | * Print various information about the SMP system hardware and setup. | ||||
*/ | */ | ||||
void | void | ||||
cpu_mp_announce(void) | cpu_mp_announce(void) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 1,120 Lines • Show Last 20 Lines |