summaryrefslogtreecommitdiff
path: root/arch/x86/kernel/cpu/topology_common.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2024-02-13 22:06:10 +0100
committerThomas Gleixner <tglx@linutronix.de>2024-02-15 22:07:45 +0100
commit3205c9833d69b97e8694efe3e193312dea4c571f (patch)
tree8d15d470f15dcf272831365b1844c0ad522b8daf /arch/x86/kernel/cpu/topology_common.c
parent380414be78bf8dbe1c3ed98feb75e2579c4a1bae (diff)
x86/cpu/topology: Retrieve cores per package from topology bitmaps
Similar to other sizing information the number of cores per package can be established from the topology bitmap. Provide a function for retrieving that information and replace the buggy hack in the CPUID evaluation with it. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Michael Kelley <mhklinux@outlook.com> Tested-by: Sohil Mehta <sohil.mehta@intel.com> Link: https://lore.kernel.org/r/20240213210252.956858282@linutronix.de
Diffstat (limited to 'arch/x86/kernel/cpu/topology_common.c')
-rw-r--r--arch/x86/kernel/cpu/topology_common.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/arch/x86/kernel/cpu/topology_common.c b/arch/x86/kernel/cpu/topology_common.c
index c21a3871a870..a2c3f8f5886d 100644
--- a/arch/x86/kernel/cpu/topology_common.c
+++ b/arch/x86/kernel/cpu/topology_common.c
@@ -155,25 +155,15 @@ static void topo_set_ids(struct topo_scan *tscan)
c->topo.core_id = (apicid & topo_domain_mask(TOPO_PKG_DOMAIN)) >>
x86_topo_system.dom_shifts[TOPO_SMT_DOMAIN];
+ /* Maximum number of cores on this package */
+ c->x86_max_cores = topology_unit_count(apicid, TOPO_CORE_DOMAIN, TOPO_PKG_DOMAIN);
+
c->topo.amd_node_id = tscan->amd_node_id;
if (c->x86_vendor == X86_VENDOR_AMD)
cpu_topology_fixup_amd(tscan);
}
-static void topo_set_max_cores(struct topo_scan *tscan)
-{
- /*
- * Bug compatible for now. This is broken on hybrid systems:
- * 8 cores SMT + 8 cores w/o SMT
- * tscan.dom_ncpus[TOPO_DIEGRP_DOMAIN] = 24; 24 / 2 = 12 !!
- *
- * Cannot be fixed without further topology enumeration changes.
- */
- tscan->c->x86_max_cores = tscan->dom_ncpus[TOPO_DIEGRP_DOMAIN] >>
- x86_topo_system.dom_shifts[TOPO_SMT_DOMAIN];
-}
-
void cpu_parse_topology(struct cpuinfo_x86 *c)
{
unsigned int dom, cpu = smp_processor_id();
@@ -201,7 +191,6 @@ void cpu_parse_topology(struct cpuinfo_x86 *c)
}
topo_set_ids(&tscan);
- topo_set_max_cores(&tscan);
}
void __init cpu_init_topology(struct cpuinfo_x86 *c)
@@ -223,7 +212,6 @@ void __init cpu_init_topology(struct cpuinfo_x86 *c)
}
topo_set_ids(&tscan);
- topo_set_max_cores(&tscan);
/*
* AMD systems have Nodes per package which cannot be mapped to