Re: [PATCH 04/20 v3] sched/eevdf: Reset lag when waking up on idle cpu

From: Kayra Cizmeci

Date: Fri Nov 06 2026 - 13:41:26 EST


On Fri, Nov 06, 2026 at 04:19:31PM +0100, Vincent Guittot wrote:
> When several tasks wake up simultaneously on an idle CPU but their prev
> CPUs were not idle, their final vlag will depend on the enqueue ordering
> as the first one will lose its lag but not the next ones.
>
> Reset the lag during the enqueue if no fair task has already been picked
> and set as the running task.
>
> As a typical example:
> - CPU0 is idle
> - TA with vlag 0ms and TB with vlag 5ms wake up on CPU0 simultaneously.
>
> Depending which task grabs the lock 1st, the behavior will be different:
> - If TA is enqueued 1st, TB will be enqueued with a positive lag and will
> be picked 1st.
> - If TB is enqueued 1st, it will lose its positive vlag and both TA and
> TB will have 0 vlag when eevdf picks next task.
>
> Signed-off-by: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
> ---
> kernel/sched/fair.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 945de0215abb..6ce4162a7703 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -967,6 +967,14 @@ void decay_entity_lag(struct cfs_rq *cfs_rq, struct task_struct *p, int flags)
> if (vlag <= 0)
> return;
>
> + rq = rq_of(cfs_rq);
> +
> + /* You can't claim any lag when waking on idle CPU */
> + if (rq->curr == rq->idle) {
> + se->vlag = 0;
> + return;
> + }
> +
> /* No fast access to prev rq task clock */
> if (flags & ENQUEUE_MIGRATED)
> return;
> @@ -977,8 +985,6 @@ void decay_entity_lag(struct cfs_rq *cfs_rq, struct task_struct *p, int flags)
> return;
> }
>
> - rq = rq_of(cfs_rq);
> -
> /* Compute sleep time */
> delta_exec = rq_clock_task(rq) - se->exec_start;
> if (unlikely(delta_exec <= 0))
> --
> 2.53.0
>


LGTM.

Reviewed-by: Kayra Cizmeci <kayracizmeci@xxxxxxxxx>


Cheers,

Kayra