Re: [PATCH v2] sched/fair: sanitize vruntime of entity being placed

From: Peter Zijlstra
Date: Wed Feb 01 2023 - 11:06:36 EST


On Mon, Jan 30, 2023 at 01:22:16PM +0100, Roman Kagan wrote:
> From: Zhang Qiao <zhangqiao22@xxxxxxxxxx>
>
> When a scheduling entity is placed onto cfs_rq, its vruntime is pulled
> to the base level (around cfs_rq->min_vruntime), so that the entity
> doesn't gain extra boost when placed backwards.
>
> However, if the entity being placed wasn't executed for a long time, its
> vruntime may get too far behind (e.g. while cfs_rq was executing a
> low-weight hog), which can inverse the vruntime comparison due to s64
> overflow. This results in the entity being placed with its original
> vruntime way forwards, so that it will effectively never get to the cpu.
>
> To prevent that, ignore the vruntime of the entity being placed if it
> didn't execute for much longer than the characteristic sheduler time
> scale.
>
> Signed-off-by: Zhang Qiao <zhangqiao22@xxxxxxxxxx>
> [rkagan: formatted, adjusted commit log, comments, cutoff value]
> Co-developed-by: Roman Kagan <rkagan@xxxxxxxxx>
> Signed-off-by: Roman Kagan <rkagan@xxxxxxxxx>

Thanks!