Skip to content

sched_ext, sched/fair: Drain blocked fair load on scx_switched_all

Peng Huang lkml sched-ext stable 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest2 patches 0 repliesNew

Changes in v2 from the cover letter

- 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/[email protected]

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2sched/fair: Clear residual sums on zero task-group avg propagationkernel/sched/fair.c+27 -80 replies
2/2sched_ext, sched/fair: Drain blocked load on scx_switched_allkernel/sched/ext/ext.c kernel/sched/fair.c kernel/sched/sched.h+11 -60 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/2] sched_ext, sched/fair: Drain blocked fair load on scx_switched_all

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/[email protected]

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(-)
Signature · 1 line
2.56.1.831.g720f3f5937-goog