Re: [PATCH] sched/fair: Fix h_nr_runnable leak in dequeue_hierarchy()
From: Alexey Charkov
Date: Mon Nov 23 2026 - 08:52:46 EST
On Mon, Nov 23, 2026 at 4:12 AM Prabhakar <prabhakar.csengg@xxxxxxxxx> wrote:
>
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@xxxxxxxxxxxxxx>
>
> Commit 486c3d06b902 ("sched/fair: Avoid transient double accounting
> for delayed tasks") changed the h_nr_runnable logic in
> dequeue_hierarchy() from "set to 1 unless delayed" to "set to 0 if
> delayed", but left the initialiser at 0:
>
> int h_nr_runnable = 0;
> ...
> if (se->sched_delayed)
> h_nr_runnable = 0;
>
> h_nr_runnable is therefore always 0, so dequeuing a task that is not
> delayed no longer decrements cfs_rq->h_nr_runnable. The count only
> grows, which inflates se->runnable_weight and skews PELT runnable_avg
> and load balancing.
>
> Initialise h_nr_runnable to 1 so that only delayed tasks, which
> set_delayed() has already accounted for, skip the decrement.
>
> Fixes: 486c3d06b902 ("sched/fair: Avoid transient double accounting for delayed tasks")
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@xxxxxxxxxxxxxx>
Thanks a lot for the fix! The offending commit forced my RK3576 board
to keep its little CPU cluster pinned at the top frequency even when
completely idle, and with your change applied it's now back to normal.
Tested-by: Alexey Charkov <alchark@xxxxxxxxxxx>
Best regards,
Alexey