Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sched/smt: Expose sched_smt_present static key

Make the scheduler's 'sched_smt_present' static key globaly available, so
it can be used in the x86 speculation control code.

Provide a query function and a stub for the CONFIG_SMP=n case.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: David Woodhouse <dwmw@amazon.co.uk>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Casey Schaufler <casey.schaufler@intel.com>
Cc: Asit Mallick <asit.k.mallick@intel.com>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Jon Masters <jcm@redhat.com>
Cc: Waiman Long <longman9394@gmail.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Dave Stewart <david.c.stewart@intel.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20181125185004.430168326@linutronix.de

+19 -3
+18
include/linux/sched/smt.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _LINUX_SCHED_SMT_H 3 + #define _LINUX_SCHED_SMT_H 4 + 5 + #include <linux/static_key.h> 6 + 7 + #ifdef CONFIG_SCHED_SMT 8 + extern struct static_key_false sched_smt_present; 9 + 10 + static __always_inline bool sched_smt_active(void) 11 + { 12 + return static_branch_likely(&sched_smt_present); 13 + } 14 + #else 15 + static inline bool sched_smt_active(void) { return false; } 16 + #endif 17 + 18 + #endif
+1 -3
kernel/sched/sched.h
··· 23 23 #include <linux/sched/prio.h> 24 24 #include <linux/sched/rt.h> 25 25 #include <linux/sched/signal.h> 26 + #include <linux/sched/smt.h> 26 27 #include <linux/sched/stat.h> 27 28 #include <linux/sched/sysctl.h> 28 29 #include <linux/sched/task.h> ··· 937 936 938 937 939 938 #ifdef CONFIG_SCHED_SMT 940 - 941 - extern struct static_key_false sched_smt_present; 942 - 943 939 extern void __update_idle_core(struct rq *rq); 944 940 945 941 static inline void update_idle_core(struct rq *rq)