[PATCHSET sched_ext/for-7.3-fixes] sched_ext: Fix keep-last for sub-scheduler tasks and two scx_qmap placement loops

From: Tejun Heo

Date: Sat Sep 05 2026 - 12:11:14 EST


Hello,

Running scx_qmap as a sub-scheduler under scx_nitosis exposed a kernel bug
and two scx_qmap bugs:

- dispatch_one() decides whether to keep running @prev by testing the root
scheduler's SCX_OPS_ENQ_LAST and bypass state. Those are properties of
@prev's own scheduler, and put_prev_task_scx() acts on that scheduler.
When the root sets the flag and @prev belongs to a sub-scheduler that
doesn't, the task is not kept and is enqueued with SCX_ENQ_LAST to a
scheduler that never opted in. This trips the WARN_ON_ONCE in
put_prev_task_scx(), and the task is queued without a follow-up scheduling
event, which can stall it. Patches 1-2 fix this.

- scx_qmap added SCX_ENQ_IMMED to its rescue inserts, which turns a rescue
request into a regular placement on a time-shared cid and loops with the
kernel's REENQ bounce until the reenqueue limit ejects the scheduler.
Patch 3 fixes this.

- scx_qmap placed tasks from the delegation split alone, ahead of the caps
in effect on the cpus, so highpri moves to a freshly granted cid were
denied and bounced. Patch 4 fixes this.

This patchset contains the following four patches:

0001 sched_ext: Rename sch to root_sch in dispatch_one()
0002 sched_ext: Use @prev's scheduler for the keep decisions in dispatch_one()
0003 sched_ext: scx_qmap: Do not add IMMED to rescue inserts
0004 sched_ext: scx_qmap: Place only on cids whose caps are in effect

0001-0002 fix the kernel side. 0003-0004 fix scx_qmap.

The patchset is based on sched_ext/for-7.3-fixes (0a85182723b6) and is also
available in the following git branch:

git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git sub-keep-last-rescue

diffstat follows. Thanks.

kernel/sched/ext/ext.c | 33 ++++++++------
tools/sched_ext/scx_qmap.bpf.c | 101 ++++++++++++++++++++++++++++++-----------
tools/sched_ext/scx_qmap.h | 3 ++
3 files changed, 97 insertions(+), 40 deletions(-)

--
tejun