From: Thomas Gleixner Date: Thu, 21 Jun 2018 08:37:20 +0000 (+0200) Subject: x86/topology: Provide topology_smt_supported() X-Git-Tag: v4.1.12-124.31.3~661 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=870a86602753f83a6e8c552a3c1ea7ba0670efaa;p=users%2Fjedix%2Flinux-maple.git x86/topology: Provide topology_smt_supported() Provide information whether SMT is supoorted by the CPUs. Preparatory patch for SMT control mechanism. Suggested-by: Dave Hansen Signed-off-by: Thomas Gleixner Acked-by: Ingo Molnar Orabug: 28220674 CVE: CVE-2018-3620 (cherry picked from commit f048c399e0f7490ab7296bc2c255d37eb14a9675) Signed-off-by: Mihai Carabas Reviewed-by: Darren Kenny Reviewed-by: Boris Ostrovsky Conflicts: arch/x86/kernel/smpboot.c Contextual --- diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h index bf9b53421a6f7..0d02e19abe581 100644 --- a/arch/x86/include/asm/topology.h +++ b/arch/x86/include/asm/topology.h @@ -124,8 +124,10 @@ extern const struct cpumask *cpu_coregroup_mask(int cpu); #ifdef CONFIG_SMP bool topology_is_primary_thread(unsigned int cpu); +bool topology_smt_supported(void); #else static inline bool topology_is_primary_thread(unsigned int cpu) { return true; } +static inline bool topology_smt_supported(void) { return false; } #endif #ifdef ENABLE_TOPO_DEFINES diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 76c42a0d26c40..9cf20ce8be2dc 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -279,6 +279,14 @@ bool topology_is_primary_thread(unsigned int cpu) return apic_id_is_primary_thread(per_cpu(x86_cpu_to_apicid, cpu)); } +/** + * topology_smt_supported - Check whether SMT is supported by the CPUs + */ +bool topology_smt_supported(void) +{ + return smp_num_siblings > 1; +} + void __init smp_store_boot_cpu_info(void) { int id = 0; /* CPU 0 */