Messages in this thread | | | From | Vincent Guittot <> | Date | Mon, 7 Nov 2022 09:00:12 +0100 | Subject | Re: [PATCH v7 1/9] sched/fair: fix unfairness at wakeup |
| |
On Sat, 5 Nov 2022 at 15:33, Chen Yu <yu.c.chen@intel.com> wrote: > > On 2022-10-28 at 11:33:55 +0200, Vincent Guittot wrote: > [snip] > > +static inline unsigned long get_latency_max(void) > > +{ > > + unsigned long thresh = get_sched_latency(false); > > + > > + thresh -= sysctl_sched_min_granularity; > > + > May I know why we substract sysctl_sched_min_granularity above? > I thought thresh -= 1 would be enough to let the waking task preempt > the current one, because: > When a long sleeping task is enqueued on this rq, its vruntime is set > to cfs_rq->min_vtime - latency, so > diff = curr->vtime - cfs_rq->min_vtime + latency, > since (curr->vtime - cfs_rq->min_vtime) >= 0, if we set the thresh to > (latency - 1), the diff is guaranteed to be bigger than thresh and > the waking task can preempt current task.
If the waking task failed to preempt current it could to wait up to sysctl_sched_min_granularity before preempting it during next tick.
Vincent
> > thanks, > Chenyu > > + return thresh; > > +}
| |