Skip to content

Commit f485702

Browse files
committed
x86: fix cache ids on Intel
Use the official way to compute the cache id on Intel (same one as in the Linux kernel) by rounding-up nbthreads_sharing and masking lower bits of the APIC ids (instead of dividing the APIC id by nbthreads_sharing). This should not affect any existing platform topology, but it's more future-proof. Thanks to Jonathan Peyton for the help. Signed-off-by: Brice Goglin <[email protected]>
1 parent fe18673 commit f485702

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

hwloc/topology-x86.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2010-2019 Inria. All rights reserved.
2+
* Copyright © 2010-2020 Inria. All rights reserved.
33
* Copyright © 2010-2013 Université Bordeaux
44
* Copyright © 2010-2011 Cisco Systems, Inc. All rights reserved.
55
* See COPYING in top-level directory.
@@ -751,7 +751,13 @@ static void look_proc(struct hwloc_backend *backend, struct procinfo *infos, uns
751751
/* default cacheid value */
752752
cache->cacheid = infos->apicid / cache->nbthreads_sharing;
753753

754-
if (cpuid_type == amd) {
754+
if (cpuid_type == intel) {
755+
/* round nbthreads_sharing to nearest power of two to build a mask (for clearing lower bits) */
756+
unsigned bits = hwloc_flsl(cache->nbthreads_sharing-1)+1;
757+
unsigned mask = ~((1U<<(bits-1)) - 1);
758+
cache->cacheid = infos->apicid & mask;
759+
760+
} else if (cpuid_type == amd) {
755761
/* AMD quirks */
756762
if (infos->cpufamilynumber == 0x17
757763
&& cache->level == 3 && cache->nbthreads_sharing == 6) {

0 commit comments

Comments
 (0)