[PATCH v2 5/5] sched/eevdf: Update protection after restoring current
From: Christian Loehle
Date: Thu Oct 01 2026 - 10:07:01 EST
A running task changed through the sched_change pattern is restored
with SNT_NORMAL. Only fresh picks set slice protection, so the restore
currently leaves vprot unchanged.
If sched_setattr() shortens the task slice, the old boundary can remain
live far beyond the new request. Lower the existing boundary when
restoring current. If protection remains live, rearm HRTICK because its
previous expiry may be later than the new boundary. The update can also
move vprot behind current's vruntime. In that case, request lazy-resched
when another fair entity is queued instead of letting hrtick_start_fair()
fall back to the later deadline.
Fixes: bcd74b2ffdd0 ("sched/fair: Only set slice protection at pick time")
Signed-off-by: Christian Loehle <christian.loehle@xxxxxxx>
---
kernel/sched/fair.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index bffc560bc7b8..59f9c08f968a 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -15571,8 +15571,7 @@ static void set_next_task_fair(struct rq *rq, struct task_struct *p, enum snt_e
if (on_rq) {
reweight_eevdf(cfs_rq, se, weight, se->on_rq);
- if (first)
- set_protect_slice(cfs_rq, se, false);
+ set_protect_slice(cfs_rq, se, !first);
}
if (task_on_rq_queued(p)) {
@@ -15582,8 +15581,15 @@ static void set_next_task_fair(struct rq *rq, struct task_struct *p, enum snt_e
*/
list_move(&se->group_node, &rq->cfs_tasks);
}
- if (!first)
+ if (!first) {
+ if (!protect_slice(se)) {
+ if (rq->cfs.h_nr_queued > 1)
+ resched_curr_lazy(rq);
+ } else if (hrtick_enabled_fair(rq)) {
+ hrtick_start_fair(rq, p);
+ }
return;
+ }
WARN_ON_ONCE(se->sched_delayed);
--
2.34.1