Move mp_topology() from apic_init(i386) and apic_setup_local(amd64) to
cpu_start_mp(). This is after we have read the cpuid registers to calculate the hyperthreading_cpus value for the sysctl that enables or disables hyperthread cores. Change mp_topology() to use that information rather than trying to do it itself. This solves the problem of ULE being incorrectly told that dual core Athlon64 X2 or Operton cpus are hyperthreading cores. At the very least, we now have a single piece of code to identify hyperthreading. Obtained from: jhb Approved by: re (kensmith)
This commit is contained in:
parent
75449c3877
commit
c3c2fa9c59
@ -1060,10 +1060,6 @@ apic_setup_local(void *dummy __unused)
|
||||
if (retval != 0)
|
||||
printf("%s: Failed to setup the local APIC: returned %d\n",
|
||||
best_enum->apic_name, retval);
|
||||
#ifdef SMP
|
||||
/* Last, setup the cpu topology now that we have probed CPUs */
|
||||
mp_topology();
|
||||
#endif
|
||||
}
|
||||
SYSINIT(apic_setup_local, SI_SUB_CPU, SI_ORDER_FIRST, apic_setup_local, NULL)
|
||||
|
||||
|
@ -186,26 +186,14 @@ void
|
||||
mp_topology(void)
|
||||
{
|
||||
struct cpu_group *group;
|
||||
u_int regs[4];
|
||||
int logical_cpus;
|
||||
int apic_id;
|
||||
int groups;
|
||||
int cpu;
|
||||
|
||||
/* Build the smp_topology map. */
|
||||
/* Nothing to do if there is no HTT support. */
|
||||
if ((cpu_feature & CPUID_HTT) == 0)
|
||||
if (hyperthreading_cpus <= 1)
|
||||
return;
|
||||
logical_cpus = (cpu_procinfo & CPUID_HTT_CORES) >> 16;
|
||||
if (logical_cpus <= 1)
|
||||
return;
|
||||
/* Nothing to do if reported cores are physical cores. */
|
||||
if (strcmp(cpu_vendor, "GenuineIntel") == 0 && cpu_high >= 4) {
|
||||
cpuid_count(4, 0, regs);
|
||||
if ((regs[0] & 0x1f) != 0 &&
|
||||
logical_cpus <= ((regs[0] >> 26) & 0x3f) + 1)
|
||||
return;
|
||||
}
|
||||
group = &mp_groups[0];
|
||||
groups = 1;
|
||||
for (cpu = 0, apic_id = 0; apic_id <= MAX_APIC_ID; apic_id++) {
|
||||
@ -215,7 +203,8 @@ mp_topology(void)
|
||||
* If the current group has members and we're not a logical
|
||||
* cpu, create a new group.
|
||||
*/
|
||||
if (group->cg_count != 0 && (apic_id % logical_cpus) == 0) {
|
||||
if (group->cg_count != 0 &&
|
||||
(apic_id % hyperthreading_cpus) == 0) {
|
||||
group++;
|
||||
groups++;
|
||||
}
|
||||
@ -420,6 +409,9 @@ cpu_mp_start(void)
|
||||
}
|
||||
|
||||
set_interrupt_apic_ids();
|
||||
|
||||
/* Last, setup the cpu topology now that we have probed CPUs */
|
||||
mp_topology();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1064,10 +1064,6 @@ apic_init(void *dummy __unused)
|
||||
if (retval != 0)
|
||||
printf("%s: Failed to setup the local APIC: returned %d\n",
|
||||
best_enum->apic_name, retval);
|
||||
#ifdef SMP
|
||||
/* Last, setup the cpu topology now that we have probed CPUs */
|
||||
mp_topology();
|
||||
#endif
|
||||
}
|
||||
SYSINIT(apic_init, SI_SUB_CPU, SI_ORDER_FIRST, apic_init, NULL)
|
||||
|
||||
|
@ -241,26 +241,14 @@ void
|
||||
mp_topology(void)
|
||||
{
|
||||
struct cpu_group *group;
|
||||
u_int regs[4];
|
||||
int logical_cpus;
|
||||
int apic_id;
|
||||
int groups;
|
||||
int cpu;
|
||||
|
||||
/* Build the smp_topology map. */
|
||||
/* Nothing to do if there is no HTT support. */
|
||||
if ((cpu_feature & CPUID_HTT) == 0)
|
||||
if (hyperthreading_cpus <= 1)
|
||||
return;
|
||||
logical_cpus = (cpu_procinfo & CPUID_HTT_CORES) >> 16;
|
||||
if (logical_cpus <= 1)
|
||||
return;
|
||||
/* Nothing to do if reported cores are physical cores. */
|
||||
if (strcmp(cpu_vendor, "GenuineIntel") == 0 && cpu_high >= 4) {
|
||||
cpuid_count(4, 0, regs);
|
||||
if ((regs[0] & 0x1f) != 0 &&
|
||||
logical_cpus <= ((regs[0] >> 26) & 0x3f) + 1)
|
||||
return;
|
||||
}
|
||||
group = &mp_groups[0];
|
||||
groups = 1;
|
||||
for (cpu = 0, apic_id = 0; apic_id <= MAX_APIC_ID; apic_id++) {
|
||||
@ -270,7 +258,8 @@ mp_topology(void)
|
||||
* If the current group has members and we're not a logical
|
||||
* cpu, create a new group.
|
||||
*/
|
||||
if (group->cg_count != 0 && (apic_id % logical_cpus) == 0) {
|
||||
if (group->cg_count != 0 &&
|
||||
(apic_id % hyperthreading_cpus) == 0) {
|
||||
group++;
|
||||
groups++;
|
||||
}
|
||||
@ -469,6 +458,9 @@ cpu_mp_start(void)
|
||||
}
|
||||
|
||||
set_interrupt_apic_ids();
|
||||
|
||||
/* Last, setup the cpu topology now that we have probed CPUs */
|
||||
mp_topology();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user