Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1130187rwb; Thu, 8 Dec 2022 07:06:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf6UW/cNczJlJMbtPMJhl1K0o8gKKwR4Wsf9K1KsUB5WZCW82PftcHFdDXsgrOAlcNlAhRdc X-Received: by 2002:a17:906:f2c8:b0:7c0:eeae:242d with SMTP id gz8-20020a170906f2c800b007c0eeae242dmr15014051ejb.672.1670512006633; Thu, 08 Dec 2022 07:06:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670512006; cv=none; d=google.com; s=arc-20160816; b=hUntpCmZhvuWbfxO/Rz5i+5q3NjqGAHVHHwwSrNtBlQW3xOmWqKMqkdYsc2eN0t5tM 5FecFs2kMIRkWmVilgHtT3DC/2YN8nADQkxQItPmPPkIvIi5tojU9xTAhl0PypIgP4KP ABgvvTRgPDxt303D67ijbmQhvnR4qL/LTMquDafRtf+NaNRFiWv1ewsnJSeciaCVbnSK xtnGl8+wzn3LIioIesnqZkGFAb0X7HBgOobjOQLm/EMyzBRKvSNf42Lt95rVsPoRpRT/ TxZ609qF3mriva1u8f50qgtPJff31+A7Sw/uT9FRYnuazi9ADqUfEtpQKySqKDlTvju8 duVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5EQRHK9ZlDWtgRsVXiI0JZkXJchjbzgSFU+bI1duxL4=; b=d/saQvJyNkZri/1bGfT3jzYc5tKwsQn4O+rPUccSPuJCoyW1uozLPhX8vIo13S0X2C SnkUqel7i07Cgcp8XjyzUmN9x6wiKcthTvDDUoKHzBgCwAgHVSbQ9rAzbzmmbaLokwoJ k0skd1yePCkQpLsAB+AqbMQgP9DAKyWl28lig8r23BYxOsrOx0jrZh5gQeP8HLSd4Kcj rWNkTvBcbg89mFoUTUhcL896p/KILAWXo1tj7vPGcqfhj8EK4kgiG9kziXXI0tIM0rwv or/dM+O+txMcnAAA+0/ESmgyWNm545l17C3UU7Iiu6UDjdX/3rsP1IpifZQxSX+mmJbE qMeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@layalina-io.20210112.gappssmtp.com header.s=20210112 header.b=pcESBS62; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h7-20020a056402280700b0046b9715162csi8289475ede.21.2022.12.08.07.06.28; Thu, 08 Dec 2022 07:06:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@layalina-io.20210112.gappssmtp.com header.s=20210112 header.b=pcESBS62; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229988AbiLHOxD (ORCPT + 72 others); Thu, 8 Dec 2022 09:53:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229966AbiLHOwz (ORCPT ); Thu, 8 Dec 2022 09:52:55 -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 2F2BC4C271 for ; Thu, 8 Dec 2022 06:52:54 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id bg10so1229719wmb.1 for ; Thu, 08 Dec 2022 06:52:54 -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=5EQRHK9ZlDWtgRsVXiI0JZkXJchjbzgSFU+bI1duxL4=; b=pcESBS62/zG7V+GsJWrKU7/PXisfwFgAymJ/MUMxWu15xwo3i4GDWcQX9v6VF15qe2 D5EwLMHkbvtc9csuGVfJBFiRVWQ2a1NMbJQpgmuG8ujbi2Q7bEsnDCSrmmy8bnlXYpcf ENb5qESpp7R5LgDTYr4Zp8cuQghWlo1KI+z1C4OIxXnILkxM3A5TcTzLN4sLhOkzh0Kw Rno6hezMZki5uOXCT5vLotDr+tE+LL0ewYH+K/MmgRaHbavncKZQSfpIoF1VRKWf015X jR+i0mIyq9ycIRR+onCBLzC4CLPA+n973t7v/PgfWIf+v4UuilplNhNjKpK7O2pJa3I/ jXiQ== 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=5EQRHK9ZlDWtgRsVXiI0JZkXJchjbzgSFU+bI1duxL4=; b=r+tMr99B0Fu0WZfqM9s8KL+NzI/9Uc9s6vbmDEYyg4RSPfFb7k9yMtN59kqx8oOj4p fjhwxdN8BNGpkvphtpRHg1QsUPr2OaMVAjzZcLBFVvybCCTU9gaZAVZEfM0VVi/7lNbg t49oXA73nyuxsF/Gr1VuWJZtBQT5VlGSucJjazGS3YopLci649Hr2ZgokxS6GqYVzJnX EpP3ufVFzVtsceFneS0jsT+JyXk36q2s0pE7cPpm03wLMnVGK1IA/9eUxIx3N/qrWW5G dLTY6C1xo/S+W4IX8rXOq5Hz52f0dPQtIdIE7ibIROElctZ6qcByJJUUcQZaMSUGaC5L PYPg== X-Gm-Message-State: ANoB5pnN0/vuGMyzpEl+1WXTyX8X8rRgpskpruNN64gugLpUXXIDnbd5 3FS3epo1omDnL02X7LAiYJ4Kug== X-Received: by 2002:a05:600c:6888:b0:3d1:d746:7bca with SMTP id fn8-20020a05600c688800b003d1d7467bcamr2106872wmb.4.1670511172700; Thu, 08 Dec 2022 06:52:52 -0800 (PST) Received: from localhost.localdomain ([2a00:79e1:abc:9:c7d:8d2a:a83c:450a]) by smtp.gmail.com with ESMTPSA id f13-20020a7bcd0d000000b003b47ff307e1sm4973469wmj.31.2022.12.08.06.52.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 06:52:52 -0800 (PST) From: Qais Yousef To: Dietmar Eggemann , Ingo Molnar , Peter Zijlstra , Vincent Guittot , "Rafael J. Wysocki" , Viresh Kumar Cc: 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 v2] sched/uclamp: Fix a uninitialized variable warnings Date: Thu, 8 Dec 2022 14:51:08 +0000 Message-Id: <20221208145108.452032-1-qyousef@layalina.io> X-Mailer: git-send-email 2.25.1 In-Reply-To: <927e4ffc-8400-b615-2d58-9e88ee4bdc3c@arm.com> References: <927e4ffc-8400-b615-2d58-9e88ee4bdc3c@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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) --- Changes in v2: * Improve indentation as suggested by Dietmar 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 4cc56c91e06e..6a2fc2ca5078 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; @@ -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,24 +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))) { - 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; -- 2.25.1