lkml.org 
[lkml]   [2018]   [Oct]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[Patch v4 06/18] smt: Create cpu_smt_enabled static key for SMT specific code
Date
Create cpu_smt_enabled static key used for enabling
SMT specific code paths.

Signed-off-by: Tim Chen <tim.c.chen@linux.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 3adecda..03170c8 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -349,6 +349,8 @@ EXPORT_SYMBOL_GPL(cpu_hotplug_enable);
#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;

@@ -364,6 +366,7 @@ void __init cpu_smt_disable(bool force)
} else {
cpu_smt_control = CPU_SMT_DISABLED;
}
+ static_branch_disable(&cpu_smt_enabled);
}

/*
@@ -373,8 +376,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);
+ }
}

/*
@@ -386,8 +391,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)
@@ -2072,6 +2079,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
\
 
 \ /
  Last update: 2018-10-30 20:24    [W:0.825 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site