summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/cpu.h2
-rw-r--r--kernel/cpu.c11
2 files changed, 11 insertions, 2 deletions
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 88dc0c653925..d0633ebdaa9c 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -201,12 +201,14 @@ enum cpuhp_smt_control {
201extern enum cpuhp_smt_control cpu_smt_control; 201extern enum cpuhp_smt_control cpu_smt_control;
202extern void cpu_smt_disable(bool force); 202extern void cpu_smt_disable(bool force);
203extern void cpu_smt_check_topology(void); 203extern void cpu_smt_check_topology(void);
204extern bool cpu_smt_possible(void);
204extern int cpuhp_smt_enable(void); 205extern int cpuhp_smt_enable(void);
205extern int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval); 206extern int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval);
206#else 207#else
207# define cpu_smt_control (CPU_SMT_NOT_IMPLEMENTED) 208# define cpu_smt_control (CPU_SMT_NOT_IMPLEMENTED)
208static inline void cpu_smt_disable(bool force) { } 209static inline void cpu_smt_disable(bool force) { }
209static inline void cpu_smt_check_topology(void) { } 210static inline void cpu_smt_check_topology(void) { }
211static inline bool cpu_smt_possible(void) { return false; }
210static inline int cpuhp_smt_enable(void) { return 0; } 212static inline int cpuhp_smt_enable(void) { return 0; }
211static inline int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval) { return 0; } 213static inline int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval) { return 0; }
212#endif 214#endif
diff --git a/kernel/cpu.c b/kernel/cpu.c
index e1967e9eddc2..fc28e17940e0 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -392,8 +392,7 @@ enum cpuhp_smt_control cpu_smt_control __read_mostly = CPU_SMT_ENABLED;
392 392
393void __init cpu_smt_disable(bool force) 393void __init cpu_smt_disable(bool force)
394{ 394{
395 if (cpu_smt_control == CPU_SMT_FORCE_DISABLED || 395 if (!cpu_smt_possible())
396 cpu_smt_control == CPU_SMT_NOT_SUPPORTED)
397 return; 396 return;
398 397
399 if (force) { 398 if (force) {
@@ -438,6 +437,14 @@ static inline bool cpu_smt_allowed(unsigned int cpu)
438 */ 437 */
439 return !cpumask_test_cpu(cpu, &cpus_booted_once_mask); 438 return !cpumask_test_cpu(cpu, &cpus_booted_once_mask);
440} 439}
440
441/* Returns true if SMT is not supported of forcefully (irreversibly) disabled */
442bool cpu_smt_possible(void)
443{
444 return cpu_smt_control != CPU_SMT_FORCE_DISABLED &&
445 cpu_smt_control != CPU_SMT_NOT_SUPPORTED;
446}
447EXPORT_SYMBOL_GPL(cpu_smt_possible);
441#else 448#else
442static inline bool cpu_smt_allowed(unsigned int cpu) { return true; } 449static inline bool cpu_smt_allowed(unsigned int cpu) { return true; }
443#endif 450#endif