]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
cpu/hotplug: Expose SMT control init function
authorJiri Kosina <jkosina@suse.cz>
Fri, 13 Jul 2018 14:23:23 +0000 (16:23 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 13 Jul 2018 14:29:55 +0000 (16:29 +0200)
The L1TF mitigation will gain a commend line parameter which allows to set
a combination of hypervisor mitigation and SMT control.

Expose cpu_smt_disable() so the command line parser can tweak SMT settings.

[ tglx: Split out of larger patch and made it preserve an already existing
   force off state ]

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Jiri Kosina <jkosina@suse.cz>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lkml.kernel.org/r/20180713142323.039715135@linutronix.de
include/linux/cpu.h
kernel/cpu.c

index 7532cbf27b1db35f3679e695ca66bcfbb7fa3ff0..c9b23ad27b3897025a9c7c4923bc27ee371c975c 100644 (file)
@@ -177,8 +177,10 @@ enum cpuhp_smt_control {
 
 #if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_SMT)
 extern enum cpuhp_smt_control cpu_smt_control;
+extern void cpu_smt_disable(bool force);
 #else
 # define cpu_smt_control               (CPU_SMT_ENABLED)
+static inline void cpu_smt_disable(bool force) { }
 #endif
 
 #endif /* _LINUX_CPU_H_ */
index d79e24df24200b9f4cca6d8a398462fc4af36d2f..8453e31f2d1a0d4f3e1efcf0418ebeb77eddc61b 100644 (file)
@@ -347,13 +347,23 @@ EXPORT_SYMBOL_GPL(cpu_hotplug_enable);
 enum cpuhp_smt_control cpu_smt_control __read_mostly = CPU_SMT_ENABLED;
 EXPORT_SYMBOL_GPL(cpu_smt_control);
 
-static int __init smt_cmdline_disable(char *str)
+void __init cpu_smt_disable(bool force)
 {
-       cpu_smt_control = CPU_SMT_DISABLED;
-       if (str && !strcmp(str, "force")) {
+       if (cpu_smt_control == CPU_SMT_FORCE_DISABLED ||
+               cpu_smt_control == CPU_SMT_NOT_SUPPORTED)
+               return;
+
+       if (force) {
                pr_info("SMT: Force disabled\n");
                cpu_smt_control = CPU_SMT_FORCE_DISABLED;
+       } else {
+               cpu_smt_control = CPU_SMT_DISABLED;
        }
+}
+
+static int __init smt_cmdline_disable(char *str)
+{
+       cpu_smt_disable(str && !strcmp(str, "force"));
        return 0;
 }
 early_param("nosmt", smt_cmdline_disable);