lkml.org 
[lkml]   [2018]   [Nov]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[Patch v6 16/16] x86/smt: Allow disabling of SMT when last SMT is offlined
Date
Currently cpu_use_smt_and_hotplug is only set during boot time
to indicate if SMT is in use.

However, CPU topology may change and when the last SMT thread is offlined,
the SMT code path can be skipped. The sched_smt_present key detects
this condition.

Export sched_smt_present and incorporate it into cpu_use_smt_and_hotplug
to disable SMT code when there are no paired siblings.

Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
---
include/linux/cpu.h | 12 ++++++++++++
kernel/sched/sched.h | 2 --
2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 4fef90a..2fc649d 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -100,6 +100,10 @@ static inline void cpu_maps_update_done(void)
#endif /* CONFIG_SMP */
extern struct bus_type cpu_subsys;

+#ifdef CONFIG_SCHED_SMT
+extern struct static_key_false sched_smt_present;
+#endif
+
#ifdef CONFIG_HOTPLUG_CPU
extern void cpus_write_lock(void);
extern void cpus_write_unlock(void);
@@ -172,7 +176,15 @@ static inline void cpuhp_report_idle_dead(void) { }

#if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_SMT)
DECLARE_STATIC_KEY_TRUE(cpu_smt_enabled);
+
+#ifdef CONFIG_SCHED_SMT
+#define cpu_use_smt_and_hotplug \
+ (static_branch_likely(&cpu_smt_enabled) && \
+ static_branch_unlikely(&sched_smt_present))
+#else
#define cpu_use_smt_and_hotplug (static_branch_likely(&cpu_smt_enabled))
+#endif
+
extern void cpu_smt_disable(bool force);
extern void cpu_smt_check_topology_early(void);
extern void cpu_smt_check_topology(void);
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 618577f..e1e3f09 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -937,8 +937,6 @@ static inline int cpu_of(struct rq *rq)

#ifdef CONFIG_SCHED_SMT

-extern struct static_key_false sched_smt_present;
-
extern void __update_idle_core(struct rq *rq);

static inline void update_idle_core(struct rq *rq)
--
2.9.4
\
 
 \ /
  Last update: 2018-11-21 01:34    [W:0.801 / U:0.556 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site