Re: [PATCH] sched/pelt: check that *_avg are null when *_sum are

From: Dietmar Eggemann
Date: Thu Jun 03 2021 - 06:42:42 EST


On 01/06/2021 17:53, Vincent Guittot wrote:
> Check that we never break the rule that pelt's avg values are null if
> pelt's sum are.
>
> Signed-off-by: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
> ---
>
> This is what I used for patch 20210601085832.12626-1-vincent.guittot@xxxxxxxxxx
>
> kernel/sched/fair.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index a2c30e52de76..c17feadeafcc 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -8021,6 +8021,15 @@ static inline bool cfs_rq_is_decayed(struct cfs_rq *cfs_rq)
> if (cfs_rq->avg.runnable_sum)
> return false;
>
> + /*
> + * _avg must be null when _sum are null because _avg = _sum / divider
> + * Make sure that rounding and/or propagation of PELT values never
> + * break this.
> + */
> + SCHED_WARN_ON(cfs_rq->avg.load_avg ||
> + cfs_rq->avg.util_avg ||
> + cfs_rq->avg.runnable_avg);
> +
> return true;
> }

Reviewed-by: Dietmar Eggemann <dietmar.eggemann@xxxxxxx>