[PATCH v2 0/2] sched_ext, sched/fair: Drain blocked fair load on scx_switched_all
From: Peng Huang
Date: Mon Nov 23 2026 - 15:13:59 EST
v1 [1] skipped rq->cfs.avg.util_sum in update_idle_rq_clock_pelt() when
scx_switched_all() was active. As Vincent Guittot pointed out, that hid
the underlying issue: once all fair tasks switch to sched_ext, fair
blocked load should be properly drained and propagated rather than left
stale in rq->cfs.avg.
Investigating why rq->cfs.avg.util_sum remained non-zero showed two
causes:
1. In update_tg_cfs_{util,runnable,load}(), if the group entity @se's
_avg had already decayed to 0 while its _sum still held a sub-divider
residual when the child gcfs_rq's _avg also reached 0, delta_avg == 0
caused an early return without clearing @se's residual _sum from the
parent cfs_rq.
2. Tasks that exited or migrated while sleeping before scx_enable()
leave deferred removals in cfs_rq->removed, and switched_from_fair()
only visits cfs_rq chains with live fair tasks. Once
__scx_switched_all is enabled, periodic blocked-load updates stop,
stranding unvisited leaf cfs_rqs in rq->cfs.avg.
Patch 1 clears residual task-group _sum values on zero-avg propagation
while keeping parent period_contrib divider scaling for non-zero
averages. Patch 2 reuses __sched_balance_update_blocked_averages() in
scx_enable()'s per-CPU scx_switched_all() loop to drain cfs_rq->removed
and propagate blocked averages across all leaf cfs_rqs.
Changes in v2:
- Drop the pelt.h workaround from v1 (Vincent Guittot).
- Clear residual sums in update_tg_cfs_{util,runnable,load}() when
propagating a zero average (Vincent Guittot).
- Reuse __sched_balance_update_blocked_averages() in scx_enable() under
scx_switched_all() to drain remaining blocked fair load (Vincent
Guittot).
[1] https://lore.kernel.org/r/20261122015729.2512645-1-penghuang@xxxxxxxxxx
Peng Huang (2):
sched/fair: Clear residual sums on zero task-group avg propagation
sched_ext, sched/fair: Drain blocked load on scx_switched_all
kernel/sched/ext/ext.c | 9 ++++-----
kernel/sched/fair.c | 42 +++++++++++++++++++++++++++++++++---------
kernel/sched/sched.h | 1 +
3 files changed, 38 insertions(+), 14 deletions(-)
--
2.56.1.831.g720f3f5937-goog