Re: [PATCH 0/4] sched: Various reweight_entity() fixes

From: K Prateek Nayak

Date: Tue Feb 10 2026 - 00:16:47 EST


Hello Peter,

On 2/9/2026 9:17 PM, Peter Zijlstra wrote:
> I ended up with the below; and I've already pushed out a fresh
> queue/sched/core. Could you please test again?

I haven't seen any "sum_shifts" turning non-zero on the overnight runs,
even with the larger workloads, so feel free to include:

Tested-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>

The overall patch looks good. I only have couple of cosmetic nits
inlined below:

[..snip..]

> u64 avg_vruntime(struct cfs_rq *cfs_rq)
> {
> struct sched_entity *curr = cfs_rq->curr;
> - s64 avg = cfs_rq->sum_w_vruntime;
> - long load = cfs_rq->sum_weight;
> + s64 delta = 0, runtime = cfs_rq->sum_w_vruntime;

nit.

"runtime" is only ever used in "weight" != 0 case so perhaps it can be
moved there to preserve the reverse x-mas (or this whole line can be
moved up top).

> + long weight = cfs_rq->sum_weight;
>
> - if (curr && curr->on_rq) {
> - unsigned long weight = scale_load_down(curr->load.weight);
> + if (curr && !curr->on_rq)
> + curr = NULL;
>
> - avg += entity_key(cfs_rq, curr) * weight;
> - load += weight;
> - }
> + if (weight) {
> + if (curr) {
> + unsigned long w = scale_load_down(curr->load.weight);
> +
> + runtime += entity_key(cfs_rq, curr) * w;
> + weight += w;
> + }
>
> - if (load) {
> /* sign flips effective floor / ceiling */
> - if (avg < 0)
> - avg -= (load - 1);
> - avg = div_s64(avg, load);
> + if (runtime < 0)
> + runtime -= (weight - 1);
> +
> + delta = div_s64(runtime, weight);
> +

nit. Is this empty line necessary?

> + } else if (curr) {
> + /*
> + * When there is but one element, it is the average.
> + */
> + delta = curr->vruntime - cfs_rq->zero_vruntime;
> }
>
> - return cfs_rq->zero_vruntime + avg;
> + update_zero_vruntime(cfs_rq, delta);
> +
> + return cfs_rq->zero_vruntime;
> }
>
> /*

--
Thanks and Regards,
Prateek