Recent Intel processors combine CPUs with different types of micro- architecture in the same package. There may be applications interested in knowing the type topology of the system. For instance, it can be used to to determine which subsets of CPUs share a common feature.
Implement cpu_type sysfs interfaces for Intel processors. For example, in a system with four Intel Atom CPUs and one Intel Core CPU, these entries look as below. In this example, the native model IDs for both types of CPUs are 0: user@host:~$: ls /sys/devices/system/cpu/types intel_atom_0 intel_core_0 user@host:~$ ls /sys/devices/system/cpu/types/intel_atom_0 cpulist cpumap user@host:~$ ls /sys/devices/system/cpu/types/intel_core_0 cpulist cpumap user@host:~$ cat /sys/devices/system/cpu/types/intel_atom/cpumap 0f user@host:~$ cat /sys/devices/system/cpu/types/intel_atom/cpulist 0-3 user@nost:~$ cat /sys/devices/system/cpu/types/intel_core/cpumap 10 user@host:~$ cat /sys/devices/system/cpu/types/intel_core/cpulist 4 Cc: Andi Kleen <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Kan Liang <[email protected]> Cc: "Rafael J. Wysocki" <[email protected]> Cc: "Ravi V. Shankar" <[email protected]> Cc: Srinivas Pandruvada <[email protected]> Cc: [email protected] Reviewed-by: Tony Luck <[email protected]> Suggested-by: Len Brown <[email protected]> # Necessity of the interface Suggested-by: Dave Hansen <[email protected]> # Details of the interface Signed-off-by: Ricardo Neri <[email protected]> --- arch/x86/include/asm/topology.h | 2 ++ arch/x86/kernel/cpu/topology.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h index f4234575f3fd..d4a3e1ce8338 100644 --- a/arch/x86/include/asm/topology.h +++ b/arch/x86/include/asm/topology.h @@ -218,4 +218,6 @@ static inline void arch_set_max_freq_ratio(bool turbo_disabled) } #endif +#define CPUTYPES_MAX_NR 2 + #endif /* _ASM_X86_TOPOLOGY_H */ diff --git a/arch/x86/kernel/cpu/topology.c b/arch/x86/kernel/cpu/topology.c index d3a0791bc052..709fc473f905 100644 --- a/arch/x86/kernel/cpu/topology.c +++ b/arch/x86/kernel/cpu/topology.c @@ -153,3 +153,26 @@ int detect_extended_topology(struct cpuinfo_x86 *c) #endif return 0; } + +u32 arch_get_cpu_type(int cpu) +{ + struct cpuinfo_x86 *c = &cpu_data(cpu); + + if (cpu < 0 || cpu >= nr_cpu_ids) + return 0; + + return c->x86_cpu_type; +} + +bool arch_has_cpu_type(void) +{ + return boot_cpu_has(X86_FEATURE_HYBRID_CPU); +} + +const char *arch_get_cpu_type_name(u32 cpu_type) +{ + if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) + return intel_get_hybrid_cpu_type_name(cpu_type); + + return NULL; +} -- 2.17.1

