Skip to content

Commit 340693e

Browse files
KAGA-KOKOgregkh
authored andcommitted
sched/smt: Expose sched_smt_present static key
commit 321a874 upstream 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 <[email protected]> Reviewed-by: Ingo Molnar <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Jiri Kosina <[email protected]> Cc: Tom Lendacky <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: David Woodhouse <[email protected]> Cc: Tim Chen <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Casey Schaufler <[email protected]> Cc: Asit Mallick <[email protected]> Cc: Arjan van de Ven <[email protected]> Cc: Jon Masters <[email protected]> Cc: Waiman Long <[email protected]> Cc: Greg KH <[email protected]> Cc: Dave Stewart <[email protected]> Cc: Kees Cook <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f98bf16 commit 340693e

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

‎include/linux/sched/smt.h‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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

‎kernel/sched/sched.h‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/sched/prio.h>
2424
#include <linux/sched/rt.h>
2525
#include <linux/sched/signal.h>
26+
#include <linux/sched/smt.h>
2627
#include <linux/sched/stat.h>
2728
#include <linux/sched/sysctl.h>
2829
#include <linux/sched/task.h>
@@ -930,9 +931,6 @@ static inline int cpu_of(struct rq *rq)
930931

931932

932933
#ifdef CONFIG_SCHED_SMT
933-
934-
extern struct static_key_false sched_smt_present;
935-
936934
extern void __update_idle_core(struct rq *rq);
937935

938936
static inline void update_idle_core(struct rq *rq)

0 commit comments

Comments
 (0)