[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKfTPtCgbtKkjA+tU2DFJgKAsXV+kFKipMxTuReaT5QKNvvAGA@mail.gmail.com>
Date: Wed, 22 Jun 2022 17:20:18 +0200
From: Vincent Guittot <vincent.guittot@...aro.org>
To: Zhaoyu Liu <zackary.liu.pro@...il.com>
Cc: mingo@...hat.com, peterz@...radead.org, juri.lelli@...hat.com,
dietmar.eggemann@....com, rostedt@...dmis.org, bsegall@...gle.com,
mgorman@...e.de, bristot@...hat.com, vschneid@...hat.com,
kuyo.chang@...iatek.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] sched/pelt: simplify load_sum assignment code in attach_entity_load_avg()
On Tue, 21 Jun 2022 at 17:45, Zhaoyu Liu <zackary.liu.pro@...il.com> wrote:
>
> In commit 40f5aa4c5eae ("sched/pelt: Fix attach_entity_load_avg() corner case"),
> these code was committed:
> if (se_weight(se) < se->avg.load_sum)
> se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se));
> else
> se->avg.load_sum = 1;
>
> they could be replace with:
> se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se)) ?: 1;
>
> to make the code cleaner.
This quite subjective as I consider current version cleaner than your proposal
>
> Signed-off-by: Zhaoyu Liu <zackary.liu.pro@...il.com>
> ---
> kernel/sched/fair.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 78795a997d9c..ed32f66bbd3d 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -3881,10 +3881,7 @@ static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s
> se->avg.runnable_sum = se->avg.runnable_avg * divider;
>
> se->avg.load_sum = se->avg.load_avg * divider;
> - if (se_weight(se) < se->avg.load_sum)
> - se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se));
> - else
> - se->avg.load_sum = 1;
> + se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se)) ?: 1;
>
> enqueue_load_avg(cfs_rq, se);
> cfs_rq->avg.util_avg += se->avg.util_avg;
> --
> 2.17.1
>
Powered by blists - more mailing lists