Skip to content

Commit

Permalink
x86: fix the management of other x2apic levels
Browse files Browse the repository at this point in the history
We need to keep sub-ids package-wide instead of parent-level-wide.
Instead of having foo[0-1] inside each bar[0-1], keep foo[0-3]
so that we can distinguish foos without having to compare their
bar id (which would make the code much more complex).

All x2apic levels are inside packages, so just keep the part of
the APIC ID up to the package shift, instead of up to the
parent shift.

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed Nov 16, 2018
1 parent 619eef3 commit 77d6f16
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion hwloc/topology-x86.c
Expand Up @@ -582,12 +582,14 @@ static void look_proc(struct hwloc_backend *backend, struct procinfo *infos, uns
if ((cpuid_type == intel || cpuid_type == zhaoxin) && highest_cpuid >= 0x0b && has_x2apic(features)) {
unsigned level, apic_nextshift, apic_number, apic_type, apic_id = 0, apic_shift = 0, id;
unsigned threadid __hwloc_attribute_unused = 0; /* shut-up compiler */
int apic_packageshift = 0;
for (level = 0; ; level++) {
ecx = level;
eax = 0x0b;
cpuid_or_from_dump(&eax, &ebx, &ecx, &edx, src_cpuiddump);
if (!eax && !ebx)
break;
apic_packageshift = eax & 0x1f;
}
if (level) {
infos->otherids = malloc(level * sizeof(*infos->otherids));
Expand All @@ -603,7 +605,7 @@ static void look_proc(struct hwloc_backend *backend, struct procinfo *infos, uns
apic_number = ebx & 0xffff;
apic_type = (ecx & 0xff00) >> 8;
apic_id = edx;
id = (apic_id >> apic_shift) & ((1 << (apic_nextshift - apic_shift)) - 1);
id = (apic_id >> apic_shift) & ((1 << (apic_packageshift - apic_shift)) - 1);
hwloc_debug("x2APIC %08x %u: nextshift %u num %2u type %u id %2u\n", apic_id, level, apic_nextshift, apic_number, apic_type, id);
infos->apicid = apic_id;
infos->otherids[level] = UINT_MAX;
Expand Down

0 comments on commit 77d6f16

Please sign in to comment.