From: Jeremy Linton <jeremy.linton@arm.com>
To: Breno Leitao <leitao@debian.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
Jie Zhan <zhanjie9@hisilicon.com>,
Lifeng Zheng <zhenglifeng1@huawei.com>,
Pierre Gondois <pierre.gondois@arm.com>,
Sumit Gupta <sumitg@nvidia.com>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
dcostantino@meta.com, pjaroszynski@nvidia.com, Al.Grant@arm.com,
linux-arm-kernel@lists.infradead.org, kernel-team@meta.com
Subject: Re: [PATCH] cpufreq: cppc: discard out-of-range delivered_perf samples
Date: Fri, 1 May 2026 12:41:45 -0500 [thread overview]
Message-ID: <7e55dd1e-2841-4918-8e3d-82203a70451a@arm.com> (raw)
In-Reply-To: <20260501-cur_freq-fix-v1-1-f84c9a423366@debian.org>
Hi,
On 5/1/26 11:32 AM, Breno Leitao wrote:
> cppc_cpufreq_get_rate() derives delivered_perf as:
>
> delivered_perf = reference_perf * delta_delivered / delta_reference
>
> over a short udelay()-bounded window between two cppc_get_perf_ctrs()
> calls. Per-read latency jitter on the underlying CPC register access
> can skew the ratio, occasionally producing delivered_perf >
> highest_perf. cppc_perf_to_khz() then linearly extrapolates above
> (nominal_perf, nominal_freq), so the value reported via
> /sys/.../cpufreq/cpuinfo_cur_freq exceeds cpuinfo_max_freq.
>
> Observed on an arm64 host (governor=performance,
> cpuinfo_max_freq=3339 MHz): 15 back-to-back reads returned values
> between 2997 and 4230 MHz.
>
> Treat an out-of-range sample as invalid and reuse the existing
> out_invalid_counters fallback, which returns the platform's
> desired_perf. This keeps cpuinfo_cur_freq within
> [0, cpuinfo_max_freq] without reporting a value the hardware did
> not deliver.
>
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
> drivers/cpufreq/cppc_cpufreq.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
> index 7e7f9dfb7a24c..dd92aa2bca464 100644
> --- a/drivers/cpufreq/cppc_cpufreq.c
> +++ b/drivers/cpufreq/cppc_cpufreq.c
> @@ -814,6 +814,14 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpu)
> if (!delivered_perf)
> goto out_invalid_counters;
>
> + /*
> + * Sampling jitter on the CPC counter pair can produce
> + * delivered_perf > highest_perf, which cppc_perf_to_khz() would
> + * extrapolate to a frequency above cpuinfo_max_freq. Discard.
> + */
> + if (delivered_perf > cpu_data->perf_caps.highest_perf)
> + goto out_invalid_counters;
> +
A little jitter over, is probably expected. If that is what is happening
then clamping to highest_perf makes sense instead. But then, this is
really a sampling problem so does it go away if you double the udelay
slightly. Maybe the udelay value should be proportional to the
reference_perf value?
> return cppc_perf_to_khz(&cpu_data->perf_caps, delivered_perf);
>
> out_invalid_counters:
>
> ---
> base-commit: 26fd6bff2c050196005312d1d306889220952a99
> change-id: 20260501-cur_freq-fix-d569cf1d1052
>
> Best regards,
> --
> Breno Leitao <leitao@debian.org>
>
>
next prev parent reply other threads:[~2026-05-01 17:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-01 16:32 [PATCH] cpufreq: cppc: discard out-of-range delivered_perf samples Breno Leitao
2026-05-01 17:41 ` Jeremy Linton [this message]
2026-05-05 12:52 ` Breno Leitao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7e55dd1e-2841-4918-8e3d-82203a70451a@arm.com \
--to=jeremy.linton@arm.com \
--cc=Al.Grant@arm.com \
--cc=dcostantino@meta.com \
--cc=kernel-team@meta.com \
--cc=leitao@debian.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pierre.gondois@arm.com \
--cc=pjaroszynski@nvidia.com \
--cc=rafael@kernel.org \
--cc=sumitg@nvidia.com \
--cc=viresh.kumar@linaro.org \
--cc=zhanjie9@hisilicon.com \
--cc=zhenglifeng1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox