public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Qais Yousef <qyousef@layalina.io>
To: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Lukasz Luba <lukasz.luba@arm.com>, Wei Wang <wvw@google.com>,
	Xuewen Yan <xuewen.yan94@gmail.com>, Hank <han.lin@mediatek.com>,
	Jonathan JMChen <Jonathan.JMChen@mediatek.com>,
	kernel test robot <lkp@intel.com>,
	Dan Carpenter <error27@gmail.com>
Subject: Re: [PATCH 1/3] sched/uclamp: Fix a uninitialized variable warnings
Date: Sat, 3 Dec 2022 14:32:34 +0000	[thread overview]
Message-ID: <20221203143234.fbbdjoc6istwxkee@airbuntu> (raw)
In-Reply-To: <927e4ffc-8400-b615-2d58-9e88ee4bdc3c@arm.com>

On 12/01/22 23:38, Dietmar Eggemann wrote:
> On 27/11/2022 15:17, Qais Yousef wrote:
> > Addresses the following warnings:
> > 
> >> config: riscv-randconfig-m031-20221111
> >> compiler: riscv64-linux-gcc (GCC) 12.1.0
> >>
> >> smatch warnings:
> >> kernel/sched/fair.c:7263 find_energy_efficient_cpu() error: uninitialized symbol 'util_min'.
> >> kernel/sched/fair.c:7263 find_energy_efficient_cpu() error: uninitialized symbol 'util_max'.
> > 
> > Fixes: 244226035a1f ("sched/uclamp: Fix fits_capacity() check in feec()")
> > Reported-by: kernel test robot <lkp@intel.com>
> > Reported-by: Dan Carpenter <error27@gmail.com>
> > Signed-off-by: Qais Yousef (Google) <qyousef@layalina.io>
> > ---
> >  kernel/sched/fair.c | 7 ++-----
> >  1 file changed, 2 insertions(+), 5 deletions(-)
> > 
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index 4cc56c91e06e..89dadaafc1ec 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -7217,10 +7217,10 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
> >  	eenv_task_busy_time(&eenv, p, prev_cpu);
> >  
> >  	for (; pd; pd = pd->next) {
> > +		unsigned long util_min = p_util_min, util_max = p_util_max;
> >  		unsigned long cpu_cap, cpu_thermal_cap, util;
> >  		unsigned long cur_delta, max_spare_cap = 0;
> >  		unsigned long rq_util_min, rq_util_max;
> > -		unsigned long util_min, util_max;
> >  		unsigned long prev_spare_cap = 0;
> >  		int max_spare_cap_cpu = -1;
> >  		unsigned long base_energy;
> > @@ -7258,10 +7258,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
> >  			 * aligned with sched_cpu_util().
> >  			 */
> >  			if (uclamp_is_used()) {
> > -				if (uclamp_rq_is_idle(cpu_rq(cpu))) {
> > -					util_min = p_util_min;
> > -					util_max = p_util_max;
> > -				} else {
> > +				if (!uclamp_rq_is_idle(cpu_rq(cpu))) {
> >  					/*
> >  					 * Open code uclamp_rq_util_with() except for
> >  					 * the clamp() part. Ie: apply max aggregation
> 
> Can we use `struct rq *rq = cpu_rq(cpu)` to reduce nesting and comply
> with 80 columns line length?

Yep, that's better!


Thanks!

--
Qais Yousef

> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 89dadaafc1ec..6a2fc2ca5078 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -7239,6 +7239,8 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
>  		eenv.pd_cap = 0;
>  
>  		for_each_cpu(cpu, cpus) {
> +			struct rq *rq = cpu_rq(cpu);
> +
>  			eenv.pd_cap += cpu_thermal_cap;
>  
>  			if (!cpumask_test_cpu(cpu, sched_domain_span(sd)))
> @@ -7257,21 +7259,19 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
>  			 * much capacity we can get out of the CPU; this is
>  			 * aligned with sched_cpu_util().
>  			 */
> -			if (uclamp_is_used()) {
> -				if (!uclamp_rq_is_idle(cpu_rq(cpu))) {
> -					/*
> -					 * Open code uclamp_rq_util_with() except for
> -					 * the clamp() part. Ie: apply max aggregation
> -					 * only. util_fits_cpu() logic requires to
> -					 * operate on non clamped util but must use the
> -					 * max-aggregated uclamp_{min, max}.
> -					 */
> -					rq_util_min = uclamp_rq_get(cpu_rq(cpu), UCLAMP_MIN);
> -					rq_util_max = uclamp_rq_get(cpu_rq(cpu), UCLAMP_MAX);
> -
> -					util_min = max(rq_util_min, p_util_min);
> -					util_max = max(rq_util_max, p_util_max);
> -				}
> +			if (uclamp_is_used() && !uclamp_rq_is_idle(rq)) {
> +				/*
> +				 * Open code uclamp_rq_util_with() except for
> +				 * the clamp() part. Ie: apply max aggregation
> +				 * only. util_fits_cpu() logic requires to
> +				 * operate on non clamped util but must use the
> +				 * max-aggregated uclamp_{min, max}.
> +				 */
> +				rq_util_min = uclamp_rq_get(rq, UCLAMP_MIN);
> +				rq_util_max = uclamp_rq_get(rq, UCLAMP_MAX);
> +
> +				util_min = max(rq_util_min, p_util_min);
> +				util_max = max(rq_util_max, p_util_max);
>  			}
>  			if (!util_fits_cpu(util, util_min, util_max, cpu))
>  				continue;

  reply	other threads:[~2022-12-03 14:32 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-27 14:17 [PATCH 0/3] Fixes for uclamp and capacity inversion detection Qais Yousef
2022-11-27 14:17 ` [PATCH 1/3] sched/uclamp: Fix a uninitialized variable warnings Qais Yousef
2022-12-01 22:38   ` Dietmar Eggemann
2022-12-03 14:32     ` Qais Yousef [this message]
2022-12-08 14:51     ` [PATCH v2] " Qais Yousef
2022-11-27 14:17 ` [PATCH 2/3] sched/fair: Fixes for capacity inversion detection Qais Yousef
2022-12-01 22:39   ` Dietmar Eggemann
2022-12-03 14:32     ` Qais Yousef
2022-12-08 14:54     ` [PATCH v2] " Qais Yousef
2022-12-08 14:58       ` Qais Yousef
2022-11-27 14:17 ` [RFC PATCH 3/3] sched/fair: Traverse cpufreq policies to detect capacity inversion Qais Yousef
2022-11-30 18:27   ` Rafael J. Wysocki
2022-12-03 14:32     ` Qais Yousef
2022-12-05 12:39       ` Rafael J. Wysocki
2022-12-05 14:09         ` Qais Yousef
2022-12-02 14:57   ` Vincent Guittot
2022-12-03 14:33     ` Qais Yousef
2022-12-04 11:35       ` Vincent Guittot
2022-12-05 11:01         ` Qais Yousef
2022-12-06 18:12           ` Vincent Guittot
2022-12-08 14:05             ` Qais Yousef
2022-12-09 16:47               ` Vincent Guittot
2022-12-12 18:43                 ` Qais Yousef
2022-12-13 17:38                   ` Dietmar Eggemann
2022-12-15 17:46                     ` Vincent Guittot
2022-12-20 11:50                     ` Qais Yousef
2022-12-13 17:42                   ` Lukasz Luba
2022-12-20 11:51                     ` Qais Yousef
2022-12-20 12:52                       ` Lukasz Luba
2022-12-15 17:39                   ` Vincent Guittot
2022-12-20 12:32                     ` Qais Yousef
2022-12-20 13:50                       ` Vincent Guittot
2022-12-23 11:58                         ` Qais Yousef
2022-12-27 13:33                           ` Vincent Guittot
2022-12-28 17:18                             ` Vincent Guittot
2023-01-09 16:40                             ` Qais Yousef
2023-01-10 16:38                               ` Vincent Guittot
2023-01-10 16:44                                 ` Qais Yousef

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221203143234.fbbdjoc6istwxkee@airbuntu \
    --to=qyousef@layalina.io \
    --cc=Jonathan.JMChen@mediatek.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=error27@gmail.com \
    --cc=han.lin@mediatek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=lukasz.luba@arm.com \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    --cc=wvw@google.com \
    --cc=xuewen.yan94@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox