Re: [PATCH] sched/fair: clamp rescaled vlag in reweight_entity() to bound entity_key()

From: Peter Zijlstra

Date: Thu Jun 11 2026 - 04:19:59 EST


On Wed, Jun 10, 2026 at 10:55:29AM -0400, Rik van Riel wrote:

> reweight_entity() preserves an entity's lag across a weight change by
> scaling vlag in rescale_entity():
>
> se->vlag = vl' = vl * old_weight / new_weight;
>
> and then, for an on_rq entity, recomputes:
>
> se->vruntime = avruntime - se->vlag;
>
> On a large weight decrease (w' << w) this inflates vlag without bound;
> nothing re-clamps it to the per-entity lag limit that entity_lag() and
> update_entity_lag() enforce everywhere else. The deadline is rescaled
> and re-based separately, so only vruntime drifts.

So the vlag limit is:

limit = calc_delta_fair(max_slice, se)

Right? But that is in fact:

max_slice * NICE_0_LOAD
limit = -----------------------
se->weight

Now, rescale does:

vlag * old_weight
vlag = -----------------
new_weight

So then transform the limit using that same:

max_slice * NICE_0_LOAD old_weight max_slice * NICE_0_LOAD
limit = ----------------------- * ---------- = -----------------------
old_weight new_weight new_weight

IOW, the transform totally preserves the limit. If the vlag was bound
before, it must be bound after.

What am I missing?