[PATCH 2/6 v2] sched/eevdf: Take into account current's lag when updating slice protection

From: Vincent Guittot

Date: Mon Jun 15 2026 - 12:29:33 EST


Take into account the lag of current task when setting the slice protection
in order to ensure that the absolute value of lags will remain in the
range [0 : slice+tick]
A task that already has a negative lag will see its protection reduced
whereas a task with positive lag will keep a full slice protection.

Signed-off-by: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
---
kernel/sched/fair.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 83bce5a04f3d..b8d5d9bcc014 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1083,6 +1083,7 @@ struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq)
*/
static inline void set_protect_slice(struct cfs_rq *cfs_rq, struct sched_entity *se)
{
+ u64 vruntime = min_vruntime(se->vruntime, avg_vruntime(cfs_rq));
u64 slice = normalized_sysctl_sched_base_slice;
u64 vprot = se->deadline;

@@ -1090,8 +1091,8 @@ static inline void set_protect_slice(struct cfs_rq *cfs_rq, struct sched_entity
slice = cfs_rq_min_slice(cfs_rq);

slice = min(slice, se->slice);
- if (slice != se->slice)
- vprot = min_vruntime(vprot, se->vruntime + calc_delta_fair(slice, se));
+ if (vruntime != se->vruntime || slice != se->slice)
+ vprot = min_vruntime(vprot, vruntime + calc_delta_fair(slice, se));

se->vprot = vprot;
}
@@ -1099,8 +1100,9 @@ static inline void set_protect_slice(struct cfs_rq *cfs_rq, struct sched_entity
static inline void update_protect_slice(struct cfs_rq *cfs_rq, struct sched_entity *se)
{
u64 slice = cfs_rq_min_slice(cfs_rq);
+ u64 vruntime = min_vruntime(se->vruntime, avg_vruntime(cfs_rq));

- se->vprot = min_vruntime(se->vprot, se->vruntime + calc_delta_fair(slice, se));
+ se->vprot = min_vruntime(se->vprot, vruntime + calc_delta_fair(slice, se));
}

static inline bool protect_slice(struct sched_entity *se)
--
2.43.0