Re: [PATCH 4/4] sched/fair: Revert 6d71a9c61604 ("sched/fair: Fix EEVDF entity placement bug causing scheduling lag")
From: Peter Zijlstra
Date: Mon Feb 02 2026 - 04:27:56 EST
On Mon, Feb 02, 2026 at 10:12:34AM +0100, Peter Zijlstra wrote:
> On Sat, Jan 31, 2026 at 04:21:39PM +0100, Peter Zijlstra wrote:
> > On Sat, Jan 31, 2026 at 09:47:07AM +0800, Zhang Qiao wrote:
> >
> > > > if (se->on_rq) {
> > > > /* commit outstanding execution time */
> > > > update_curr(cfs_rq);
> > > > - update_entity_lag(cfs_rq, se);
> > > > - se->deadline -= se->vruntime;
> > > > + avruntime = avg_vruntime(cfs_rq);
> > > > + se->vlag = entity_lag(avruntime, se);
> > >
> > >
> > > vlag is updated here. Considering vlag and vprot share the same union, updating
> > > vlag will overwrite vprot. Is it right to call protect_slice() (which use vprot)
> > > after this update?
> >
> > Oh you are quite right; I'm sure Ingo had a patch removing that union,
> > but clearly that's not been merged yet.
> >
> > Sorry about that mistake; I'll make a new version on Monday.
>
> After looking at things, I think the best option is to simply remove
> that union.
>
> The thing is, I can fix reweight to respect this union, but there are
> more problems, notably the sched_change pattern will not only call
> put_prev_task/set_next_task, it will actually dequeue/enqueue the thing
> and therefore 'temporarily' use the vlag field, destroying the vprot
> value.
>
> And yes, we can fix all that, but I'm thinking that at that point the
> union is more trouble than its worth.
>
And its already gone -- I managed to consistently look at the wrong
tree. So all should be good.
---
commit 80390ead2080071cbd6f427ff8deb94d10a4a50f
Author: Ingo Molnar <mingo@xxxxxxxxxx>
Date: Wed Nov 26 05:31:28 2025 +0100
sched/fair: Separate se->vlag from se->vprot
There's no real space concerns here and keeping these fields
in a union makes reading (and tracing) the scheduler code harder.
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
Link: https://patch.msgid.link/20251201064647.1851919-4-mingo@xxxxxxxxxx
diff --git a/include/linux/sched.h b/include/linux/sched.h
index d395f2810fac..bf96a7d595e2 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -586,15 +586,10 @@ struct sched_entity {
u64 sum_exec_runtime;
u64 prev_sum_exec_runtime;
u64 vruntime;
- union {
- /*
- * When !@on_rq this field is vlag.
- * When cfs_rq->curr == se (which implies @on_rq)
- * this field is vprot. See protect_slice().
- */
- s64 vlag;
- u64 vprot;
- };
+ /* Approximated virtual lag: */
+ s64 vlag;
+ /* 'Protected' deadline, to give out minimum quantums: */
+ u64 vprot;
u64 slice;
u64 nr_migrations;