Message ID | 20231018162540.667646-3-vincent.guittot@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4913302vqb; Wed, 18 Oct 2023 09:27:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGioo6EIjbcv6K+RcE4WUE6bU1Fy3bmlOORRqGDygHjMqNP16b/aglGDP+KHF7N4P+Q6mNg X-Received: by 2002:a05:6830:25d2:b0:6bd:bba9:2d63 with SMTP id d18-20020a05683025d200b006bdbba92d63mr7049163otu.9.1697646434099; Wed, 18 Oct 2023 09:27:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697646434; cv=none; d=google.com; s=arc-20160816; b=YTKdVaSLFnfaFVQr6+TNbmRUA64eaFfjYaNmgDiw+eIb/shH73eHcZzWHnDa8fEejV 1tiri6qXRKlNou+yHSl2UEploqvC8axUNeyeO4c/mGrkS/JpQiBOiJNVJg1bQvx7dGfF 3xouv1e/UveGdraj+FwqQ8/aqhamVWULKedTxH+aZKbXcgbVhLtLAqTJwO0UwBfIE1JU X2soL+4+pAsE2YiFYk3ypBXg2TTTHn+NVm2XUW6HXBta7MD8a42x66Wz2e+XqBxwt2Z2 jS+WmNo1S2QvTyqtathW6IUo6WQKU5fXbimlAzVPw+5VKxb7AdgT7DjgDOiauFGM9XRl Yn9g== 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=/Z47rGwNrqDmeGZQL2+O4h6n0CW6ulSbmPrUuoIVrkg=; fh=aqXlZKEuqBn32GiqXwfBTBEPXMVE+dzbtwpLcW+Wljc=; b=wJ/gP+OmmvJuXJhPWZGU+U9fRFzOawYCp1LnKvpxse8nf6f+VUT47qspZ7nDfBmmo4 lRZE+n3U+hJrv+K/f/pB9aJ98xr4ibVA2NxGS/V8pzggMWCEK9XYNXPA5xMvDS56vO/e s+H7MykGEevxmW8nmWW5zLP+YBipIfmZtq/y21Qe6/UarBP12L6lfPNwtuLhMkgdtAbl OCT5hAhuOXowZV+NdPsdT7mRxzDuh13hf6+Lig9WjtcabZZ1ydSROFrH2X7bfuZyYliO EARP5tuQqRhIWrpMMhWIndVX+zavnguSuT7cM6ZBMrd9v5J0yK2McJ9Gi2JqR02jgQuG mvtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f85jNDyj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id y25-20020a056a00181900b00690c23d353asi4599448pfa.217.2023.10.18.09.27.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:27:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f85jNDyj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 5E33C80ACEF0; Wed, 18 Oct 2023 09:27:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232684AbjJRQ0D (ORCPT <rfc822;zwp10758@gmail.com> + 24 others); Wed, 18 Oct 2023 12:26:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231615AbjJRQZy (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 18 Oct 2023 12:25:54 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE8DE111 for <linux-kernel@vger.kernel.org>; Wed, 18 Oct 2023 09:25:49 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40837ebba42so11655235e9.0 for <linux-kernel@vger.kernel.org>; Wed, 18 Oct 2023 09:25:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697646348; x=1698251148; darn=vger.kernel.org; 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=/Z47rGwNrqDmeGZQL2+O4h6n0CW6ulSbmPrUuoIVrkg=; b=f85jNDyj+YCeVocfqQ9Wnfs6HCEUPsoxfnev59jx74f0GdAE6LnN6JA1kxfwn44r0M QcVN7Ajxs4kNGmRdV91XHS5Bf1UALo7T1EguSZOqENx96Qe2d/+ExLpKKIhs1JBk3B59 o3ekzF3iMtipAtwxwcYx0KL1AyMDSdwQTJq7oqTJ3tOhAyatLMYYLUYmHLhxBBD8dKI9 +LMqXKotmIDdJLSjCVO4QvGu8lpa1JlnfYYDR5ST9NPaVElWRC6o31ezWTF0ZX3PwgMi xg09U1UdhUXKCtLMlM71gEnWP4mF4zSN0KvGVwUJUkfUQQbHe0NCpUnRzRYHibAr29Tk 7PpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697646348; x=1698251148; 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=/Z47rGwNrqDmeGZQL2+O4h6n0CW6ulSbmPrUuoIVrkg=; b=jZwp6Lo7A/0hk027RPr5wrwBhFqTpiY4BVa0QDsjKGzWjDhAoI4FX3omGYYLuoGqkr GhgCv8SP0k47eiuEgW2b87tXdDBLcWA/++6EXa6ihUeJzlLUMd47hVv4KfUrgqHqMfYL tNR6LMUxJ5tmCVEh7rpVpTxf0EB7I3pLAM2U90aNGqigXxwLepIAQrRN3VAh3AAx7Da7 ch6NKhGmoVh9NTvtrd5scW5PFXNuYvvvwBS4nFS+21XQx3iBl+mizDV/psDp9Jx1QQHb 37D9XeVqUIbM1GNE7HCgoVoPmHcckZFjkL+TYmIg+/yYHTMunZzF7/aDWhBoOxyyotwf bDZQ== X-Gm-Message-State: AOJu0YyQ4lBTGGmZ93KK+Xrp17TTOqwKhWvXagNI2lTi4/66nG0EGa8A VKxMEsKG1wpOP+qTtLnhZWlUqg== X-Received: by 2002:a05:600c:4f15:b0:401:bdd7:49ae with SMTP id l21-20020a05600c4f1500b00401bdd749aemr4828030wmq.18.1697646348170; Wed, 18 Oct 2023 09:25:48 -0700 (PDT) Received: from vingu-book.. ([2a01:e0a:f:6020:fcf4:9d83:8d0d:39aa]) by smtp.gmail.com with ESMTPSA id q12-20020a05600c2e4c00b0040648217f4fsm2033503wmf.39.2023.10.18.09.25.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:25:47 -0700 (PDT) From: Vincent Guittot <vincent.guittot@linaro.org> To: linux@armlinux.org.uk, catalin.marinas@arm.com, will@kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, sudeep.holla@arm.com, gregkh@linuxfoundation.org, rafael@kernel.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, viresh.kumar@linaro.org, lenb@kernel.org, robert.moore@intel.com, lukasz.luba@arm.com, ionela.voinescu@arm.com, pierre.gondois@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linuxfoundation.org Cc: conor.dooley@microchip.com, suagrfillet@gmail.com, ajones@ventanamicro.com, lftan@kernel.org, Vincent Guittot <vincent.guittot@linaro.org> Subject: [PATCH v3 2/6] cpufreq: use the fixed and coherent frequency for scaling capacity Date: Wed, 18 Oct 2023 18:25:36 +0200 Message-Id: <20231018162540.667646-3-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231018162540.667646-1-vincent.guittot@linaro.org> References: <20231018162540.667646-1-vincent.guittot@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 howler.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 18 Oct 2023 09:27:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780111307110461042 X-GMAIL-MSGID: 1780111307110461042 |
Series |
consolidate and cleanup CPU capacity
|
|
Commit Message
Vincent Guittot
Oct. 18, 2023, 4:25 p.m. UTC
cpuinfo.max_freq can change at runtime because of boost as an example. This implies that the value could be different from the frequency that has been used to compute the capacity of a CPU. The new arch_scale_freq_ref() returns a fixed and coherent frequency that can be used to compute the capacity for a given frequency. Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Tested-by: Lukasz Luba <lukasz.luba@arm.com> --- drivers/cpufreq/cpufreq.c | 4 ++-- include/linux/cpufreq.h | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-)
Comments
On Wed, Oct 18, 2023 at 6:25 PM Vincent Guittot <vincent.guittot@linaro.org> wrote: > > cpuinfo.max_freq can change at runtime because of boost as an example. This > implies that the value could be different from the frequency that has been > used to compute the capacity of a CPU. > > The new arch_scale_freq_ref() returns a fixed and coherent frequency > that can be used to compute the capacity for a given frequency. > > Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org> > Acked-by: Viresh Kumar <viresh.kumar@linaro.org> > Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> > Tested-by: Lukasz Luba <lukasz.luba@arm.com> Acked-by: Rafael J. Wysocki <rafael@kernel.org> > --- > drivers/cpufreq/cpufreq.c | 4 ++-- > include/linux/cpufreq.h | 9 +++++++++ > 2 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 60ed89000e82..8c4f9c2f9c44 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -454,7 +454,7 @@ void cpufreq_freq_transition_end(struct cpufreq_policy *policy, > > arch_set_freq_scale(policy->related_cpus, > policy->cur, > - policy->cpuinfo.max_freq); > + arch_scale_freq_ref(policy->cpu)); > > spin_lock(&policy->transition_lock); > policy->transition_ongoing = false; > @@ -2174,7 +2174,7 @@ unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy, > > policy->cur = freq; > arch_set_freq_scale(policy->related_cpus, freq, > - policy->cpuinfo.max_freq); > + arch_scale_freq_ref(policy->cpu)); > cpufreq_stats_record_transition(policy, freq); > > if (trace_cpu_frequency_enabled()) { > diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h > index 71d186d6933a..bbc483b4b6e5 100644 > --- a/include/linux/cpufreq.h > +++ b/include/linux/cpufreq.h > @@ -1211,6 +1211,15 @@ void arch_set_freq_scale(const struct cpumask *cpus, > { > } > #endif > + > +#ifndef arch_scale_freq_ref > +static __always_inline > +unsigned int arch_scale_freq_ref(int cpu) > +{ > + return 0; > +} > +#endif > + > /* the following are really really optional */ > extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; > extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs; > -- > 2.34.1 >
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 60ed89000e82..8c4f9c2f9c44 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -454,7 +454,7 @@ void cpufreq_freq_transition_end(struct cpufreq_policy *policy, arch_set_freq_scale(policy->related_cpus, policy->cur, - policy->cpuinfo.max_freq); + arch_scale_freq_ref(policy->cpu)); spin_lock(&policy->transition_lock); policy->transition_ongoing = false; @@ -2174,7 +2174,7 @@ unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy, policy->cur = freq; arch_set_freq_scale(policy->related_cpus, freq, - policy->cpuinfo.max_freq); + arch_scale_freq_ref(policy->cpu)); cpufreq_stats_record_transition(policy, freq); if (trace_cpu_frequency_enabled()) { diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 71d186d6933a..bbc483b4b6e5 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -1211,6 +1211,15 @@ void arch_set_freq_scale(const struct cpumask *cpus, { } #endif + +#ifndef arch_scale_freq_ref +static __always_inline +unsigned int arch_scale_freq_ref(int cpu) +{ + return 0; +} +#endif + /* the following are really really optional */ extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs;