[RFC PATCH sched_ext/for-7.2 0/10] sched: Make proxy execution compatible with sched_ext
From: Andrea Righi
Date: Wed May 06 2026 - 13:47:16 EST
This series enables using proxy execution with sched_ext and is based on early
work by John Stultz [1].
Background
==========
Proxy execution (proxy-exec) lets a waiting task ("donor") donate its execution
context to a mutex owner, so the owner can run while the donor stays eligible on
the runqueue.
Currently, proxy execution and sched_ext are mutually exclusive at build time:
we can't enable CONFIG_SCHED_PROXY_EXEC=y and CONFIG_SCHED_CLASS_EXT=y in the
same kernel.
This restriction can be problematic for Linux distributions and for anyone who
wants to ship one kernel and choose features at runtime.
Why they are mutually exclusive?
================================
sched_ext schedulers drive dispatch through their own interfaces. A proxy-exec
handoff can run a task that the BPF scheduler never dispatched through that
path. sched_ext callbacks then observe a "current" task that does not match what
the BPF side considers running, so kfuncs and helper state can see an
inconsistent view of the executing task.
sched_ext also tracks runnable work through Dispatch Queues (DSQs) and BPF
chosen dispatch rules, while the core scheduler still maintains classic per-CPU
runqueues and pick paths. A proxy handoff can therefore switch the CPU to a task
that the BPF scheduler never inserted or ordered through its DSQ interface.
DSQ state, vtime, and "who is running" bookkeeping inside the BPF program can
then disagree with what the core actually executes, so helpers and kfuncs that
assume their dispatched task is current may observe stale or inconsistent state.
Default behaviour when sched_ext is in use
==========================================
The series relaxes the Kconfig coupling, but keeps proxy-exec context donation
off by default whenever a sched_ext scheduler is loaded: mutex-blocked
tasks are forced to block instead of staying as donors, and the pick path skips
proxy selection; leftover handoff state is cleared so mutex retry paths do not
trip blocked_on consistency checks.
Users who accept the semantic mismatch for their BPF scheduler can opt in at
boot:
sched_proxy_exec_scx=0|1 (default 0)
Setting 1 allows donor->owner context switches under sched_ext as well.
This enables Linux distributions to set CONFIG_SCHED_PROXY_EXEC and
CONFIG_SCHED_CLASS_EXT together and ship kernels capable of supporting both
features.
Then users can decide, via sched_proxy_exec and sched_proxy_exec_scx, whether to
enable proxy-exec alongside sched_ext, use sched_ext without proxy-exec, or
disable proxy-exec entirely.
References
==========
[1] https://lore.kernel.org/all/20251206001451.1418225-1-jstultz@xxxxxxxxxx
Git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arighi/linux.git scx-proxy-exec
Andrea Righi (8):
sched/core: Skip migration disabled tasks in proxy execution
sched/core: Skip put_prev_task/set_next_task re-entry for sched_ext donors
sched_ext: Fix TOCTOU race in consume_remote_task()
sched_ext: Fix ops.running/stopping() pairing for proxy-exec donors
sched_ext: Save/restore kf_tasks[] when task ops nest
sched_ext: Skip ops.runnable() when nested in SCX_CALL_OP_TASK
sched/core: Disable proxy-exec context switch under sched_ext by default
sched: Allow enabling proxy exec with sched_ext
John Stultz (2):
sched/ext: Split curr|donor references properly
sched/ext: Avoid migrating blocked tasks with proxy execution
Documentation/admin-guide/kernel-parameters.txt | 6 ++
include/linux/sched/ext.h | 9 ++
init/Kconfig | 2 -
kernel/sched/core.c | 78 ++++++++++++--
kernel/sched/ext.c | 138 ++++++++++++++++++------
5 files changed, 193 insertions(+), 40 deletions(-)