diff options
| -rw-r--r-- | arch/x86/kernel/cpu/bugs.c | 2 | ||||
| -rw-r--r-- | arch/x86/kvm/vmx/vmx.c | 3 | ||||
| -rw-r--r-- | include/linux/cpu.h | 2 | ||||
| -rw-r--r-- | kernel/cpu.c | 33 | ||||
| -rw-r--r-- | kernel/sched/fair.c | 1 | ||||
| -rw-r--r-- | kernel/smp.c | 2 |
6 files changed, 8 insertions, 35 deletions
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 1de0f4170178..01874d54f4fd 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c | |||
| @@ -71,7 +71,7 @@ void __init check_bugs(void) | |||
| 71 | * identify_boot_cpu() initialized SMT support information, let the | 71 | * identify_boot_cpu() initialized SMT support information, let the |
| 72 | * core code know. | 72 | * core code know. |
| 73 | */ | 73 | */ |
| 74 | cpu_smt_check_topology_early(); | 74 | cpu_smt_check_topology(); |
| 75 | 75 | ||
| 76 | if (!IS_ENABLED(CONFIG_SMP)) { | 76 | if (!IS_ENABLED(CONFIG_SMP)) { |
| 77 | pr_info("CPU: "); | 77 | pr_info("CPU: "); |
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 4341175339f3..95d618045001 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include <linux/mod_devicetable.h> | 26 | #include <linux/mod_devicetable.h> |
| 27 | #include <linux/mm.h> | 27 | #include <linux/mm.h> |
| 28 | #include <linux/sched.h> | 28 | #include <linux/sched.h> |
| 29 | #include <linux/sched/smt.h> | ||
| 29 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
| 30 | #include <linux/tboot.h> | 31 | #include <linux/tboot.h> |
| 31 | #include <linux/trace_events.h> | 32 | #include <linux/trace_events.h> |
| @@ -6823,7 +6824,7 @@ static int vmx_vm_init(struct kvm *kvm) | |||
| 6823 | * Warn upon starting the first VM in a potentially | 6824 | * Warn upon starting the first VM in a potentially |
| 6824 | * insecure environment. | 6825 | * insecure environment. |
| 6825 | */ | 6826 | */ |
| 6826 | if (cpu_smt_control == CPU_SMT_ENABLED) | 6827 | if (sched_smt_active()) |
| 6827 | pr_warn_once(L1TF_MSG_SMT); | 6828 | pr_warn_once(L1TF_MSG_SMT); |
| 6828 | if (l1tf_vmx_mitigation == VMENTER_L1D_FLUSH_NEVER) | 6829 | if (l1tf_vmx_mitigation == VMENTER_L1D_FLUSH_NEVER) |
| 6829 | pr_warn_once(L1TF_MSG_L1D); | 6830 | pr_warn_once(L1TF_MSG_L1D); |
diff --git a/include/linux/cpu.h b/include/linux/cpu.h index 218df7f4d3e1..5041357d0297 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h | |||
| @@ -180,12 +180,10 @@ enum cpuhp_smt_control { | |||
| 180 | #if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_SMT) | 180 | #if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_SMT) |
| 181 | extern enum cpuhp_smt_control cpu_smt_control; | 181 | extern enum cpuhp_smt_control cpu_smt_control; |
| 182 | extern void cpu_smt_disable(bool force); | 182 | extern void cpu_smt_disable(bool force); |
| 183 | extern void cpu_smt_check_topology_early(void); | ||
| 184 | extern void cpu_smt_check_topology(void); | 183 | extern void cpu_smt_check_topology(void); |
| 185 | #else | 184 | #else |
| 186 | # define cpu_smt_control (CPU_SMT_ENABLED) | 185 | # define cpu_smt_control (CPU_SMT_ENABLED) |
| 187 | static inline void cpu_smt_disable(bool force) { } | 186 | static inline void cpu_smt_disable(bool force) { } |
| 188 | static inline void cpu_smt_check_topology_early(void) { } | ||
| 189 | static inline void cpu_smt_check_topology(void) { } | 187 | static inline void cpu_smt_check_topology(void) { } |
| 190 | #endif | 188 | #endif |
| 191 | 189 | ||
diff --git a/kernel/cpu.c b/kernel/cpu.c index c0c7f64573ed..d1c6d152da89 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c | |||
| @@ -376,9 +376,6 @@ void __weak arch_smt_update(void) { } | |||
| 376 | 376 | ||
| 377 | #ifdef CONFIG_HOTPLUG_SMT | 377 | #ifdef CONFIG_HOTPLUG_SMT |
| 378 | enum cpuhp_smt_control cpu_smt_control __read_mostly = CPU_SMT_ENABLED; | 378 | enum cpuhp_smt_control cpu_smt_control __read_mostly = CPU_SMT_ENABLED; |
| 379 | EXPORT_SYMBOL_GPL(cpu_smt_control); | ||
| 380 | |||
| 381 | static bool cpu_smt_available __read_mostly; | ||
| 382 | 379 | ||
| 383 | void __init cpu_smt_disable(bool force) | 380 | void __init cpu_smt_disable(bool force) |
| 384 | { | 381 | { |
| @@ -397,25 +394,11 @@ void __init cpu_smt_disable(bool force) | |||
| 397 | 394 | ||
| 398 | /* | 395 | /* |
| 399 | * The decision whether SMT is supported can only be done after the full | 396 | * The decision whether SMT is supported can only be done after the full |
| 400 | * CPU identification. Called from architecture code before non boot CPUs | 397 | * CPU identification. Called from architecture code. |
| 401 | * are brought up. | ||
| 402 | */ | ||
| 403 | void __init cpu_smt_check_topology_early(void) | ||
| 404 | { | ||
| 405 | if (!topology_smt_supported()) | ||
| 406 | cpu_smt_control = CPU_SMT_NOT_SUPPORTED; | ||
| 407 | } | ||
| 408 | |||
| 409 | /* | ||
| 410 | * If SMT was disabled by BIOS, detect it here, after the CPUs have been | ||
| 411 | * brought online. This ensures the smt/l1tf sysfs entries are consistent | ||
| 412 | * with reality. cpu_smt_available is set to true during the bringup of non | ||
| 413 | * boot CPUs when a SMT sibling is detected. Note, this may overwrite | ||
| 414 | * cpu_smt_control's previous setting. | ||
| 415 | */ | 398 | */ |
| 416 | void __init cpu_smt_check_topology(void) | 399 | void __init cpu_smt_check_topology(void) |
| 417 | { | 400 | { |
| 418 | if (!cpu_smt_available) | 401 | if (!topology_smt_supported()) |
| 419 | cpu_smt_control = CPU_SMT_NOT_SUPPORTED; | 402 | cpu_smt_control = CPU_SMT_NOT_SUPPORTED; |
| 420 | } | 403 | } |
| 421 | 404 | ||
| @@ -428,18 +411,10 @@ early_param("nosmt", smt_cmdline_disable); | |||
| 428 | 411 | ||
| 429 | static inline bool cpu_smt_allowed(unsigned int cpu) | 412 | static inline bool cpu_smt_allowed(unsigned int cpu) |
| 430 | { | 413 | { |
| 431 | if (topology_is_primary_thread(cpu)) | 414 | if (cpu_smt_control == CPU_SMT_ENABLED) |
| 432 | return true; | 415 | return true; |
| 433 | 416 | ||
| 434 | /* | 417 | if (topology_is_primary_thread(cpu)) |
| 435 | * If the CPU is not a 'primary' thread and the booted_once bit is | ||
| 436 | * set then the processor has SMT support. Store this information | ||
| 437 | * for the late check of SMT support in cpu_smt_check_topology(). | ||
| 438 | */ | ||
| 439 | if (per_cpu(cpuhp_state, cpu).booted_once) | ||
| 440 | cpu_smt_available = true; | ||
| 441 | |||
| 442 | if (cpu_smt_control == CPU_SMT_ENABLED) | ||
| 443 | return true; | 418 | return true; |
| 444 | 419 | ||
| 445 | /* | 420 | /* |
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 50aa2aba69bd..310d0637fe4b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c | |||
| @@ -5980,6 +5980,7 @@ static inline int find_idlest_cpu(struct sched_domain *sd, struct task_struct *p | |||
| 5980 | 5980 | ||
| 5981 | #ifdef CONFIG_SCHED_SMT | 5981 | #ifdef CONFIG_SCHED_SMT |
| 5982 | DEFINE_STATIC_KEY_FALSE(sched_smt_present); | 5982 | DEFINE_STATIC_KEY_FALSE(sched_smt_present); |
| 5983 | EXPORT_SYMBOL_GPL(sched_smt_present); | ||
| 5983 | 5984 | ||
| 5984 | static inline void set_idle_cores(int cpu, int val) | 5985 | static inline void set_idle_cores(int cpu, int val) |
| 5985 | { | 5986 | { |
diff --git a/kernel/smp.c b/kernel/smp.c index 163c451af42e..f4cf1b0bb3b8 100644 --- a/kernel/smp.c +++ b/kernel/smp.c | |||
| @@ -584,8 +584,6 @@ void __init smp_init(void) | |||
| 584 | num_nodes, (num_nodes > 1 ? "s" : ""), | 584 | num_nodes, (num_nodes > 1 ? "s" : ""), |
| 585 | num_cpus, (num_cpus > 1 ? "s" : "")); | 585 | num_cpus, (num_cpus > 1 ? "s" : "")); |
| 586 | 586 | ||
| 587 | /* Final decision about SMT support */ | ||
| 588 | cpu_smt_check_topology(); | ||
| 589 | /* Any cleanup work */ | 587 | /* Any cleanup work */ |
| 590 | smp_cpus_done(setup_max_cpus); | 588 | smp_cpus_done(setup_max_cpus); |
| 591 | } | 589 | } |
