[PATCH sched_ext/for-7.4-fixes 0/2] sched_ext: Fix two gaps in dl_server protection against RT starvation

Hang Zhengyang via B4 Relay posted 2 patches 1 day, 17 hours ago
kernel/sched/ext/ext.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
[PATCH sched_ext/for-7.4-fixes 0/2] sched_ext: Fix two gaps in dl_server protection against RT starvation
Posted by Hang Zhengyang via B4 Relay 1 day, 17 hours ago
These patches fix two cases where a dl_server should protect tasks from
an RT task but isn't running. The starved tasks then hold up the
scheduler disable. It doesn't finish until the RT task stops.

Patch 1: in full mode, the disable attaches fair_server only at the end.
Tasks move back to fair long before that.

Patch 2: a CPU's ext_server restarts only when the first sched_ext task
is enqueued there. If it stops while tasks are still queued, nothing
restarts it.

Both came out of one stress test (scx_simple, CPU hotplug, stress-ng,
SCHED_FIFO spinners). The patches don't depend on each other.

Tested on sched_ext/for-7.4-fixes (8e156b9218f9) in an 8 vCPU KVM guest
with PREEMPT, PREEMPT_RCU and NO_HZ_FULL:

                         no patches    patch 1        patch 2   both
  patch 1 repro          37/300 stuck  0/300          -         0/300
  same, KASAN+lockdep    3/100 stuck   0/100          -         0/100
  stress, KASAN+lockdep  hung, 4 min   hung, 2-5 min  1/3 hung  6/7 ok [*]
  stress, no debug       -             2/2 ok         -         3/3 ok
  selftests              -             38 ok, 2 skip  -         38 ok, 2 skip
  messaging [**]         1.849 s       -              -         1.821 s

  Each stress run is 15 minutes.
  [*]  The 7th run stopped at 2.5 min. A fork stalled for 75 s with the
       scheduler enabled, then went on. Not the disable hang. Cause not
       found.
  [**] perf bench sched messaging -g 8 -l 1000 under scx_simple, mean of
       15 runs

With patch 2 alone, the one stress hang was the problem patch 1 fixes.

Patch 2's cost: during a scheduler reload, ext_server restarted and
stopped 238 times in 41 ms on one CPU. I also ran an RT spinner with
sched_ext tasks on the same CPU, under scx_simple and scx_central.
There, patch 2 changed neither the restart count nor the time the RT
task lost.

I didn't test on bare metal, or with other schedulers outside that cost
test. I didn't write selftests, because both hangs depend on timing.

I used Claude Code to find the issues, write the patches and run the
tests. I reran the reproducer and reviewed the patches.

---
Hang Zhengyang (2):
      sched_ext: Attach fair_server before tasks fall back to fair on disable
      sched_ext: Start ext_server on every enqueue

 kernel/sched/ext/ext.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)
---
base-commit: 8e156b9218f9f1f8b866d8e253145afdb01cf289
change-id: 20261121-scx-dlsrv-7d44ef45820e

Best regards,
-- 
Hang Zhengyang <hang.zhengyang1010@gmail.com>