* [PATCH 0/4] sched/core: Core scheduling beyond SMT siblings
@ 2026-12-03 22:13 Ahmed Abdelraoof
2026-12-03 22:13 ` [PATCH 1/4] sched/core: Decouple the core scheduling unit from cpu_smt_mask Ahmed Abdelraoof
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Ahmed Abdelraoof @ 2026-12-03 22:13 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra
Cc: Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt,
Ben Segall, Mel Gorman, Valentin Schneider, K Prateek Nayak,
Jonathan Corbet, Shuah Khan, Randy Dunlap, linux-doc,
linux-kernel, Ahmed Abdelraoof
From: Ahmed Abdelraoof <araoof@amazon.com>
Core scheduling isolates tasks that distrust each other by never
running them simultaneously on CPUs that share microarchitectural
state. Today the isolation unit is hard-wired to the SMT sibling set.
New processors can share an L2 cache between pair of cores while
providing no SMT at all. There, the SMT sibling set reduces to a
single CPU, so core scheduling has nothing to isolate, while the
shared L2 exposes the same class of side channel one level up.
This series generalizes core scheduling to a configurable isolation
unit and adds support for cluster unit, which on x86 is the set of CPUs
sharing an L2. Two side-channel classes motivate this:
- Cache-based channels (Prime+Probe and friends): if an attacker and
a victim can co-run on cores sharing an L2 between a small number of
cores, a reliable cross-core channel exists. Restricting each cluster
to same-cookie co-residency removes that concurrent precondition.
Attacks that span a context switch remain out of scope, as they are
for SMT core scheduling.
- Frequency-domain channels: one core's activity modulates the clock
the whole cluster observes, leaking information without any cache
traffic. This series does not attempt to mitigate that class; it is
future work.
base-commit: 74ce3843347b0fe192e9bf29f46e1a266515defa
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] sched/core: Decouple the core scheduling unit from cpu_smt_mask
2026-12-03 22:13 [PATCH 0/4] sched/core: Core scheduling beyond SMT siblings Ahmed Abdelraoof
@ 2026-12-03 22:13 ` Ahmed Abdelraoof
2026-12-03 22:13 ` [PATCH 2/4] sched/core: Nest the isolation unit rq locks under one lock for lockdep Ahmed Abdelraoof
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Ahmed Abdelraoof @ 2026-12-03 22:13 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra
Cc: Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt,
Ben Segall, Mel Gorman, Valentin Schneider, K Prateek Nayak,
Jonathan Corbet, Shuah Khan, Randy Dunlap, linux-doc,
linux-kernel, Anselm Busse, Ahmed Abdelraoof
From: Anselm Busse <abusse@amazon.com>
Core scheduling uses cpu_smt_mask() to identify which CPUs (SMT threads)
belong to the same core scheduling equivalence group. That said, SMT
siblings are not the only CPUs that share microarchitectural state.
Cores behind a shared L2 cache can observe each other through it much
as SMT siblings can through the core.
Add sched_core_isolation_mask() as the single definition of that unit
and use it for every core scheduling user of cpu_smt_mask(). The helper
returns cpu_smt_mask() for now, so there is no functional change.
Signed-off-by: Anselm Busse <abusse@amazon.com>
Co-developed-by: Ahmed Abdelraoof <araoof@amazon.com>
Signed-off-by: Ahmed Abdelraoof <araoof@amazon.com>
---
kernel/sched/core.c | 33 ++++++++++++++++++---------------
kernel/sched/sched.h | 18 ++++++++++++++----
2 files changed, 32 insertions(+), 19 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index ea89471d4743..cdd944bb274d 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -433,11 +433,11 @@ static void sched_core_lock(int cpu, unsigned long *flags)
__context_unsafe(/* acquires multiple */)
__acquires(&runqueues.__lock) /* overapproximation */
{
- const struct cpumask *smt_mask = cpu_smt_mask(cpu);
+ const struct cpumask *isolation_mask = sched_core_isolation_mask(cpu);
int t, i = 0;
local_irq_save(*flags);
- for_each_cpu(t, smt_mask)
+ for_each_cpu(t, isolation_mask)
raw_spin_lock_nested(&cpu_rq(t)->__lock, i++);
}
@@ -445,10 +445,10 @@ static void sched_core_unlock(int cpu, unsigned long *flags)
__context_unsafe(/* releases multiple */)
__releases(&runqueues.__lock) /* overapproximation */
{
- const struct cpumask *smt_mask = cpu_smt_mask(cpu);
+ const struct cpumask *isolation_mask = sched_core_isolation_mask(cpu);
int t;
- for_each_cpu(t, smt_mask)
+ for_each_cpu(t, isolation_mask)
raw_spin_unlock(&cpu_rq(t)->__lock);
local_irq_restore(*flags);
}
@@ -465,7 +465,7 @@ static void __sched_core_flip(bool enabled)
*/
cpumask_copy(&sched_core_mask, cpu_online_mask);
for_each_cpu(cpu, &sched_core_mask) {
- const struct cpumask *smt_mask = cpu_smt_mask(cpu);
+ const struct cpumask *isolation_mask = sched_core_isolation_mask(cpu);
sched_core_lock(cpu, &flags);
@@ -480,14 +480,17 @@ static void __sched_core_flip(bool enabled)
sched_core_lock(cpu, &flags);
}
- for_each_cpu(t, smt_mask)
+ for_each_cpu(t, isolation_mask)
cpu_rq(t)->core_enabled = enabled;
cpu_rq(cpu)->core->core_forceidle_start = 0;
sched_core_unlock(cpu, &flags);
- cpumask_andnot(&sched_core_mask, &sched_core_mask, smt_mask);
+ /*
+ * Skip already toggled cores
+ */
+ cpumask_andnot(&sched_core_mask, &sched_core_mask, isolation_mask);
}
/*
@@ -6700,7 +6703,7 @@ DEFINE_LOCK_GUARD_1(core_lock, int,
static void sched_core_cpu_starting(unsigned int cpu)
{
- const struct cpumask *smt_mask = cpu_smt_mask(cpu);
+ const struct cpumask *isolation_mask = sched_core_isolation_mask(cpu);
struct rq *rq = cpu_rq(cpu), *core_rq = NULL;
int t;
@@ -6709,11 +6712,11 @@ static void sched_core_cpu_starting(unsigned int cpu)
WARN_ON_ONCE(rq->core != rq);
/* if we're the first, we'll be our own leader */
- if (cpumask_weight(smt_mask) == 1)
+ if (cpumask_weight(isolation_mask) == 1)
return;
/* find the leader */
- for_each_cpu(t, smt_mask) {
+ for_each_cpu(t, isolation_mask) {
if (t == cpu)
continue;
rq = cpu_rq(t);
@@ -6727,7 +6730,7 @@ static void sched_core_cpu_starting(unsigned int cpu)
return;
/* install and validate core_rq */
- for_each_cpu(t, smt_mask) {
+ for_each_cpu(t, isolation_mask) {
rq = cpu_rq(t);
if (t == cpu)
@@ -6739,14 +6742,14 @@ static void sched_core_cpu_starting(unsigned int cpu)
static void sched_core_cpu_deactivate(unsigned int cpu)
{
- const struct cpumask *smt_mask = cpu_smt_mask(cpu);
+ const struct cpumask *isolation_mask = sched_core_isolation_mask(cpu);
struct rq *rq = cpu_rq(cpu), *core_rq = NULL;
int t;
guard(core_lock)(&cpu);
/* if we're the last man standing, nothing to do */
- if (cpumask_weight(smt_mask) == 1) {
+ if (cpumask_weight(isolation_mask) == 1) {
WARN_ON_ONCE(rq->core != rq);
return;
}
@@ -6756,7 +6759,7 @@ static void sched_core_cpu_deactivate(unsigned int cpu)
return;
/* find a new leader */
- for_each_cpu(t, smt_mask) {
+ for_each_cpu(t, isolation_mask) {
if (t == cpu)
continue;
core_rq = cpu_rq(t);
@@ -6789,7 +6792,7 @@ static void sched_core_cpu_deactivate(unsigned int cpu)
core_rq->core_forceidle_start = 0;
/* install new leader */
- for_each_cpu(t, smt_mask) {
+ for_each_cpu(t, isolation_mask) {
rq = cpu_rq(t);
rq->core = core_rq;
}
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 32f76551a0c5..948f70af6fa6 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1565,7 +1565,7 @@ static inline raw_spinlock_t *__rq_lockp(struct rq *rq)
}
/*
- * A CPU coming online is set in cpu_smt_mask() before
+ * A CPU coming online is set in sched_core_isolation_mask() before
* sched_core_cpu_starting() links its rq->core to the core leader.
* Until then it does not share the core-wide lock, so it must not be
* touched as part of the core.
@@ -1576,11 +1576,11 @@ static inline bool sched_core_sibling(struct rq *rq, struct rq *rq_i)
}
#define for_each_core_cpu(i, rq) \
- for_each_cpu(i, cpu_smt_mask(rq->cpu)) \
+ for_each_cpu(i, sched_core_isolation_mask(rq->cpu)) \
if (sched_core_sibling(rq, cpu_rq(i)))
#define for_each_core_cpu_wrap(i, rq) \
- for_each_cpu_wrap(i, cpu_smt_mask(rq->cpu), rq->cpu) \
+ for_each_cpu_wrap(i, sched_core_isolation_mask(rq->cpu), rq->cpu) \
if (sched_core_sibling(rq, cpu_rq(i)))
extern bool
@@ -1588,6 +1588,16 @@ cfs_prio_less(const struct task_struct *a, const struct task_struct *b, bool fi)
extern void task_vruntime_update(struct rq *rq, struct task_struct *p, bool in_fi);
+/*
+ * The core scheduling isolation unit: the set of CPUs that share one runqueue
+ * lock and that are constrained to run tasks carrying a single cookie at any
+ * instant.
+ */
+static inline const struct cpumask *sched_core_isolation_mask(int cpu)
+{
+ return cpu_smt_mask(cpu);
+}
+
/*
* Helpers to check if the CPU's core cookie matches with the task's cookie
* when core scheduling is enabled.
@@ -1615,7 +1625,7 @@ static inline bool sched_core_cookie_match(struct rq *rq, struct task_struct *p)
if (rq->core->core_cookie == p->core_cookie)
return true;
- for_each_cpu(cpu, cpu_smt_mask(cpu_of(rq))) {
+ for_each_cpu(cpu, sched_core_isolation_mask(cpu_of(rq))) {
if (!available_idle_cpu(cpu)) {
idle_core = false;
break;
--
2.47.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] sched/core: Nest the isolation unit rq locks under one lock for lockdep
2026-12-03 22:13 [PATCH 0/4] sched/core: Core scheduling beyond SMT siblings Ahmed Abdelraoof
2026-12-03 22:13 ` [PATCH 1/4] sched/core: Decouple the core scheduling unit from cpu_smt_mask Ahmed Abdelraoof
@ 2026-12-03 22:13 ` Ahmed Abdelraoof
2026-12-03 22:13 ` [PATCH 3/4] sched/core: Gate core scheduling on the isolation unit Ahmed Abdelraoof
2026-12-03 22:13 ` [PATCH 4/4] sched/core: Support L2 cache isolation Ahmed Abdelraoof
3 siblings, 0 replies; 5+ messages in thread
From: Ahmed Abdelraoof @ 2026-12-03 22:13 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra
Cc: Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt,
Ben Segall, Mel Gorman, Valentin Schneider, K Prateek Nayak,
Jonathan Corbet, Shuah Khan, Randy Dunlap, linux-doc,
linux-kernel, Ahmed Abdelraoof, Anselm Busse
From: Ahmed Abdelraoof <araoof@amazon.com>
Lockdep does not properly handle nested locking of more than 8 locks of
the same class using subclasses. This showed up when testing
L2-cache-based core scheduling policies in QEMU with custom topologies.
To work around this limitation, take the rq lock of the unit's first CPU
as a subclass of its own and nest the other rq locks under it.
The idea of using a nest lock to work around the 8-subclass limit is
inspired by commit e4a454ced74c ("KVM: add kvm_lock_all_vcpus and
kvm_trylock_all_vcpus"), where they did the trick using an already
existing lock.
The idea of splitting the first lock into a subclass of its own is
inspired by commit 566c09c53455 ("raid5: relieve lock contention in
get_active_stripe()").
Co-developed-by: Anselm Busse <abusse@amazon.com>
Signed-off-by: Anselm Busse <abusse@amazon.com>
Signed-off-by: Ahmed Abdelraoof <araoof@amazon.com>
---
kernel/sched/core.c | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index cdd944bb274d..b62716094445 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -429,16 +429,26 @@ static DEFINE_MUTEX(sched_core_mutex);
static atomic_t sched_core_count;
static struct cpumask sched_core_mask;
+/*
+ * The rq locks of a unit share one lockdep class, and a subclass per CPU
+ * would overflow MAX_LOCKDEP_SUBCLASSES on units wider than eight CPUs. So
+ * nest them under the first CPU's rq lock, taken as a subclass of its own.
+ */
+#define SCHED_CORE_NEST_SUBCLASS (SINGLE_DEPTH_NESTING + 1)
+
static void sched_core_lock(int cpu, unsigned long *flags)
__context_unsafe(/* acquires multiple */)
__acquires(&runqueues.__lock) /* overapproximation */
{
const struct cpumask *isolation_mask = sched_core_isolation_mask(cpu);
- int t, i = 0;
+ struct rq *first = cpu_rq(cpumask_first(isolation_mask));
+ int t;
- local_irq_save(*flags);
- for_each_cpu(t, isolation_mask)
- raw_spin_lock_nested(&cpu_rq(t)->__lock, i++);
+ raw_spin_lock_irqsave_nested(&first->__lock, *flags, SCHED_CORE_NEST_SUBCLASS);
+ for_each_cpu(t, isolation_mask) {
+ if (cpu_rq(t) != first)
+ raw_spin_lock_nest_lock(&cpu_rq(t)->__lock, &first->__lock);
+ }
}
static void sched_core_unlock(int cpu, unsigned long *flags)
@@ -446,11 +456,14 @@ static void sched_core_unlock(int cpu, unsigned long *flags)
__releases(&runqueues.__lock) /* overapproximation */
{
const struct cpumask *isolation_mask = sched_core_isolation_mask(cpu);
+ struct rq *first = cpu_rq(cpumask_first(isolation_mask));
int t;
- for_each_cpu(t, isolation_mask)
- raw_spin_unlock(&cpu_rq(t)->__lock);
- local_irq_restore(*flags);
+ for_each_cpu(t, isolation_mask) {
+ if (cpu_rq(t) != first)
+ raw_spin_unlock(&cpu_rq(t)->__lock);
+ }
+ raw_spin_unlock_irqrestore(&first->__lock, *flags);
}
static void __sched_core_flip(bool enabled)
--
2.47.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] sched/core: Gate core scheduling on the isolation unit
2026-12-03 22:13 [PATCH 0/4] sched/core: Core scheduling beyond SMT siblings Ahmed Abdelraoof
2026-12-03 22:13 ` [PATCH 1/4] sched/core: Decouple the core scheduling unit from cpu_smt_mask Ahmed Abdelraoof
2026-12-03 22:13 ` [PATCH 2/4] sched/core: Nest the isolation unit rq locks under one lock for lockdep Ahmed Abdelraoof
@ 2026-12-03 22:13 ` Ahmed Abdelraoof
2026-12-03 22:13 ` [PATCH 4/4] sched/core: Support L2 cache isolation Ahmed Abdelraoof
3 siblings, 0 replies; 5+ messages in thread
From: Ahmed Abdelraoof @ 2026-12-03 22:13 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra
Cc: Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt,
Ben Segall, Mel Gorman, Valentin Schneider, K Prateek Nayak,
Jonathan Corbet, Shuah Khan, Randy Dunlap, linux-doc,
linux-kernel, Anselm Busse, Ahmed Abdelraoof
From: Anselm Busse <abusse@amazon.com>
prctl(PR_SCHED_CORE) fails with -ENODEV unless sched_smt_present is set.
Once the isolation unit can be wider than the SMT siblings, core
scheduling has something to isolate on systems without SMT.
Add a separate sched_core_unit_present key, counted once per unit as its
second CPU comes up, and gate the prctl on it.
Keep sched_smt_present as it is used to report kernel suseptability to
SMT related vulnerabilities (TAA, L1TF ..etc).
No functional change intended.
Signed-off-by: Anselm Busse <abusse@amazon.com>
Co-developed-by: Ahmed Abdelraoof <araoof@amazon.com>
Signed-off-by: Ahmed Abdelraoof <araoof@amazon.com>
---
kernel/sched/core.c | 26 ++++++++++++++++++++++++++
kernel/sched/core_sched.c | 2 +-
kernel/sched/sched.h | 11 +++++++++++
3 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b62716094445..c69f40e7b93a 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -8725,6 +8725,30 @@ static inline void sched_smt_present_dec(int cpu)
static_branch_dec_cpuslocked(&sched_smt_present);
}
+#ifdef CONFIG_SCHED_CORE
+DEFINE_STATIC_KEY_FALSE(sched_core_unit_present);
+
+/*
+ * Fire once per isolation unit, as its second CPU comes up and again as the
+ * unit shrinks back through two, which keeps the refcount balanced for any
+ * unit width. When the unit is SMT this tracks sched_smt_present exactly.
+ */
+static inline void sched_core_unit_present_inc(int cpu)
+{
+ if (cpumask_weight(sched_core_isolation_mask(cpu)) == 2)
+ static_branch_inc_cpuslocked(&sched_core_unit_present);
+}
+
+static inline void sched_core_unit_present_dec(int cpu)
+{
+ if (cpumask_weight(sched_core_isolation_mask(cpu)) == 2)
+ static_branch_dec_cpuslocked(&sched_core_unit_present);
+}
+#else
+static inline void sched_core_unit_present_inc(int cpu) { }
+static inline void sched_core_unit_present_dec(int cpu) { }
+#endif
+
int sched_cpu_activate(unsigned int cpu)
{
struct rq *rq = cpu_rq(cpu);
@@ -8739,6 +8763,7 @@ int sched_cpu_activate(unsigned int cpu)
* When going up, increment the number of cores with SMT present.
*/
sched_smt_present_inc(cpu);
+ sched_core_unit_present_inc(cpu);
set_cpu_active(cpu, true);
if (sched_smp_initialized) {
@@ -8817,6 +8842,7 @@ int sched_cpu_deactivate(unsigned int cpu)
* When going down, decrement the number of cores with SMT present.
*/
sched_smt_present_dec(cpu);
+ sched_core_unit_present_dec(cpu);
sched_core_cpu_deactivate(cpu);
diff --git a/kernel/sched/core_sched.c b/kernel/sched/core_sched.c
index d56be1c31435..ba4d608c0d80 100644
--- a/kernel/sched/core_sched.c
+++ b/kernel/sched/core_sched.c
@@ -136,7 +136,7 @@ int sched_core_share_pid(unsigned int cmd, pid_t pid, enum pid_type type,
struct pid *grp;
int err = 0;
- if (!sched_smt_active())
+ if (!sched_core_unit_active())
return -ENODEV;
BUILD_BUG_ON(PR_SCHED_CORE_SCOPE_THREAD != PIDTYPE_PID);
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 948f70af6fa6..97126c1dcb09 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1598,6 +1598,17 @@ static inline const struct cpumask *sched_core_isolation_mask(int cpu)
return cpu_smt_mask(cpu);
}
+DECLARE_STATIC_KEY_FALSE(sched_core_unit_present);
+
+/*
+ * True once some isolation unit spans more than one CPU, i.e. once core
+ * scheduling has something it can actually exclude.
+ */
+static inline bool sched_core_unit_active(void)
+{
+ return static_branch_likely(&sched_core_unit_present);
+}
+
/*
* Helpers to check if the CPU's core cookie matches with the task's cookie
* when core scheduling is enabled.
--
2.47.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] sched/core: Support L2 cache isolation
2026-12-03 22:13 [PATCH 0/4] sched/core: Core scheduling beyond SMT siblings Ahmed Abdelraoof
` (2 preceding siblings ...)
2026-12-03 22:13 ` [PATCH 3/4] sched/core: Gate core scheduling on the isolation unit Ahmed Abdelraoof
@ 2026-12-03 22:13 ` Ahmed Abdelraoof
3 siblings, 0 replies; 5+ messages in thread
From: Ahmed Abdelraoof @ 2026-12-03 22:13 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra
Cc: Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt,
Ben Segall, Mel Gorman, Valentin Schneider, K Prateek Nayak,
Jonathan Corbet, Shuah Khan, Randy Dunlap, linux-doc,
linux-kernel, Anselm Busse, Ahmed Abdelraoof
From: Anselm Busse <abusse@amazon.com>
Core scheduling only isolates SMT siblings from each other. Cores that
share an L2 cache can observe each other through it much as SMT siblings
can through the core, so on processors that pair cores around a shared
L2 core scheduling leaves that path open.
Add a kernel command-line parameter "sched_core_unit=X", where X can be
"smt" (the default) to keep the SMT siblings as the isolation unit, or
"cluster" to use the CPUs of a cluster as reported by
topology_cluster_cpumask(). On x86 a cluster is the set of CPUs that
share an L2 cache. All CPUs of a unit share one rq lock, so a wider
unit trades some lock contention for the isolation.
If "cluster" is selected but no cluster spans more than one CPU, warn
that no clusters were reported and core scheduling is unavailable.
Signed-off-by: Anselm Busse <abusse@amazon.com>
Co-developed-by: Ahmed Abdelraoof <araoof@amazon.com>
Signed-off-by: Ahmed Abdelraoof <araoof@amazon.com>
---
.../admin-guide/kernel-parameters.txt | 12 +++++
kernel/sched/core.c | 44 +++++++++++++++++++
kernel/sched/sched.h | 18 ++++++++
3 files changed, 74 insertions(+)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 176648941aec..faaeb4812b60 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -6801,6 +6801,18 @@ Kernel parameters
cost of significant additional memory use for tables.
+ sched_core_unit=
+ [KNL,EARLY] Select the CPUs that core scheduling treats
+ as one isolation unit, i.e. that never run tasks with
+ different core scheduling cookies at the same time.
+ Format: { smt | cluster }
+ smt - SMT siblings (default).
+ cluster - CPUs in the same cluster, as reported by the
+ CPU topology (on x86, the CPUs that share an L2
+ cache); for processors that pair cores around a
+ shared L2 without SMT.
+ See Documentation/admin-guide/hw-vuln/core-scheduling.rst.
+
sched_proxy_exec= [KNL]
Enables or disables "proxy execution" style
solution to mutex-based priority inversion.
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index c69f40e7b93a..6640ea861818 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -429,6 +429,50 @@ static DEFINE_MUTEX(sched_core_mutex);
static atomic_t sched_core_count;
static struct cpumask sched_core_mask;
+enum sched_core_unit_type sched_core_unit __ro_after_init = SCHED_CORE_UNIT_SMT;
+
+static int __init sched_core_unit_setup(char *str)
+{
+ /* A bare "sched_core_unit" with no value arrives here as NULL. */
+ if (!str)
+ return 0;
+
+ if (!strcmp(str, "smt")) {
+ sched_core_unit = SCHED_CORE_UNIT_SMT;
+ } else if (!strcmp(str, "cluster")) {
+ sched_core_unit = SCHED_CORE_UNIT_CLUSTER;
+ } else {
+ pr_warn("sched_core_unit=%s unrecognised, using smt\n", str);
+ return 0;
+ }
+
+ pr_info("core scheduling isolation unit: %s\n", str);
+ return 0;
+}
+
+/*
+ * Parsed from start_kernel(), so the value is stable well before the first
+ * sched_core_cpu_starting() elects any rq->core leader.
+ */
+early_param("sched_core_unit", sched_core_unit_setup);
+
+static int __init sched_core_unit_check(void)
+{
+ int cpu;
+
+ if (sched_core_unit != SCHED_CORE_UNIT_CLUSTER)
+ return 0;
+
+ for_each_online_cpu(cpu) {
+ if (cpumask_weight(sched_core_isolation_mask(cpu)) > 1)
+ return 0;
+ }
+
+ pr_warn("sched_core: cluster unit spans a single CPU everywhere; no clusters reported, core scheduling unavailable\n");
+ return 0;
+}
+late_initcall(sched_core_unit_check);
+
/*
* The rq locks of a unit share one lockdep class, and a subclass per CPU
* would overflow MAX_LOCKDEP_SUBCLASSES on units wider than eight CPUs. So
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 97126c1dcb09..bc7030b4ff75 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1588,13 +1588,31 @@ cfs_prio_less(const struct task_struct *a, const struct task_struct *b, bool fi)
extern void task_vruntime_update(struct rq *rq, struct task_struct *p, bool in_fi);
+/*
+ * Which topology level core scheduling treats as its isolation unit.
+ */
+enum sched_core_unit_type {
+ SCHED_CORE_UNIT_SMT,
+ SCHED_CORE_UNIT_CLUSTER,
+};
+
+extern enum sched_core_unit_type sched_core_unit;
+
/*
* The core scheduling isolation unit: the set of CPUs that share one runqueue
* lock and that are constrained to run tasks carrying a single cookie at any
* instant.
+ *
+ * On x86 topology_cluster_cpumask() is cpu_l2c_shared_mask(), which is built
+ * from the CPUID leaf 4 L2 descriptor whenever there is more than one core per
+ * package, independently of CONFIG_SCHED_CLUSTER. So the cluster unit does not
+ * require a cluster sched domain to exist.
*/
static inline const struct cpumask *sched_core_isolation_mask(int cpu)
{
+ if (sched_core_unit == SCHED_CORE_UNIT_CLUSTER)
+ return topology_cluster_cpumask(cpu);
+
return cpu_smt_mask(cpu);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-12-03 22:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 22:13 [PATCH 0/4] sched/core: Core scheduling beyond SMT siblings Ahmed Abdelraoof
2026-12-03 22:13 ` [PATCH 1/4] sched/core: Decouple the core scheduling unit from cpu_smt_mask Ahmed Abdelraoof
2026-12-03 22:13 ` [PATCH 2/4] sched/core: Nest the isolation unit rq locks under one lock for lockdep Ahmed Abdelraoof
2026-12-03 22:13 ` [PATCH 3/4] sched/core: Gate core scheduling on the isolation unit Ahmed Abdelraoof
2026-12-03 22:13 ` [PATCH 4/4] sched/core: Support L2 cache isolation Ahmed Abdelraoof
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox