Re: [PATCH] sched/fair: Drop min_vruntime() call from set_protect_slice()

From: Zhan Xusheng

Date: Mon Aug 10 2026 - 08:44:08 EST


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