Re: [PATCH 1/3] sched/fair: Exclude delayed-dequeued tasks from sum_nr_running
From: Peter Zijlstra
Date: Fri Nov 20 2026 - 05:55:10 EST
On Fri, Nov 20, 2026 at 07:19:48AM +0530, Srikar Dronamraju wrote:
> Delayed dequeue keeps a sleeping task on the CFS runqueue until its
> accumulated lag is repaid. While such tasks remain accounted in
> rq->nr_running, they are no longer runnable and are not eligible to
> consume CPU time.
>
> update_sg_lb_stats() currently uses rq->nr_running when computing
> sum_nr_running. As a result, delayed-dequeued tasks contribute to group
> load statistics even though they are effectively sleeping. This can
> inflate the apparent load of a group and influence load balancing
> decisions.
>
> Other metrics collected by update_sg_lb_stats(), such as group_runnable
> and h_nr_runnable, already focus on runnable work. Counting delayed
> entities in sum_nr_running makes it inconsistent with the rest of the
> load-balancing statistics.
>
> Exclude cfs_h_nr_delayed() tasks from sum_nr_running so that load
> balancing decisions are based on runnable tasks rather than entities
> waiting to complete delayed dequeue accounting.
>
> Signed-off-by: Srikar Dronamraju <srikar@xxxxxxxxxxxxx>
> ---
> kernel/sched/fair.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index d4cc0caee626..21f2b17894e3 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -12296,7 +12296,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,
> sgs->group_runnable += cpu_runnable(rq);
> sgs->sum_h_nr_running += rq->cfs.h_nr_runnable;
>
> - nr_running = rq->nr_running;
> + nr_running = rq->nr_running - cfs_h_nr_delayed(rq);
h_nr_runnable already excludes delayed; its is h_nr_queued that includes
it.