Skip to content

Commit c5cd6fd

Browse files
author
Peter Zijlstra
committed
sched/fair: Fix the negative lag increase fix
Vincent reported that my rework of his original patch lost a little something. Specifically it got the return value wrong; it should not compare against the old se->vlag, but rather against the current value. Since the thing that matters is if the effective vruntime of an entity is affected and the thing needs repositioning or not. Fixes: 059258b ("sched/fair: Prevent negative lag increase during delayed dequeue") Reported-by: Vincent Guittot <vincent.guittot@linaro.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Tested-by: Vincent Guittot <vincent.guittot@linaro.org> Link: https://patch.msgid.link/20260423094107.GT3102624%40noisy.programming.kicks-ass.net
1 parent 254f496 commit c5cd6fd

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

kernel/sched/fair.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -847,13 +847,19 @@ static s64 entity_lag(struct cfs_rq *cfs_rq, struct sched_entity *se, u64 avrunt
847847
* Similarly, check that the entity didn't gain positive lag when DELAY_ZERO
848848
* is set.
849849
*
850-
* Return true if the lag has been adjusted.
850+
* Return true if the vlag has been modified. Specifically:
851+
*
852+
* se->vlag != avg_vruntime() - se->vruntime
853+
*
854+
* This can be due to clamping in entity_lag() or clamping due to
855+
* sched_delayed. Either way, when vlag is modified and the entity is
856+
* retained, the tree needs to be adjusted.
851857
*/
852858
static __always_inline
853859
bool update_entity_lag(struct cfs_rq *cfs_rq, struct sched_entity *se)
854860
{
855-
s64 vlag = entity_lag(cfs_rq, se, avg_vruntime(cfs_rq));
856-
bool ret;
861+
u64 avruntime = avg_vruntime(cfs_rq);
862+
s64 vlag = entity_lag(cfs_rq, se, avruntime);
857863

858864
WARN_ON_ONCE(!se->on_rq);
859865

@@ -863,10 +869,9 @@ bool update_entity_lag(struct cfs_rq *cfs_rq, struct sched_entity *se)
863869
if (sched_feat(DELAY_ZERO))
864870
vlag = min(vlag, 0);
865871
}
866-
ret = (vlag == se->vlag);
867872
se->vlag = vlag;
868873

869-
return ret;
874+
return avruntime - vlag != se->vruntime;
870875
}
871876

872877
/*

0 commit comments

Comments
 (0)