mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 12:57:06 +09:00
sched: Add sched_smt_active()
Add the sched_smt_active() function needed for some x86 speculation mitigations. This was introduced upstream by commits1b568f0aab"sched/core: Optimize SCHED_SMT",ba2591a599"sched/smt: Update sched_smt_present at runtime",c5511d03ec"sched/smt: Make sched_smt_present track topology", and321a874a7e"sched/smt: Expose sched_smt_present static key". The upstream implementation uses the static_key_{disable,enable}_cpuslocked() functions, which aren't practical to backport. Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@kernel.org> Cc: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
4cc154901e
commit
c803409910
18
include/linux/sched/smt.h
Normal file
18
include/linux/sched/smt.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef _LINUX_SCHED_SMT_H
|
||||
#define _LINUX_SCHED_SMT_H
|
||||
|
||||
#include <linux/atomic.h>
|
||||
|
||||
#ifdef CONFIG_SCHED_SMT
|
||||
extern atomic_t sched_smt_present;
|
||||
|
||||
static __always_inline bool sched_smt_active(void)
|
||||
{
|
||||
return atomic_read(&sched_smt_present);
|
||||
}
|
||||
#else
|
||||
static inline bool sched_smt_active(void) { return false; }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user