[PATCH 1/2] sched_ext: Enforce SCX_CAP_BASE in core-sched task selection

From: Kuba Piecuch

Date: Thu Nov 26 2026 - 16:33:38 EST


Under CONFIG_EXT_SUB_SCHED, a sub-scheduler is only allowed to run tasks
on CPUs where it holds SCX_CAP_BASE (apart from migration-disabled tasks
and a task admitted as rq->scx.rescue.curr). The sched_ext dispatch path
enforces this via scx_task_can_stay_on_cpu() and scx_rescuee().

However, ext_sched_class leaves .task_is_throttled NULL. Under
CONFIG_SCHED_CORE, pick_next_task() calls sched_core_find() on sibling
runqueues and sched_core_balance() calls try_steal_cookie() across CPUs,
both of which select directly from rq->core_tree and rely on
sched_task_is_throttled() to filter ineligible tasks before bypassing
pick_task_scx(). With .task_is_throttled unset, a sub-scheduler task
sharing a core-scheduling cookie with a sibling can be picked by
sched_core_find() or stolen by try_steal_cookie() onto a CPU where its
sub-scheduler lacks SCX_CAP_BASE, running without ops.dispatch() and
bypassing sub-scheduler CPU isolation.

Implement task_is_throttled_scx() under CONFIG_SCHED_CORE, returning true
when !scx_task_can_stay_on_cpu(rq, p) && p != scx_rescuee(rq), and wire
it to ext_sched_class.task_is_throttled. Both callers hold cpu_rq(cpu)'s
lock, and scx_task_can_stay_on_cpu() already fast-paths !scx_has_subs()
(and CONFIG_EXT_SUB_SCHED=n), allows local migration-disabled tasks, and
resolves bypass via scx_exec_sched().

Fixes: 46a85ae6fe5b ("sched_ext: Tie cpu occupancy to SCX_CAP_BASE through the task slice")
Cc: stable@xxxxxxxxxxxxxxx # v7.3+
Signed-off-by: Kuba Piecuch <jpiecuch@xxxxxxxxxx>
---
kernel/sched/ext/ext.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index 3a69100e47f7..a4a93ed97f7b 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -4261,6 +4261,13 @@ bool scx_prio_less(const struct task_struct *a, const struct task_struct *b,

return time_after(a->scx.runnable_at, b->scx.runnable_at);
}
+
+static int task_is_throttled_scx(struct task_struct *p, int cpu)
+{
+ struct rq *rq = cpu_rq(cpu);
+
+ return !scx_task_can_stay_on_cpu(rq, p) && p != scx_rescuee(rq);
+}
#endif /* CONFIG_SCHED_CORE */

static int select_task_rq_scx(struct task_struct *p, int prev_cpu, int wake_flags)
@@ -5959,6 +5966,10 @@ DEFINE_SCHED_CLASS(ext) = {

.update_curr = update_curr_scx,

+#ifdef CONFIG_SCHED_CORE
+ .task_is_throttled = task_is_throttled_scx,
+#endif
+
#ifdef CONFIG_UCLAMP_TASK
.uclamp_enabled = 1,
#endif
--
2.56.1.839.g22a8290db9-goog