MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mptable_hyperthread_fixup

Function mptable_hyperthread_fixup

freebsd/x86/x86/mptable.c:960–1004  ·  view source on GitHub ↗

* Perform a hyperthreading "fix-up" to enumerate any logical CPU's * that aren't already listed in the table. * * XXX: We assume that all of the physical CPUs in the * system have the same number of logical CPUs. * * XXX: We assume that APIC ID's are allocated such that * the APIC ID's for a physical processor are aligned * with the number of logical CPU's in the processor. */

Source from the content-addressed store, hash-verified

958 * with the number of logical CPU's in the processor.
959 */
960static void
961mptable_hyperthread_fixup(u_int id_mask)
962{
963 u_int i, id, logical_cpus;
964
965 /* Nothing to do if there is no HTT support. */
966 if ((cpu_feature & CPUID_HTT) == 0)
967 return;
968 logical_cpus = (cpu_procinfo & CPUID_HTT_CORES) >> 16;
969 if (logical_cpus <= 1)
970 return;
971
972 /*
973 * For each APIC ID of a CPU that is set in the mask,
974 * scan the other candidate APIC ID's for this
975 * physical processor. If any of those ID's are
976 * already in the table, then kill the fixup.
977 */
978 for (id = 0; id <= MAX_LAPIC_ID; id++) {
979 if ((id_mask & 1 << id) == 0)
980 continue;
981 /* First, make sure we are on a logical_cpus boundary. */
982 if (id % logical_cpus != 0)
983 return;
984 for (i = id + 1; i < id + logical_cpus; i++)
985 if ((id_mask & 1 << i) != 0)
986 return;
987 }
988
989 /*
990 * Ok, the ID's checked out, so perform the fixup by
991 * adding the logical CPUs.
992 */
993 while ((id = ffs(id_mask)) != 0) {
994 id--;
995 for (i = id + 1; i < id + logical_cpus; i++) {
996 if (bootverbose)
997 printf(
998 "MPTable: Adding logical CPU %d from main CPU %d\n",
999 i, id);
1000 lapic_create(i, 0);
1001 }
1002 id_mask &= ~(1 << id);
1003 }
1004}
1005#endif /* MPTABLE_FORCE_HTT */
1006
1007/*

Callers 1

mptable_setup_localFunction · 0.85

Calls 3

lapic_createFunction · 0.85
ffsFunction · 0.50
printfFunction · 0.50

Tested by

no test coverage detected