From patchwork Thu Jan 12 12:27:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qais Yousef X-Patchwork-Id: 642481 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 3245AC54EBC for ; Thu, 12 Jan 2023 12:27:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229819AbjALM1c (ORCPT ); Thu, 12 Jan 2023 07:27:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229521AbjALM1a (ORCPT ); Thu, 12 Jan 2023 07:27:30 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BF8BE038 for ; Thu, 12 Jan 2023 04:27:29 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id p1-20020a05600c1d8100b003d8c9b191e0so14901254wms.4 for ; Thu, 12 Jan 2023 04:27:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GCcNIf1UDvpuNFf5vf6I9RJFpFoRfVbI97Z02S7w11Y=; b=gqlZx5nKqp7gWtHj2VtzvWabHx3d0lzbz8cWeB4kIBorh/UGScyAAfbJbYPXhsaJoU fhP7yJANvZo9WuUChqGizHV6E2xdG1lpAq8umJKDZZSOxFnmjRwPGBpNhVPmxGDtvu/9 ooTxgzzTa4EnGJk3i9ZeIZtu2oE4IhI5ZkvixnakGQGOlREeGuq8BHaW6uARCuoMzeTD SB2nbteXj3n+waH9as/eKVO/X4jy6HGO5KfmDcwlpeuMAMELpyeNeVivZsx8mQvlRdvl QD1mK0AHxYU3u3Xj3LjBueXI7WD5JCHVMU6wL0wKIPUB5su+8D097VCFf2hpiQgMkf5e POzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GCcNIf1UDvpuNFf5vf6I9RJFpFoRfVbI97Z02S7w11Y=; b=in97HdRmUVDpyANNpaYvm5rXa3b/878ZFlwla2Ea2V48rNe49CqxG1Q/hsBPT6Wyxk gsGGJoWfSCQUPSnEwJBxIG2j2n2I31ETRuSixQHO2gJ/z8iHrbIZN0WbE8khGkx0F5Ez qY+XEIGIjLcjk7x5U21f94f4oF7+ZJfnaMYO15CEBlvk6qkspwJGpo/XAvnwERmwa+BK ts+jEdJB2BgbzQaIMlIrIIfDuExAuItnnjWr6rHMBQL6cMq00LUhosywreXzLHcynZi6 e8zamk6+/sbXwA9LJwTYmy93q/2cLsoMjvDu4+vCmRdpfeSNpc4qszEzCk/mQ3/o9Pbt /N4A== X-Gm-Message-State: AFqh2kreCRTYFiHeO1JQQEioUPYxSKAd4RsvLANvzurbL2NQ/Cvsy9a6 999DmvJlHexbNIReC06CDF+Hew== X-Google-Smtp-Source: AMrXdXtdEBRvBQgd/6uz8LieQd8BHljlCl9RDt73lsyy4hhbaUWrV5WImaqKCcpXlCMpsh+4LAGRIA== X-Received: by 2002:a1c:4c12:0:b0:3c6:e63e:89a6 with SMTP id z18-20020a1c4c12000000b003c6e63e89a6mr55130984wmf.2.1673526447908; Thu, 12 Jan 2023 04:27:27 -0800 (PST) Received: from airbuntu.lon.corp.google.com ([104.132.45.104]) by smtp.gmail.com with ESMTPSA id f11-20020a05600c4e8b00b003d04e4ed873sm30132354wmq.22.2023.01.12.04.27.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 04:27:27 -0800 (PST) From: Qais Yousef To: Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann Cc: "Rafael J. Wysocki" , Viresh Kumar , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Lukasz Luba , Wei Wang , Xuewen Yan , Hank , Jonathan JMChen , Qais Yousef , kernel test robot , Dan Carpenter Subject: [PATCH v3 1/2] sched/uclamp: Fix a uninitialized variable warnings Date: Thu, 12 Jan 2023 12:27:07 +0000 Message-Id: <20230112122708.330667-2-qyousef@layalina.io> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230112122708.330667-1-qyousef@layalina.io> References: <20230112122708.330667-1-qyousef@layalina.io> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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) Reviewed-by: Vincent Guittot --- kernel/sched/fair.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index e9d906a9bba9..5a8e75d4a17b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7353,10 +7353,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; @@ -7375,6 +7375,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))) @@ -7393,24 +7395,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))) { - util_min = p_util_min; - util_max = p_util_max; - } else { - /* - * 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;