Message ID | 20221127141742.1644023-2-qyousef@layalina.io |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5138249wrr; Sun, 27 Nov 2022 06:18:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf49ZAaqiLj0ETHKvsebmhHM2mwZk/6DplE6sKmTIVwYrQ+pBo0usjkoJ62zy23Xunr73yNh X-Received: by 2002:a63:4a0c:0:b0:477:a63e:bdad with SMTP id x12-20020a634a0c000000b00477a63ebdadmr21891467pga.254.1669558713950; Sun, 27 Nov 2022 06:18:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669558713; cv=none; d=google.com; s=arc-20160816; b=GGRtt5m2UrEj1QifVFzwHN/nlNPniW1d8lFvdiaKWQvbU2K7aOwVlQen49CfsiZ2D6 L/icP46DThE+Bon4Xnzrnk49cK+rFveZHIT6ZiknsKGCC2tx5v/eobcRoUsSVis/hHlu 9JF6GyZMVsTC6yeOPMbKxd79iKnIIAMRM8moIL4xM1hQ6l8E4kFD1MaYFx2GblCSQt73 4dlJQAfs/kdAyP6HVdN6zwLFWRy1rKK4fJ2iCJkEbs7+bgu4Sz19NLOTKuyHy2HaTXzQ gvcRfoQN8m3GTs63XKbWFzDI71fWeDbtFUNurGpOmoXcJ3NoDX85Fa+FXmbr2YOVDL70 Yujg== 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=jkAjMv32NBv57ip/jp/OcgWLx4nOD1X2Vve6sHHv9TI=; b=UVZbr35GBBJsmXF1hPyfOUIWDyJECkVYjPKj++lSI5IBWI+5gaXrMNRMrHK6qK9M+t WKhxgmskWRGJGWJlCn7/yQzSZguBowEKI1h0o4i9GIwtAurEA67yPopu18xxhQ7FmjXW CjqN+mfxs6BJjWB/yS6Ub082p5dGiofWOF6sWl4jupDNp6Yczq2iViV+wKvOc1sQ3QMX nQ6aWWrl0/P0NAp6vn2QnwipLJgoR9teV+7AWNaKtpDT4kze8l3ElaDzEPyvFVTZkp/c Tw8nqk4zZuneTIBR/wLhkrt89hOxvbfljnmXUpTbLTHCF8VTvFQ0/59xHmEqUCm1oMAi jtNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@layalina-io.20210112.gappssmtp.com header.s=20210112 header.b=wJlclZrh; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d11-20020a63fd0b000000b00462f77bcd1esi10213592pgh.90.2022.11.27.06.18.21; Sun, 27 Nov 2022 06:18:33 -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=wJlclZrh; 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 S229551AbiK0OSG (ORCPT <rfc822;chrisjones.unixmen@gmail.com> + 99 others); Sun, 27 Nov 2022 09:18:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229575AbiK0OSD (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 27 Nov 2022 09:18:03 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E26A3D2CE for <linux-kernel@vger.kernel.org>; Sun, 27 Nov 2022 06:18:02 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id x17so13092417wrn.6 for <linux-kernel@vger.kernel.org>; Sun, 27 Nov 2022 06:18:02 -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=jkAjMv32NBv57ip/jp/OcgWLx4nOD1X2Vve6sHHv9TI=; b=wJlclZrhZWJJLY4gKqU4fQES98mqQVQVDUvCpoKE/Gxf7/HXho4CZNyqW4HxaSaA8A c4Rjl2N+yZDHwIz+TAKQHxMqUl+6iz1cx7iGstjJmiuD05BD7sCFybcXGkR9d0ny+yOK oBI9Db0+HQLdyQEvb2TKypAG3NuYTaMHOr0n8Taxd1S1qcrD8epAUsRBTxFnX8FXmZr4 Jx85SCM6w8UUOtYtI6O0RQ4QKnK30quLo6pY9yXuC96P5PcAq/sfrmUvfOke+4yWCGYj CRmQyr1HTCipxjci3vu5VuqXHFsqJ/5DDx6F2y0Oa/6P+h5DcAMu8eo7y35OSd5E31y7 +XvA== 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=jkAjMv32NBv57ip/jp/OcgWLx4nOD1X2Vve6sHHv9TI=; b=KtHjj0J4rSF/n9+6eZ6EwgX983/ekLVaccZKKliDsqBHfF80wXxk1NhWHUYIbcQ/yZ 3e0+QBn1h9KuqLgBbuOqvDD3JIu/lMo6MPWeYa5wKsioQanWkKWBZ//5E0iKXJah+6zy rIs6PE90OtmBYEsXIUMq+6toUO0E2i2PC7r5fHLAFiXDoIF1wibN2CD8IwgagwI0wv+0 UQcfrZRNKJjwxIzlaxD5Fn2VWI0qnDiFJyyC0uqwqeBRLZWBlcFoNs9igRH0X3VULwPs LIuh82bVjlSFtr1NeYV3WwmLEYWcVGchucbiC1x/tMOrPlwCqSxAKpKethik9Zs7ActJ LeBw== X-Gm-Message-State: ANoB5pn4ZYZhaJ/ZWAEjIus/QkOxv5yn7ceGFDFRR8120YMSAwFMybnc D9Es0jub1P5cr3rMDIz55HsrCg== X-Received: by 2002:a5d:4149:0:b0:242:149c:5690 with SMTP id c9-20020a5d4149000000b00242149c5690mr1303871wrq.491.1669558681519; Sun, 27 Nov 2022 06:18:01 -0800 (PST) Received: from localhost.localdomain (host86-130-134-87.range86-130.btcentralplus.com. [86.130.134.87]) by smtp.gmail.com with ESMTPSA id l1-20020a05600c4f0100b003c6f3f6675bsm17109757wmq.26.2022.11.27.06.18.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Nov 2022 06:18:01 -0800 (PST) From: Qais Yousef <qyousef@layalina.io> To: Ingo Molnar <mingo@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Vincent Guittot <vincent.guittot@linaro.org>, Dietmar Eggemann <dietmar.eggemann@arm.com>, "Rafael J. Wysocki" <rafael@kernel.org>, Viresh Kumar <viresh.kumar@linaro.org> Cc: 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>, Qais Yousef <qyousef@layalina.io>, kernel test robot <lkp@intel.com>, Dan Carpenter <error27@gmail.com> Subject: [PATCH 1/3] sched/uclamp: Fix a uninitialized variable warnings Date: Sun, 27 Nov 2022 14:17:40 +0000 Message-Id: <20221127141742.1644023-2-qyousef@layalina.io> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221127141742.1644023-1-qyousef@layalina.io> References: <20221127141742.1644023-1-qyousef@layalina.io> 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750659198338246921?= X-GMAIL-MSGID: =?utf-8?q?1750659198338246921?= |
Series |
Fixes for uclamp and capacity inversion detection
|
|
Commit Message
Qais Yousef
Nov. 27, 2022, 2:17 p.m. UTC
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(-)
Comments
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? 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;
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;
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