Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3957910rdg; Wed, 18 Oct 2023 10:31:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IENNzlqI8GHrtqseg58ZeZj/7nPCEVtCNHwOHQIniEg+wXSBJBQEceaP/BipFcPj4sNPyh9 X-Received: by 2002:a05:6a00:198c:b0:6ba:bd35:9efd with SMTP id d12-20020a056a00198c00b006babd359efdmr5826644pfl.5.1697650286152; Wed, 18 Oct 2023 10:31:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697650286; cv=none; d=google.com; s=arc-20160816; b=U5UEnNzpqaojDNCOkmmwu7dtp9cho6XLNWGmMSuPvMRYdiu1DLQ4oHitCVxUY/MSOj JW15J07mOQaLtI2n61CDKMp5O21kIgf54ORMowBNfW256RdvNFi7jgt3L/cwdckETx3O TQdFKaBQiKp9i7oqiG3ajqJ0HjRgtBaa6tRDxhz41Ma+arGDeS/skWILxBkHdVqMHIJZ 6Uk5SgM0bk66vJWpkZ24iwRrm4wS+u77lpBM+hAJYmjlIpzoT0hVj8OD0AAPghyeNTMd GPvifu2PYT7mZ0QT9lzq0+s0cTdA3YZuQS498NmWjK8iUdZ0hqmP1zISVY/rEMn80Tz3 Sb0g== 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=Bx2AwgVkOZOfV6LPsf8d4zE3dU+wr/dmHnMr0oF7wFQ=; fh=PSWA2Cew5QTMD2HMgWzLQIgCaRiQdRH2PK6uelRrXPs=; b=oz1m+Ob4pUnDI65Cxqw0K+U/Z83Iypy1i1I5ZHABMNg/sThXxRoyvaCc/Pqj0f8eiH QPBGnF+nyOT8sIfpSLvC7FS9xlHsSmhOZPnduRNd2RUYJheyW4NXRA1/9K4q9fN7h+QY IBGeI7N70eOTYqQvHydhWVivSTA/ihIXgO0EX7S9Bv1tky9Er9HYVnWnY9W6fSYVpRAE bSH5PvpoE+SnJpi5joXDsFt+XB2YUwPP9xgDdNSB5p/A9+7AegySsByEwPAO4k7782+t AYfcjPBQKlu8voIs3QWblTtEYEfjtLaPzKCWYkENcU0q2gPfxFqWmInhvrW2GcL+KV9o E+6g== 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:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id h11-20020a056a00170b00b0068e2d888713si4668828pfc.167.2023.10.18.10.31.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 10:31:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id F3D9980713E6; Wed, 18 Oct 2023 10:31:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231730AbjJRRag convert rfc822-to-8bit (ORCPT + 99 others); Wed, 18 Oct 2023 13:30:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231643AbjJRR3z (ORCPT ); Wed, 18 Oct 2023 13:29:55 -0400 Received: from mail-oo1-f43.google.com (mail-oo1-f43.google.com [209.85.161.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 699C63C0F; Wed, 18 Oct 2023 10:23:25 -0700 (PDT) Received: by mail-oo1-f43.google.com with SMTP id 006d021491bc7-582050ce2d8so25812eaf.0; Wed, 18 Oct 2023 10:23:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697649804; x=1698254604; 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=I2lwiFW7v1x6wJxRpx1c+ObPtw/kHFVlH2vUJpoYMn0=; b=AyN+NoPAVB8NQ1Jq3z4mylGl6Ae++nsCqlUsiob5kMuKBv7h8JL+ye1HEMthG0tvb1 NxmK0CS9Ig+jTtmNngI04vbRqXZKncEGAORkGmXGQWV6cJ8t52KSx4DpczqDZODYlZ8j q8KpPMO57QECLStv3uTuylzxo7WO4zyqRkrwquJ1RgeEod1AlyvBVhmpsCwp8WAn4Gl7 ryg3szxmrA3upeE7VjSuXQBwurv8j82xozg24GgwO5VMhCRJp2LjO4siPR93S+izqBiI I6NlahBmucbrDjYBLn4+ED5ck6rht4ynj1LuXSL/2NhqpuCaqz3c25gcGzdQECUJWqn4 ks6Q== X-Gm-Message-State: AOJu0YxpHvf0ViJg46ESn432olLBgRBMlCVdIhw7L8jwL/U9+yRTvJ1r 6ILbfEBG4dClBZy9ndSaay29+4N6Pr+C1uW4qpLnkQX7zf0= X-Received: by 2002:a05:6820:180f:b0:581:f17d:5eb5 with SMTP id bn15-20020a056820180f00b00581f17d5eb5mr3255065oob.0.1697649804594; Wed, 18 Oct 2023 10:23:24 -0700 (PDT) MIME-Version: 1.0 References: <20231018162540.667646-1-vincent.guittot@linaro.org> <20231018162540.667646-3-vincent.guittot@linaro.org> In-Reply-To: <20231018162540.667646-3-vincent.guittot@linaro.org> From: "Rafael J. Wysocki" Date: Wed, 18 Oct 2023 19:23:13 +0200 Message-ID: Subject: Re: [PATCH v3 2/6] cpufreq: use the fixed and coherent frequency for scaling capacity To: Vincent Guittot Cc: 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, conor.dooley@microchip.com, suagrfillet@gmail.com, ajones@ventanamicro.com, lftan@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 18 Oct 2023 10:31:06 -0700 (PDT) On Wed, Oct 18, 2023 at 6:25 PM Vincent Guittot 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 > Acked-by: Viresh Kumar > Reviewed-by: Lukasz Luba > Tested-by: Lukasz Luba Acked-by: Rafael J. Wysocki > --- > 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 >