Re: [PATCH 6/6 v3] sched/eevdf: Speedup short slice task scheduling

From: K Prateek Nayak

Date: Thu Jun 25 2026 - 03:37:59 EST


Hello Vincent,

On 6/24/2026 8:42 PM, Vincent Guittot wrote:
> +/*
> + * 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
> +

nit.

^ is that a stray line or a Missing * at the beginning of the comment
line?

> + */
> +static u64 eligible_vruntime(struct cfs_rq *cfs_rq, struct sched_entity *se)
> +{
> + struct sched_entity *curr = cfs_rq->curr;

curr seems to be unused here and is NULL anyways when
set_protect_slice() is called ;-)

> + long weight = cfs_rq->sum_weight;
> + s64 delta = 0;
> +
> + if (weight) {
> + s64 runtime = cfs_rq->sum_w_vruntime;
> +
> + 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;

Even with a single entity, the se->vruntime can still diverge from
cfs_rq->zero_vruntime

Last avg_vruntime() call for cfs_rq was at update_entity_lag() during
last dequeue while se->on_rq was still set for the dequeuing entity.

Should this be entity_key(cfs_rq, se) instead?

> + }
> +
> + return cfs_rq->zero_vruntime + delta + 1;
> +}
> +
> static inline u64 cfs_rq_max_slice(struct cfs_rq *cfs_rq);
>
> /*
--
Thanks and Regards,
Prateek