Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 059258b0d424 ("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

+10 -5
+10 -5
kernel/sched/fair.c
··· 847 847 * Similarly, check that the entity didn't gain positive lag when DELAY_ZERO 848 848 * is set. 849 849 * 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. 851 857 */ 852 858 static __always_inline 853 859 bool update_entity_lag(struct cfs_rq *cfs_rq, struct sched_entity *se) 854 860 { 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); 857 863 858 864 WARN_ON_ONCE(!se->on_rq); 859 865 ··· 869 863 if (sched_feat(DELAY_ZERO)) 870 864 vlag = min(vlag, 0); 871 865 } 872 - ret = (vlag == se->vlag); 873 866 se->vlag = vlag; 874 867 875 - return ret; 868 + return avruntime - vlag != se->vruntime; 876 869 } 877 870 878 871 /*