Re: [PATCH v2] sched: fair: Prevent negative lag increase during delayed dequeue

Peter Zijlstra
2026-04-22T22:20:54Z

On Wed, Apr 22, 2026 at 04:28:28PM +0200, Peter Zijlstra wrote:

> Let me ponder this a bit...

Like this? Or am I still making a mess of things? AFAICT this is the
exact same as your initial version.

---
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 69361c63353a..24e8c78b110a 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -847,13 +847,13 @@ static s64 entity_lag(struct cfs_rq *cfs_rq, struct sched_entity *se, u64 avrunt
* Similarly, check that the entity didn't gain positive lag when DELAY_ZERO
* is set.
*
- * Return true if the lag has been adjusted.
+ * Return true if the lag of a delayed entity has been adjusted.
*/
static __always_inline
bool update_entity_lag(struct cfs_rq *cfs_rq, struct sched_entity *se)
{
s64 vlag = entity_lag(cfs_rq, se, avg_vruntime(cfs_rq));
- bool ret;
+ bool ret = false;

WARN_ON_ONCE(!se->on_rq);

@@ -862,8 +862,9 @@ bool update_entity_lag(struct cfs_rq *cfs_rq, struct sched_entity *se)
vlag = max(vlag, se->vlag);
if (sched_feat(DELAY_ZERO))
vlag = min(vlag, 0);
+
+ ret = (vlag != se->vlag);
}
- ret = (vlag == se->vlag);
se->vlag = vlag;

return ret;