[PATCHSET sched_ext/for-7.4-fixes] sched_ext: Enforce SCX_CAP_BASE in core-sched task selection

From: Kuba Piecuch

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


Under CONFIG_EXT_SUB_SCHED, sched_ext enforces SCX_CAP_BASE on the
dispatch path via scx_task_can_stay_on_cpu() and scx_rescuee(). However,
ext_sched_class leaves .task_is_throttled unset. Under CONFIG_SCHED_CORE,
sched_core_find() and try_steal_cookie() select tasks directly from
rq->core_tree and rely on sched_task_is_throttled() to filter ineligible
tasks before bypassing pick_task_scx(). As a result, a sub-scheduler task
sharing a core-scheduling cookie with an SMT sibling can be picked or
stolen onto a CPU where its sub-scheduler lacks SCX_CAP_BASE.

Patch 1 implements task_is_throttled_scx() under CONFIG_SCHED_CORE and
wires it to ext_sched_class.task_is_throttled.

Patch 2 adds the sub_core_caps selftest exercising a cid-form root
scheduler and child sub-scheduler on an SMT pair, verifying that a
cookie-matching sub-scheduler task is not picked on a denied sibling and
runs once SCX_CAP_BASE is granted. It requires CONFIG_SCHED_CORE=y (not
enabled by default in tools/testing/selftests/sched_ext/config) and an
SMT pair plus a third CPU. Without patch 1, the selftest fails with:

ERR: sub_core_caps.c:534
Sub task ran on denied CPU 1 via core-sched (run=6 deq_cse=6)

The patches were written with the help of an AI coding assistant. I have
reviewed the patches and verified the tests run by the tool.

Kuba Piecuch (2):
sched_ext: Enforce SCX_CAP_BASE in core-sched task selection
selftests/sched_ext: Add sub_core_caps test for core-sched
SCX_CAP_BASE

kernel/sched/ext/ext.c | 11 +
tools/testing/selftests/sched_ext/Makefile | 1 +
.../selftests/sched_ext/sub_core_caps.c | 616 ++++++++++++++++++
.../sched_ext/sub_core_caps_root.bpf.c | 78 +++
.../sched_ext/sub_core_caps_sub.bpf.c | 84 +++
5 files changed, 790 insertions(+)
create mode 100644 tools/testing/selftests/sched_ext/sub_core_caps.c
create mode 100644 tools/testing/selftests/sched_ext/sub_core_caps_root.bpf.c
create mode 100644 tools/testing/selftests/sched_ext/sub_core_caps_sub.bpf.c


base-commit: 0919f8bea37e7e354b342c2dff52dd8f5b958d6a
--
2.56.1.839.g22a8290db9-goog