Re: [PATCH 1/1] sched/fair: improve yield_to vs fairness

From: Peter Zijlstra
Date: Tue Jul 27 2021 - 09:35:44 EST


On Fri, Jul 23, 2021 at 05:21:37PM +0100, Mel Gorman wrote:

> I'm still not a fan because vruntime gets distorted. From the docs
>
> Small detail: on "ideal" hardware, at any time all tasks would have the same
> p->se.vruntime value --- i.e., tasks would execute simultaneously and no task
> would ever get "out of balance" from the "ideal" share of CPU time
>
> If yield_to impacts this "ideal share" then it could have other
> consequences.

Note that we already violate this ideal both subtly and explicitly.

For an example of the latter consider pretty much the entirety of
place_entity() with GENTLE_FAIR_SLEEPERS being the most egregious
example.

That said; adding to vruntime will only penalize the task itself, while
subtracting from vruntime will penalize everyone else. And in that sense
addition to vruntime is a safe option.

I've not fully considered the case at hand; just wanted to give some
context.