Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2081021rdh; Tue, 26 Sep 2023 11:44:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEW/gYO6ztY/c/XiDBz2F1Q9rUKWO8ptBjwQ+uqdUelVXZGJNLc5rFT8QuRcf7Zgnigic8W X-Received: by 2002:a05:6358:912:b0:132:d333:4a5c with SMTP id r18-20020a056358091200b00132d3334a5cmr13101737rwi.10.1695753854617; Tue, 26 Sep 2023 11:44:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695753854; cv=none; d=google.com; s=arc-20160816; b=NR+CgAuAIQGWTOUkzNRuDvI6odKRWDl2yEWHg8Tfx2+4xZ1c/ljsvIt1NxLYPfVTib PAI9sMSuTICiKykRJBRAkrlmWLPOqrs2iJAeE95frLFEWarf64JMOQn8JISxWxjve/jw xJf/gdxCSQ+hsRl19lNEW+Q5nQRyHM8iopQFT+ePxjjv9WKArKYVT3B1MmoRWWDu3sdX 4zAmdBH4FP434e56byrfvPP/zqRhH1yXKGDypxljI3uRmUDzFT4WkQtlHtxZKpslxA4M Ij7S7MTVZ33wpegQYHjsHfq819QUQc15FIqMTwYjFxLlwLFXyjPePbiJj+rck40tfW2Z OGDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=QI44H0pS0KvhjX9b3K69jTe9Hn2rkhO1OEoXrlBLpIU=; fh=O6YYF95gEoTquszwa1x1Mp3NZS9Am1klEUxdtkLeXmY=; b=PFv3f07cXnr08RI5av0ezftcKcdt/6ofGBT9ETaBDrTHnIiobaM2MKOP+icp6xhLr4 TL923g15JwLmoVqHRs9JUnAQxQGiCtiIVDsc1pptkYs9QqUXHNStLCxtAjqKA9/bYAeI Uqo2DQALHpru893ASJut4E2gAONnz8oPnj+Ka0jzdM4fvSLbagFDkwrc/BWqheAVRZGk iChD1ggmsK3YOsjDmYtmux7sjRtsQkUbRqUc+PkuIwO9TMXYcppP4XDIGW7ymrRQ93xN G1XtUMAktMh3kGrQOugLgMqeHRC7n5vSpuGDjmdA04j/ZTgHpG3JYNjpoqJ9oGJPsmuX 8OXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id y187-20020a638ac4000000b00578d0d070f4si13039134pgd.844.2023.09.26.11.44.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 11:44:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 4E310811F247; Tue, 26 Sep 2023 11:33:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235481AbjIZScw convert rfc822-to-8bit (ORCPT + 99 others); Tue, 26 Sep 2023 14:32:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229885AbjIZScv (ORCPT ); Tue, 26 Sep 2023 14:32:51 -0400 Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69619BF; Tue, 26 Sep 2023 11:32:45 -0700 (PDT) Received: by mail-oo1-f46.google.com with SMTP id 006d021491bc7-57b83ff7654so229527eaf.1; Tue, 26 Sep 2023 11:32:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695753164; x=1696357964; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rlwH9j7aEpiUK7f0oRPeOnDbGJAgp1YU3tyVHfKNU4A=; b=DNLhFY6mqrQsDfd2H/OQ/Vj8cPyqAbVLPlTccG56DjjMQJEeQAa1pLpALxogwyzDG4 Lr7O1aBPn4CbdDw+KfRfWv6rIH70v1The8YrrvNcjfpVWQbCBBuPa9GzmXVBcXHsUdH+ 1cZvaNCZgyHiBNz1DPk6B59bZ/F/6pbI9XzJ9yLd1Tih+IsL5uKJeTjFQp0Lpnp+YnBo s4g62i9BMGPSflsNNZDHWf7fWwI5diIvcnlg5rYu88wDs6O2JI0zRIbloU/6w2trqLB2 JS4J9DY16Jtx+vRvuRFcxisucMoPI9Cd1N0UqYhUWCnrA17gtHB7bVxW+7wCVlWtzJyw 6deg== X-Gm-Message-State: AOJu0YwmQW1NS+kuu15+BsBRabQM7zCW3EZM7/EN9zn0ZFkIkmVZcdPX TomjFdutJIpZ/gf/vrnoejusOUG78nLw9bn1NkrgVOhrGDc= X-Received: by 2002:a05:6870:f689:b0:1d5:f814:56a3 with SMTP id el9-20020a056870f68900b001d5f81456a3mr9566114oab.2.1695753164734; Tue, 26 Sep 2023 11:32:44 -0700 (PDT) MIME-Version: 1.0 References: <20230925081139.1305766-1-lukasz.luba@arm.com> <20230925081139.1305766-4-lukasz.luba@arm.com> In-Reply-To: <20230925081139.1305766-4-lukasz.luba@arm.com> From: "Rafael J. Wysocki" Date: Tue, 26 Sep 2023 20:32:33 +0200 Message-ID: Subject: Re: [PATCH v4 03/18] PM: EM: Find first CPU online while updating OPP efficiency To: Lukasz Luba Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org, dietmar.eggemann@arm.com, rui.zhang@intel.com, amit.kucheria@verdurent.com, amit.kachhap@gmail.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org, len.brown@intel.com, pavel@ucw.cz, mhiramat@kernel.org, qyousef@layalina.io, wvw@google.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 26 Sep 2023 11:33:00 -0700 (PDT) On Mon, Sep 25, 2023 at 10:11 AM Lukasz Luba wrote: > > The Energy Model might be updated at runtime and the energy efficiency > for each OPP may change. Thus, there is a need to update also the > cpufreq framework and make it aligned to the new values. In order to > do that, use a first online CPU from the Performance Domain. > > Signed-off-by: Lukasz Luba > --- > kernel/power/energy_model.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c > index 42486674b834..3dafdd7731c4 100644 > --- a/kernel/power/energy_model.c > +++ b/kernel/power/energy_model.c > @@ -243,12 +243,19 @@ em_cpufreq_update_efficiencies(struct device *dev, struct em_perf_state *table) > struct em_perf_domain *pd = dev->em_pd; > struct cpufreq_policy *policy; > int found = 0; > - int i; > + int i, cpu; > > if (!_is_cpu_device(dev) || !pd) > return; > > - policy = cpufreq_cpu_get(cpumask_first(em_span_cpus(pd))); > + /* Try to get a CPU which is online and in this PD */ > + cpu = cpumask_first_and(em_span_cpus(pd), cpu_active_mask); The comment talks about "online" and cpu_active_mask is used. Isn't it a bit inconsistent? > + if (cpu >= nr_cpu_ids) { > + dev_warn(dev, "EM: No online CPU for CPUFreq policy\n"); > + return; > + } > + > + policy = cpufreq_cpu_get(cpu); > if (!policy) { > dev_warn(dev, "EM: Access to CPUFreq policy failed\n"); > return; > -- > 2.25.1 >