Re: [PATCH 08/17] sched/fair: Implement an EEVDF like policy

From: Peter Zijlstra
Date: Thu Mar 30 2023 - 04:05:15 EST


On Wed, Mar 29, 2023 at 04:35:25PM +0200, Vincent Guittot wrote:

> IIUC how it works, Vd = ve + r / wi
>
> So for a same weight, the vd will be earlier but it's no more alway
> true for different weight

Correct; but for a heavier task the time also goes slower and since it
needs more time, you want it to go first. But yes, this is weird at
first glance.

Let us consider a 3 task scenario, where one task (A) is double weight
wrt to the other two (B,C), and let them run one quanta (q) at a time.

Each step will see V advance q/4.

A: w=2, r=4q B: w=1, r=4q C: w=1, r=4q

1) A runs -- earliest deadline

A |-------<
B |---------------<
C |---------------<
---+---+---+---+---+---+---+-----------
V ^

2) B runs (tie break with C) -- A is ineligible due to v_a > V

A |-----<
B |---------------<
C |---------------<
---+---+---+---+---+---+---+-----------
V ^

3) A runs -- earliest deadline

A |-----<
B |-----------<
C |---------------<
---+---+---+---+---+---+---+-----------
V ^

4) C runs -- only eligible task

A |---<
B |-----------<
C |---------------<
---+---+---+---+---+---+---+-----------
V ^

5) similar to 1)

A |---<
B |-----------<
C |-----------<
---+---+---+---+---+---+---+-----------
V ^

And we see that we get a very nice ABAC interleave, with the only other
possible schedule being ACAB.

By virtue of the heaver task getting a shorter virtual deadline it gets
nicely interleaved with the other tasks and you get a very consistent
schedule with very little choice.

Like already said, step 2) is the only place we had a choice, and if we
were to have given either B or C a shorter request (IOW latency-nice)
that choice would have been fully determined.

So increasing w gets you more time (and the shorter deadline causes the
above interleaving), while for the same w, reducing r gets you picked
earlier.

Perhaps another way to look at it is that since heavier tasks run more
(often) you've got to compete against it more often for latency.


Does that help?