From: Kuba Piecuch <jpiecuch@google.com>
To: Tejun Heo <tj@kernel.org>, David Vernet <void@manifault.com>,
Andrea Righi <arighi@nvidia.com>,
Changwoo Min <changwoo@igalia.com>
Cc: Kuba Piecuch <jpiecuch@google.com>,
sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] sched_ext: Enforce SCX_CAP_BASE in core-sched task selection
Date: Thu, 26 Nov 2026 21:33:29 +0000 [thread overview]
Message-ID: <20261126213212.3930589-2-jpiecuch@google.com> (raw)
In-Reply-To: <20261126213212.3930589-1-jpiecuch@google.com>
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@vger.kernel.org # v7.3+
Signed-off-by: Kuba Piecuch <jpiecuch@google.com>
---
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
next prev parent reply other threads:[~2026-11-26 21:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 21:33 [PATCHSET sched_ext/for-7.4-fixes] " Kuba Piecuch
2026-11-26 21:33 ` Kuba Piecuch [this message]
2026-11-26 21:33 ` [PATCH 2/2] selftests/sched_ext: Add sub_core_caps test for core-sched SCX_CAP_BASE Kuba Piecuch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261126213212.3930589-2-jpiecuch@google.com \
--to=jpiecuch@google.com \
--cc=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sched-ext@lists.linux.dev \
--cc=tj@kernel.org \
--cc=void@manifault.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®