[PATCH v2 3/5] sched/eevdf: Cap protection when current has the shortest slice
From: Christian Loehle
Date: Thu Oct 01 2026 - 09:51:32 EST
Changing a task slice preserves its remaining request. With
PLACE_REL_DEADLINE, the deadline can therefore extend beyond the new
slice after sched_setattr() reduces it.
The protection calculation starts from that deadline for a fresh grant,
or from the existing boundary for an update. It only applies the slice
cap when another entity has a shorter slice. If current itself has the
shortest slice, protection can remain live for the remainder of the old
request.
Apply the slice bound for both fresh grants and updates, including when it
is current's own slice. Keep the earlier ineligibility boundary for the
PREEMPT_SHORT case when a shorter slice is competing.
Fixes: 82e9d0456e06 ("sched/fair: Avoid re-setting virtual deadline on 'migrations'")
Signed-off-by: Christian Loehle <christian.loehle@xxxxxxx>
---
kernel/sched/fair.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 3f881ded5457..15fa967273f6 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1134,15 +1134,13 @@ static inline void set_protect_slice(struct cfs_rq *cfs_rq, struct sched_entity
if (sched_feat(RUN_TO_PARITY))
slice = cfs_rq_min_slice(cfs_rq);
- if (!update)
- slice = min(slice, se->slice);
+ slice = min(slice, se->slice);
+ /* A preserved deadline can extend beyond the current slice. */
+ vprot = min_vruntime(vprot, vruntime + calc_delta_fair(slice, se));
/* If there are shorter slices than se's one */
- if (update || slice != se->slice) {
- vprot = min_vruntime(vprot, vruntime + calc_delta_fair(slice, se));
- if (sched_feat(PREEMPT_SHORT) && slice != se->slice)
- vprot = min_vruntime(vprot, ineligible_vruntime(cfs_rq));
- }
+ if (sched_feat(PREEMPT_SHORT) && slice != se->slice)
+ vprot = min_vruntime(vprot, ineligible_vruntime(cfs_rq));
se->vprot = vprot;
}
--
2.34.1