Skip to content

Commit 321a874

Browse files
committed
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 <[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]
1 parent dbe7336 commit 321a874

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

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>
@@ -936,9 +937,6 @@ static inline int cpu_of(struct rq *rq)
936937

937938

938939
#ifdef CONFIG_SCHED_SMT
939-
940-
extern struct static_key_false sched_smt_present;
941-
942940
extern void __update_idle_core(struct rq *rq);
943941

944942
static inline void update_idle_core(struct rq *rq)

0 commit comments

Comments
 (0)