[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZerhnPHeBSgd+XOk@gmail.com>
Date: Fri, 8 Mar 2024 10:59:56 +0100
From: Ingo Molnar <mingo@...nel.org>
To: Vincent Guittot <vincent.guittot@...aro.org>
Cc: linux-kernel@...r.kernel.org, Shrikanth Hegde <sshegde@...ux.ibm.com>,
Peter Zijlstra <peterz@...radead.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Valentin Schneider <vschneid@...hat.com>
Subject: Re: [PATCH 3/9] sched/balancing: Change 'enum cpu_idle_type' to have
more natural definitions
* Vincent Guittot <vincent.guittot@...aro.org> wrote:
> On Mon, 4 Mar 2024 at 10:48, Ingo Molnar <mingo@...nel.org> wrote:
> >
> > The cpu_idle_type enum has the confusingly inverted property
> > that 'not idle' is 1, and 'idle' is '0'.
> >
> > This resulted in a number of unnecessary complications in the code.
> >
> > Reverse the order, remove the CPU_NOT_IDLE type, and convert
> > all code to a natural boolean form.
> >
> > It's much more readable:
> >
> > - enum cpu_idle_type idle = this_rq->idle_balance ?
> > - CPU_IDLE : CPU_NOT_IDLE;
> > -
> > + enum cpu_idle_type idle = this_rq->idle_balance;
> >
> > --------------------------------
> >
> > - if (env->idle == CPU_NOT_IDLE || !busiest->sum_nr_running)
> > + if (!env->idle || !busiest->sum_nr_running)
> >
> > --------------------------------
> >
> > And gets rid of the double negation in these usages:
> >
> > - if (env->idle != CPU_NOT_IDLE && env->src_rq->nr_running <= 1)
> > + if (env->idle && env->src_rq->nr_running <= 1)
> >
> > Furthermore, this makes code much more obvious where there's
> > differentiation between CPU_IDLE and CPU_NEWLY_IDLE.
> >
> > Signed-off-by: Ingo Molnar <mingo@...nel.org>
> > Cc: Peter Zijlstra <peterz@...radead.org>
> > Cc: Vincent Guittot <vincent.guittot@...aro.org>
> > Cc: Dietmar Eggemann <dietmar.eggemann@....com>
> > Cc: Linus Torvalds <torvalds@...ux-foundation.org>
> > Cc: Valentin Schneider <vschneid@...hat.com>
> > ---
> > include/linux/sched/idle.h | 3 +--
> > kernel/sched/fair.c | 27 ++++++++++++---------------
> > 2 files changed, 13 insertions(+), 17 deletions(-)
> >
> > diff --git a/include/linux/sched/idle.h b/include/linux/sched/idle.h
> > index 478084f9105e..4a6423700ffc 100644
> > --- a/include/linux/sched/idle.h
> > +++ b/include/linux/sched/idle.h
> > @@ -5,8 +5,7 @@
> > #include <linux/sched.h>
> >
> > enum cpu_idle_type {
> > - CPU_IDLE,
> > - CPU_NOT_IDLE,
>
> Could be set CPU_NOT_IDLE = 0 to help keeping in mind that 0 means
> cpu is not idle even if we don't use it ?
Yeah, makes sense. I've added back __CPU_NOT_IDLE = 0 (with the underscore
to make sure some pending patch isn't accidentally relying on something it
shouldn't), and added your Reviewed-by.
Thanks,
Ingo
Powered by blists - more mailing lists