[patch 33/37] x86/topology: Store extended topology leaf information

Thomas Gleixner
2023-04-14T23:46:47Z

Save the extended topology leaf number if it exists and is valid in
preparation of parallel CPU bringup.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/include/asm/topology.h | 1 +
arch/x86/kernel/cpu/topology.c | 3 +++
2 files changed, 4 insertions(+)

--- a/arch/x86/include/asm/topology.h
+++ b/arch/x86/include/asm/topology.h
@@ -121,6 +121,7 @@ extern unsigned int __max_die_per_packag
#define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu))
#define topology_sibling_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu))

+extern unsigned int topology_extended_leaf;
extern unsigned int __max_logical_packages;
#define topology_max_packages() (__max_logical_packages)

--- a/arch/x86/kernel/cpu/topology.c
+++ b/arch/x86/kernel/cpu/topology.c
@@ -29,6 +29,8 @@ unsigned int __max_die_per_package __rea
EXPORT_SYMBOL(__max_die_per_package);

#ifdef CONFIG_SMP
+unsigned int topology_extended_leaf __read_mostly;
+
/*
* Check if given CPUID extended topology "leaf" is implemented
*/
@@ -72,6 +74,7 @@ int detect_extended_topology_early(struc
if (leaf < 0)
return -1;

+ topology_extended_leaf = leaf;
set_cpu_cap(c, X86_FEATURE_XTOPOLOGY);

cpuid_count(leaf, SMT_LEVEL, &eax, &ebx, &ecx, &edx);