[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <91b719e53640f60666b40a3516da2b80703b2f76.1542418937.git.tim.c.chen@linux.intel.com>
Date: Fri, 16 Nov 2018 17:53:51 -0800
From: Tim Chen <tim.c.chen@...ux.intel.com>
To: Jiri Kosina <jikos@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>
Cc: Tim Chen <tim.c.chen@...ux.intel.com>,
Tom Lendacky <thomas.lendacky@....com>,
Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Andrea Arcangeli <aarcange@...hat.com>,
David Woodhouse <dwmw@...zon.co.uk>,
Andi Kleen <ak@...ux.intel.com>,
Dave Hansen <dave.hansen@...el.com>,
Casey Schaufler <casey.schaufler@...el.com>,
Asit Mallick <asit.k.mallick@...el.com>,
Arjan van de Ven <arjan@...ux.intel.com>,
Jon Masters <jcm@...hat.com>,
Waiman Long <longman9394@...il.com>,
linux-kernel@...r.kernel.org, x86@...nel.org
Subject: [Patch v5 08/16] smt: Create cpu_smt_enabled static key for SMT specific code
In later code, STIBP will be turned on/off in the context switch code
path when SMT is enabled. Checks for SMT is best
avoided on such hot paths.
Create cpu_smt_enabled static key to turn on such SMT specific code
statically.
This key is set in code under hot plug, so it is limited in
scope to architecture supporting CPU hotplug, like x86.
Signed-off-by: Tim Chen <tim.c.chen@...ux.intel.com>
---
include/linux/cpu.h | 1 +
kernel/cpu.c | 12 ++++++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 218df7f..b54f085 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -188,5 +188,6 @@ static inline void cpu_smt_disable(bool force) { }
static inline void cpu_smt_check_topology_early(void) { }
static inline void cpu_smt_check_topology(void) { }
#endif
+DECLARE_STATIC_KEY_TRUE(cpu_smt_enabled);
#endif /* _LINUX_CPU_H_ */
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 3c7f3b4..e216154 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -370,6 +370,8 @@ static void lockdep_release_cpus_lock(void)
#ifdef CONFIG_HOTPLUG_SMT
enum cpuhp_smt_control cpu_smt_control __read_mostly = CPU_SMT_ENABLED;
EXPORT_SYMBOL_GPL(cpu_smt_control);
+DEFINE_STATIC_KEY_TRUE(cpu_smt_enabled);
+EXPORT_SYMBOL_GPL(cpu_smt_enabled);
static bool cpu_smt_available __read_mostly;
@@ -386,6 +388,7 @@ void __init cpu_smt_disable(bool force)
pr_info("SMT: disabled\n");
cpu_smt_control = CPU_SMT_DISABLED;
}
+ static_branch_disable(&cpu_smt_enabled);
}
/*
@@ -395,8 +398,10 @@ void __init cpu_smt_disable(bool force)
*/
void __init cpu_smt_check_topology_early(void)
{
- if (!topology_smt_supported())
+ if (!topology_smt_supported()) {
cpu_smt_control = CPU_SMT_NOT_SUPPORTED;
+ static_branch_disable(&cpu_smt_enabled);
+ }
}
/*
@@ -408,8 +413,10 @@ void __init cpu_smt_check_topology_early(void)
*/
void __init cpu_smt_check_topology(void)
{
- if (!cpu_smt_available)
+ if (!cpu_smt_available) {
cpu_smt_control = CPU_SMT_NOT_SUPPORTED;
+ static_branch_disable(&cpu_smt_enabled);
+ }
}
static int __init smt_cmdline_disable(char *str)
@@ -2101,6 +2108,7 @@ static int cpuhp_smt_enable(void)
cpu_maps_update_begin();
cpu_smt_control = CPU_SMT_ENABLED;
+ static_branch_enable(&cpu_smt_enabled);
arch_smt_update();
for_each_present_cpu(cpu) {
/* Skip online CPUs and CPUs on offline nodes */
--
2.9.4
Powered by blists - more mailing lists