kernel/sched/fair.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
The branch is only taken when slice is not equal to se->slice,
and that means se->slice is bigger than slice, since after the
min() call, slice is assigned the smaller one of se->slice and slice.
The min_vruntime comparison always picks the calculated value, since it is
smaller.
So, skip the comparison by not calling min_vruntime and assign the
calculated value directly to vprot. No functional change intended.
Signed-off-by: Kayra Cizmeci <kayracizmeci@gmail.com>
---
I only did a boot test on x86 (Zen 3), since the change is well below my noise floor.
kernel/sched/fair.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index d78467ec6ee1..97506b2edf7d 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1090,8 +1090,13 @@ 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);
+ /*
+ * slice < se->slice, so the calculated value
+ * is always before se->deadline.
+ * No comparison needed.
+ */
if (slice != se->slice)
- vprot = min_vruntime(vprot, se->vruntime + calc_delta_fair(slice, se));
+ vprot = se->vruntime + calc_delta_fair(slice, se);
se->vprot = vprot;
}
--
2.53.0
On Mon, 10 Aug 2026 14:54:22 +0300, Kayra Cizmeci wrote: > The min_vruntime comparison always picks the calculated value, since it is > smaller. The argument needs @vprot to be se->vruntime + calc_delta_fair(se->slice, se). It is se->deadline, which is only that much ahead just after the deadline is set. place_entity() does not even set a full slice: vslice = calc_delta_fair(se->slice, se); ... if (sched_feat(PLACE_DEADLINE_INITIAL) && (flags & ENQUEUE_INITIAL)) vslice /= 2; ... se->deadline = se->vruntime + vslice; PLACE_DEADLINE_INITIAL is on by default, so a new entity reaches its first pick with the deadline half a slice ahead. The branch you are simplifying runs when cfs_rq_min_slice() is below se->slice, i.e. with custom slices in play; if it is also above half of se->slice, then se->vruntime + calc_delta_fair(slice, se) is past se->deadline and min_vruntime() is what keeps @vprot there. The gap also shrinks while an entity runs: update_deadline() returns early below the deadline, and put_prev_entity() re-enqueues a preempted entity without renewing it, so by the next pick se->deadline - se->vruntime is only what is left of the slice. Assigning the calculated value unconditionally puts se->vprot past se->deadline, and protect_slice() only compares se->vruntime against se->vprot, so RUN_TO_PARITY would keep protecting the entity past its own deadline. Thanks, Zhan Xusheng
> The argument needs @vprot to be se->vruntime + calc_delta_fair(se->slice, se). > It is se->deadline, which is only that much ahead just after the deadline is > set. place_entity() does not even set a full slice You are right. I completely overlooked that. I assumed that the deadline is always calculated with se->slice but that is wrong. Thanks for the detailed explanation. Please drop this patch. Thanks, Kayra
© 2016 - 2026 Red Hat, Inc.