[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKfTPtAE6DJTwxZ996BJoUJF++fFHdFk-C2bpUQ8aG0NQusApA@mail.gmail.com>
Date: Thu, 27 May 2021 15:18:35 +0200
From: Vincent Guittot <vincent.guittot@...aro.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Ingo Molnar <mingo@...hat.com>, Juri Lelli <juri.lelli@...hat.com>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
linux-kernel <linux-kernel@...r.kernel.org>,
Odin Ugedal <odin@...d.al>,
"open list:CONTROL GROUP (CGROUP)" <cgroups@...r.kernel.org>
Subject: Re: [PATCH 1/2] sched/fair: keep load_avg and load_sum synced
On Thu, 27 May 2021 at 15:06, Peter Zijlstra <peterz@...radead.org> wrote:
>
> On Thu, May 27, 2021 at 02:29:15PM +0200, Vincent Guittot wrote:
>
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -3509,7 +3509,8 @@ update_tg_cfs_load(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq
> > se->avg.load_sum = runnable_sum;
> > se->avg.load_avg = load_avg;
> > add_positive(&cfs_rq->avg.load_avg, delta_avg);
> > - add_positive(&cfs_rq->avg.load_sum, delta_sum);
> > + cfs_rq->avg.load_sum = cfs_rq->avg.load_avg * divider;
>
> If I'm not mistaken, this makes delta_sum unused, so we can remove it
> entirely, see below.
yes, you're right
>
> > +
>
> This extra blank space, we really need that? :-)
>
> > }
>
> ---
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 161b92aa1c79..2b99e687fe7a 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -3453,10 +3453,9 @@ update_tg_cfs_runnable(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cf
> static inline void
> update_tg_cfs_load(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq)
> {
> - long delta_avg, running_sum, runnable_sum = gcfs_rq->prop_runnable_sum;
> + long running_sum, runnable_sum = gcfs_rq->prop_runnable_sum;
> unsigned long load_avg;
> u64 load_sum = 0;
> - s64 delta_sum;
> u32 divider;
>
> if (!runnable_sum)
> @@ -3503,13 +3502,11 @@ update_tg_cfs_load(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq
> load_sum = (s64)se_weight(se) * runnable_sum;
> load_avg = div_s64(load_sum, divider);
>
> - delta_sum = load_sum - (s64)se_weight(se) * se->avg.load_sum;
> - delta_avg = load_avg - se->avg.load_avg;
> -
> se->avg.load_sum = runnable_sum;
> se->avg.load_avg = load_avg;
> - add_positive(&cfs_rq->avg.load_avg, delta_avg);
> - add_positive(&cfs_rq->avg.load_sum, delta_sum);
> +
> + add_positive(&cfs_rq->avg.load_avg, (long)(load_avg - se->avg.load_avg));
you have to keep:
delta_avg = load_avg - se->avg.load_avg
or move se->avg.load_avg = load_avg after
add_positive(&cfs_rq->avg.load_avg, ..);
because otherwise (load_avg - se->avg.load_avg) == 0
> + cfs_rq->avg.load_sum = cfs_rq->avg.load_avg * divider;
> }
>
> static inline void add_tg_cfs_propagate(struct cfs_rq *cfs_rq, long runnable_sum)
Powered by blists - more mailing lists