From: Andrea Righi <arighi@nvidia.com>
To: Peter Zijlstra <peterz@infradead.org>, Tejun Heo <tj@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
John Stultz <jstultz@google.com>,
David Vernet <void@manifault.com>,
Changwoo Min <changwoo@igalia.com>, Tao Cui <cuitao@kylinos.cn>,
sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCHSET sched_ext/for-7.5] sched/proxy: Handle retained donors on scheduling class transitions
Date: Thu, 26 Nov 2026 12:13:56 +0100 [thread overview]
Message-ID: <20261126111649.208476-1-arighi@nvidia.com> (raw)
Proxy execution keeps mutex-blocked donors on the runqueue. A BPF
scheduler with SCX_OPS_ENQ_BLOCKED admits donors that block while it
owns them, but sched_ext is not currently designed to pass it donors
retained elsewhere, regardless of SCX_OPS_ENQ_BLOCKED. To enforce this,
explicit hooks at the entry points into sched_ext block a retained donor
before sched_change_begin() records its queued state.
Tao Cui reported [1] that rt_mutex_setprio() has no such hook: an EXT
task that is PI-boosted into RT/DL and blocks on a second mutex while
boosted is retained by RT/DL, and when the boost goes away it is handed
back to sched_ext as a queued blocked donor that the BPF scheduler never
admitted.
The same can happen in __sched_setscheduler(). It calls
scx_prepare_setscheduler() to block a retained donor, but only when the
requested policy is SCHED_EXT. When the BPF scheduler takes over all
tasks (no SCX_OPS_SWITCH_PARTIAL), switching an RT/DL task to
SCHED_NORMAL, e.g., via sched_setscheduler(2) or sysrq-n, also moves it
into EXT without blocking the donor. In both cases, a BPF scheduler
without SCX_OPS_ENQ_BLOCKED receives a queued blocked donor it never
admitted: the donor is enqueued without SCX_ENQ_BLOCKED and, once
picked, proxy execution runs the mutex owner on its behalf, even though
the BPF scheduler opted out of it.
As suggested by Peter [2], instead of adding more hooks, let the
incoming class decide: switching_to() now returns whether the class
accepts a retained proxy donor, and sched_change_end() blocks the task
when it doesn't. This handles every class transition into sched_ext,
including PI deboost, and replaces the existing explicit hooks.
Moreover, moving a task between BPF schedulers (sub-sched enable,
rehome, punt) doesn't change its sched_class, so switching_to() doesn't
run there. Rather than keeping a separate hook for these paths, make
SCX_OPS_ENQ_BLOCKED a property of the whole hierarchy: a sub-scheduler
must match the root scheduler's setting or it fails to load, as also
suggested by Peter [3]. This makes the remaining scx-specific donor
blocking, and sched_proxy_block_task(), unnecessary.
Behavior change: a BPF scheduler with SCX_OPS_ENQ_BLOCKED now inherits
retained donors on class entry instead of having them blocked. A queued
donor is passed to ops.enqueue() with SCX_ENQ_BLOCKED as soon as the
scheduler isn't bypassing. The current donor, like any running task
entering sched_ext, keeps running without going through ops.enqueue(),
and gets SCX_ENQ_BLOCKED the next time it does.
Git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arighi/linux.git scx-proxy-donors
Peter, should we route this through the sched_ext tree or would you
prefer that I rebase it onto tip/sched/core?
Thanks,
-Andrea
[1] https://lore.kernel.org/r/20261112144935.583937-3-cui.tao@linux.dev
[2] https://lore.kernel.org/r/20261112160136.GF1922751@noisy.programming.kicks-ass.net
[3] https://lore.kernel.org/r/20261112164149.GE1813469@noisy.programming.kicks-ass.net
Andrea Righi (4):
sched: Let switching_to() decide whether to keep a retained proxy donor
sched_ext: Make SCX_OPS_ENQ_BLOCKED a hierarchy-wide setting
sched: Remove sched_proxy_block_task()
selftests/sched_ext: Check that blocked donors are never enqueued unadmitted
kernel/sched/core.c | 118 ++++++++++++++-------
kernel/sched/ext/ext.c | 78 +++++---------
kernel/sched/ext/ext.h | 2 -
kernel/sched/ext/internal.h | 4 +-
kernel/sched/ext/sub.c | 12 +--
kernel/sched/idle.c | 2 +-
kernel/sched/sched.h | 16 +--
kernel/sched/stop_task.c | 2 +-
kernel/sched/syscalls.c | 2 -
tools/sched_ext/include/scx/enum_defs.autogen.h | 1 -
tools/sched_ext/include/scx/enums_abi.autogen.h | 1 -
tools/sched_ext/scx_qmap.c | 2 +-
.../testing/selftests/sched_ext/enq_blocked.bpf.c | 9 ++
tools/testing/selftests/sched_ext/enq_blocked.c | 18 +++-
14 files changed, 149 insertions(+), 118 deletions(-)
next reply other threads:[~2026-11-26 11:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 11:13 Andrea Righi [this message]
2026-11-26 11:13 ` [PATCH 1/4] sched: Let switching_to() decide whether to keep a retained proxy donor Andrea Righi
2026-11-26 16:01 ` Peter Zijlstra
2026-11-26 11:13 ` [PATCH 2/4] sched_ext: Make SCX_OPS_ENQ_BLOCKED a hierarchy-wide setting Andrea Righi
2026-11-26 11:13 ` [PATCH 3/4] sched: Remove sched_proxy_block_task() Andrea Righi
2026-11-26 11:14 ` [PATCH 4/4] selftests/sched_ext: Check that blocked donors are never enqueued unadmitted Andrea Righi
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=20261126111649.208476-1-arighi@nvidia.com \
--to=arighi@nvidia.com \
--cc=bsegall@google.com \
--cc=changwoo@igalia.com \
--cc=cuitao@kylinos.cn \
--cc=dietmar.eggemann@arm.com \
--cc=jstultz@google.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sched-ext@lists.linux.dev \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=void@manifault.com \
--cc=vschneid@redhat.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®