Re: [RFC][PATCH 13/15] sched/fair: Implement latency-nice

From: Peter Zijlstra
Date: Thu Jun 08 2023 - 08:46:05 EST


On Thu, Jun 08, 2023 at 12:34:58PM +0200, Peter Zijlstra wrote:
> > Then asking for a request shorter than the tick also means that
> > scheduler must enqueue a new request (on behalf of the task) during
> > the tick and evaluate if the task is still the one to be scheduled
> > now.
>
> If there is no 'interrupt', we won't update time and the scheduler can't
> do anything -- as you well know. The paper only requires (and we
> slightly violate this) to push forward the deadline. See the comment
> with update_deadline().
>
> Much like pure EDF without a combined CBS.
>
> > So similarly to q, the request size r should be at least a tick
> > in order to reevaluate which task will run next after the end of a
> > request. In fact, the real limit is : r/wi >= tick/(Sum wj)
>
> > We can always not follow these assumptions made in the publication but
> > I wonder how we can then rely on its theorems and corollaries
>
> Again, I'm not entirely following, the corollaries take r_i < q into
> account, that's where the max(rmax, q) term comes from.
>
> You're right in that r_i < q does not behave 'right', but it doesn't
> invalidate the results. Note that if a task overshoots, it will build of
> significant negative lag (right side of the tree) and won't be eligible
> for it's next actual period. This 'hole' in the schedule is then used to
> make up for the extra time it used previously.

So notably, if your task *does* behave correctly and does not consume
the full request, then it will not build up (large) negative lag and
wakeup-preemption can make it go quickly on the next period.

This is where that FUDGE hack comes in, except I got it wrong, I think
it needs to be something like:

if (delta / W >= vslice) {
se->vlag += vslice
if (se->vlag > 0)
se->vlag = 0;
}

To ensure it can't gain time. It's still a gruesome hack, but at least
is shouldn't be able to game the system.