From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 333CEC352A1 for ; Sat, 3 Dec 2022 14:32:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229752AbiLCOcq (ORCPT ); Sat, 3 Dec 2022 09:32:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229775AbiLCOcm (ORCPT ); Sat, 3 Dec 2022 09:32:42 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 025B8DF2 for ; Sat, 3 Dec 2022 06:32:37 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id c65-20020a1c3544000000b003cfffd00fc0so8578776wma.1 for ; Sat, 03 Dec 2022 06:32:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20210112.gappssmtp.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=t/slI43YQ77BjkqjOhSgLj/8+/Ru84H0eXYANhuZ9jQ=; b=sxlWioTj2TBdkQ3JocqfqDrRDRe5ov/iJiMZpASubQ7a6fzpJ+D4o+zfYiZYNuJ9Vu TSdIV/tQvgCuxE/fSIuUxx6F/7GsBmezM7OnW2Hz9Pp7CN4S7Xbnz96LnJjqiZ/rGO8u 44nT5iHEFwC9KWgRIoRp1e6xZOrK5JBDI8krxXt6LloAIoose8Wxm8HGscDuNsjqD4CT nNGee4ZMb42guH+HIvnkHQy7w+743VNqDKD807WHyOj2GdtMoj22L+B5TNLKzs83bhol S3CtRCW1PqtMi8KV4GBQhPgfa2fM6XcifI+xYc+s8EQ9A8a94S/i9H+1/gclteq/ISL1 jXbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=t/slI43YQ77BjkqjOhSgLj/8+/Ru84H0eXYANhuZ9jQ=; b=IW9z93SquuUs8csxXDwfUCpD+AeNCZGsAZUUqEQJDjlE7NDltRuMoE9+O0iB20O+C9 7YdkoO7aj+wGc/G9unDeWmZ2NQDAFdVR8Y+2kUPnAVQp2io/LeEBmBEJetEN2/6PgG8Z MyL9BKacGu4aMSXoqsshh7gvdBxDCpWSzIXGbnbsNb8+8+G/l+sI+2lE+WUt76wu3ege Wa/oyYkLtpxZVIi1dBRds03/mGxjgh5to9zO5dVU+3NmNxArYXvi2eVtq0nccpKRmRLP DhFVVCudX7Xu02uIkPFKtHkRnz/4zDAArWlAlqzA/0ge/rErt+fe+296vt7DuIDp+LCy Mcmg== X-Gm-Message-State: ANoB5pnLvhErDDykinNlL/bIbiYic5HeBpLagBsS+QXJ6QjWv4LdnVcV zrJMD3t303zVOtw9Eapri7dO2A== X-Google-Smtp-Source: AA0mqf5mbz6bxFw4RhOsBjOIwI5wF+k1H0fTKPeW2J+ipJId4fh329MyKu99sWaZGmS+5ELR6r8OCA== X-Received: by 2002:a05:600c:4f51:b0:3b4:a6c4:70fb with SMTP id m17-20020a05600c4f5100b003b4a6c470fbmr41719758wmq.79.1670077956415; Sat, 03 Dec 2022 06:32:36 -0800 (PST) Received: from airbuntu (host86-130-134-87.range86-130.btcentralplus.com. [86.130.134.87]) by smtp.gmail.com with ESMTPSA id r2-20020a056000014200b002422bc69111sm11976885wrx.9.2022.12.03.06.32.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Dec 2022 06:32:36 -0800 (PST) Date: Sat, 3 Dec 2022 14:32:34 +0000 From: Qais Yousef To: Dietmar Eggemann Cc: Ingo Molnar , Peter Zijlstra , Vincent Guittot , "Rafael J. Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Lukasz Luba , Wei Wang , Xuewen Yan , Hank , Jonathan JMChen , kernel test robot , Dan Carpenter Subject: Re: [PATCH 1/3] sched/uclamp: Fix a uninitialized variable warnings Message-ID: <20221203143234.fbbdjoc6istwxkee@airbuntu> References: <20221127141742.1644023-1-qyousef@layalina.io> <20221127141742.1644023-2-qyousef@layalina.io> <927e4ffc-8400-b615-2d58-9e88ee4bdc3c@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <927e4ffc-8400-b615-2d58-9e88ee4bdc3c@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 > > Reported-by: Dan Carpenter > > Signed-off-by: Qais Yousef (Google) > > --- > > 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;