Re: [PATCH 4/8] sched/eevdf: Decay positive lag of sleeping entities
From: Peter Zijlstra
Date: Tue Sep 22 2026 - 06:08:54 EST
On Mon, Sep 21, 2026 at 05:22:34PM +0200, Vincent Guittot wrote:
> Similarly to delayed dequeue that enables an entity to decay its negative
> lag while sleeping, a task should not keep a positive lag forever.
>
> The sleep duration and the weight of the entity is used to decay the
> positive lag at wakeup.
>
> Signed-off-by: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
> ---
> kernel/sched/fair.c | 33 +++++++++++++++++++++++++++++++--
> 1 file changed, 31 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index e6eb9a4c03be..4230954d10d0 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -896,6 +896,32 @@ bool update_entity_lag(struct cfs_rq *cfs_rq, struct sched_entity *se)
> return avruntime - vlag != se->vruntime;
> }
>
> +static __always_inline
> +void decay_entity_lag(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
> +{
> + s64 vlag = se->vlag;
> + s64 delta_exec;
> +
> + WARN_ON_ONCE(se->on_rq);
> +
> + /* Negative lag implies delayed dequeue */
> + if (vlag <= 0)
> + return;
> +
> + if (flags & ENQUEUE_MIGRATED)
> + return;
Is not this a rather prevalent case?
> +
> + /* Compute the sleep time */
> + delta_exec = rq_clock_task(rq_of(cfs_rq)) - se->exec_start;
> + if (unlikely(delta_exec <= 0))
> + return;
Urgh, are we going to try and bring back all that sleep time stuff
again? ;-)
> +
> + vlag -= calc_delta_fair(delta_exec, se);
Should this not be 'W+w' at the very least?, ideally it would be the
complete sum of all decaying weight rather than just 'w', but that might
be a tad tricky.
> +
> + /* vlag can't become negative while sleeping */
> + se->vlag = max(0, vlag);
> +}
Anyway, the basic observation is that were this thing runnable, it would
have only a w/W share of runtime, not a w/w share.
Using the full fraction of sleep time like this will make the decay too
fast.
And dealing with that MIGRATED case is somewhat important; in which case
I suppose we can try and approximate by doing something like '(W1+W2)/2
+ w'.