Re: [PATCH] sched/pelt: Skip dormant cfs util_sum under scx_switched_all

From: Tejun Heo

Date: Mon Nov 23 2026 - 18:48:56 EST


Hello, Peng.

On Mon, Nov 23, 2026 at 08:09:34AM -0800, Peng Huang wrote:
> For v2, rather than touching update_idle_rq_clock_pelt(), how about
> adding a fair helper (similar in spirit to rq_offline_fair() ->
> clear_tg_offline_cfs_rqs()) and calling it from scx_enable() in the
> existing per-CPU scx_switched_all() loop (where rq->lock is held,
> rq->clock is updated, and rq->cfs.h_nr_queued == 0)? Specifically, it
> would walk leaf_cfs_rq_list bottom-up (plus &rq->cfs) to:
> - flush cfs_rq->removed,
> - clear load/runnable/util _sum and _avg on the empty cfs_rqs and
> their tg_ses while preserving last_update_time and period_contrib,
> - clear tg contributions via clear_tg_load_avg(), remove the empty
> cfs_rqs from leaf_cfs_rq_list, and update rq->has_blocked_load.

I'm not familiar with this code, so I may be missing something, but
doesn't __update_blocked_fair() already do most of this? It walks
leaf_cfs_rq_list bottom-up, flushes cfs_rq->removed and propagates the
result to the parent. It just stops running once scx_switched_all() is
set. Maybe the helper can run the blocked load update once on each rq
from that loop instead of open-coding the clearing? If I'm reading it
right, one pass after all the tasks have switched would take care of #1.

As for #2, are the leftover sums big enough to matter for
update_idle_rq_clock_pelt()? It looks like fair can leave similar
leftovers behind once the avgs reach zero.

Thanks.

--
tejun