This is a slightly cleaned up version of: http://people.freebsd.org/~jhb/htt_ule.patch The only changes I made were removing unused variables to stop compiler warnings. ("regs" and "logical_cpus") Index: sys/amd64/amd64/local_apic.c =========================================================================== --- sys/amd64/amd64/local_apic.c 2007/07/29 22:40:17 #38 +++ sys/amd64/amd64/local_apic.c 2007/07/29 22:40:17 @@ -1060,10 +1060,6 @@ 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) Index: sys/amd64/amd64/mp_machdep.c =========================================================================== --- sys/amd64/amd64/mp_machdep.c 2007/07/29 22:40:17 #61 +++ sys/amd64/amd64/mp_machdep.c 2007/07/29 22:40:17 @@ -186,26 +186,14 @@ 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) - return; - logical_cpus = (cpu_procinfo & CPUID_HTT_CORES) >> 16; - if (logical_cpus <= 1) + if (hyperthreading_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 @@ * 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 @@ } set_interrupt_apic_ids(); + + /* Last, setup the cpu topology now that we have probed CPUs */ + mp_topology(); } Index: sys/i386/i386/local_apic.c =========================================================================== --- sys/i386/i386/local_apic.c 2007/07/29 22:40:17 #42 +++ sys/i386/i386/local_apic.c 2007/07/29 22:40:17 @@ -1064,10 +1064,6 @@ 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) Index: sys/i386/i386/mp_machdep.c =========================================================================== --- sys/i386/i386/mp_machdep.c 2007/07/29 22:40:17 #121 +++ sys/i386/i386/mp_machdep.c 2007/07/29 22:40:17 @@ -241,26 +241,14 @@ 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) - return; - logical_cpus = (cpu_procinfo & CPUID_HTT_CORES) >> 16; - if (logical_cpus <= 1) + if (hyperthreading_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 @@ * 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 @@ } set_interrupt_apic_ids(); + + /* Last, setup the cpu topology now that we have probed CPUs */ + mp_topology(); }