Re: [PATCH 6/6 v3] sched/eevdf: Speedup short slice task scheduling
From: Peter Zijlstra
Date: Thu Jun 25 2026 - 04:35:35 EST
On Wed, Jun 24, 2026 at 05:12:29PM +0200, Vincent Guittot wrote:
> When a task with a shorter slice is enqueued, we protect the running
> task which has a longer slice until it becomes ineligible instead of a
> full slice in order to speedup the switch to other tasks until the task
> with the shortest slice is scheduled. This helps to the task to not wait
> too many full slices before running.
>
> Signed-off-by: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
> Tested-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>
> ---
> kernel/sched/fair.c | 52 +++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 50 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index f972987618e7..7c541f27a1ed 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -813,6 +813,48 @@ u64 avg_vruntime(struct cfs_rq *cfs_rq)
> return cfs_rq->zero_vruntime;
> }
>
> +/*
> + * Compute the vruntime until which the entity remains eligible when it runs
> + * or is about to run on the CPU. We use this value to set vprot to the min
> + * value until which other entities would not be picked anyway.
> + * \Sum (v_i - v0)*w_i
> + * V = ------------------- + v0
> + * \Sum w_i
> + *
> + * We want V' for (v_se - v0) == 0. Previous entity has already been enqueued
> + * in the rb tree and next is already dequeued so
> + *
> + * cfs_rq->sum_w_vruntime
> + * V' = ------------------------- + v0
> + * cfs_rq->sum_weight + w_se
> +
> + */
> +static u64 eligible_vruntime(struct cfs_rq *cfs_rq, struct sched_entity *se)
> +{
> + struct sched_entity *curr = cfs_rq->curr;
> + long weight = cfs_rq->sum_weight;
> + s64 delta = 0;
'curr' goes unused in this function, did you want:
if (curr && !curr->on_rq)
curr = NULL;
> +
> + if (weight) {
> + s64 runtime = cfs_rq->sum_w_vruntime;
if (curr) {
unsigned long w = avg_vruntime_weight(cfs_rq, curr->load.weight);
runtime += entity_key(cfs_rq, curr) * w;
weight += w;
}
?
> +
> + weight += avg_vruntime_weight(cfs_rq, se->load.weight);
> +
> + /* sign flips effective floor / ceiling */
> + if (runtime < 0)
> + runtime -= (weight - 1);
> +
> + delta = div64_long(runtime, weight);
> + } else {
> + /*
> + * When there is but one element, it is the average.
> + */
> + delta = 0;
> + }
> +
> + return cfs_rq->zero_vruntime + delta + 1;
> +}