From: Pierre Gondois <pierre.gondois@arm.com>
To: Yang Shi <yang@os.amperecomputing.com>
Cc: viresh.kumar@linaro.org, scott@os.amperecomputing.com,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
"Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: [PATCH] cpufreq: CPPC: use 10ms delay instead of 2us to avoid high error
Date: Wed, 19 Apr 2023 18:52:47 +0200 [thread overview]
Message-ID: <41ae3b9e-c774-5061-b045-d5ec2a658880@arm.com> (raw)
In-Reply-To: <a2924821-80b9-e68f-3ae4-7a2c989afc88@arm.com>
>
> Just 2 other comments:
> a-
> It might be interesting to change the order in which cpc registers are read
> just to see if it has an impact, but even if it has, I m not sure how this
> could be exploitable.
> Just in case, I mean doing that, but I think that b. might be better to try.
>
> diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
> index c51d3ccb4cca..479b55006020 100644
> --- a/drivers/acpi/cppc_acpi.c
> +++ b/drivers/acpi/cppc_acpi.c
> @@ -1350,8 +1350,8 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
> }
> }
>
> - cpc_read(cpunum, delivered_reg, &delivered);
> cpc_read(cpunum, reference_reg, &reference);
> + cpc_read(cpunum, delivered_reg, &delivered);
> cpc_read(cpunum, ref_perf_reg, &ref_perf);
>
> /*
>
> b-
> In the trace that you shared, the cpc_read() calls in the fist
> cppc_get_perf_ctrs() calls seem to always take a bit more time than in the
> second cppc_get_perf_ctrs() call.
> Would it be possible to collect traces similar as above with 3 or 4 calls to
> cppc_get_perf_ctrs() instead of 2 ? It would allow to check whether in the first
> call, accessing the cpc registers takes more time than in the following calls,
> due to cache misses or other reasons.
> Ideally statistics on the result would be the best, or if you have a trace.dat
> to share containing a trace with multiple cppc_cpufreq_get_rate() calls.
>
> Example of code where we do 4 calls to cppc_get_perf_ctrs():
>
> diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
> index 022e3555407c..6370f2f0bdad 100644
> --- a/drivers/cpufreq/cppc_cpufreq.c
> +++ b/drivers/cpufreq/cppc_cpufreq.c
> @@ -853,6 +853,20 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpu)
>
> udelay(2); /* 2usec delay between sampling */
>
> + ret = cppc_get_perf_ctrs(cpu, &fb_ctrs_t1);
> + if (ret)
> + return ret;
> +
> + udelay(2); /* 2usec delay between sampling */
> +
> + /* Do a third call. */
> + ret = cppc_get_perf_ctrs(cpu, &fb_ctrs_t1);
> + if (ret)
> + return ret;
> +
> + udelay(2); /* 2usec delay between sampling */
> +
> + /* Do a fourth call. */
> ret = cppc_get_perf_ctrs(cpu, &fb_ctrs_t1);
> if (ret)
> return ret;
And also, if the cpc_read() calls in the third/fourth call are actually faster,
would it be possible to check whether the computed frequency is more accurate
(i.e. no over/undershoot) ?
next prev parent reply other threads:[~2023-04-19 16:53 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-28 19:38 Yang Shi
2023-03-29 18:43 ` Rafael J. Wysocki
2023-03-29 23:22 ` Yang Shi
2023-04-04 19:07 ` Yang Shi
2023-04-05 17:57 ` Pierre Gondois
2023-04-06 21:52 ` Yang Shi
2023-04-07 8:31 ` Pierre Gondois
2023-04-07 22:19 ` Yang Shi
2023-04-11 8:51 ` Pierre Gondois
2023-04-18 18:24 ` Yang Shi
2023-04-19 9:45 ` Pierre Gondois
2023-04-19 16:52 ` Pierre Gondois [this message]
2023-04-19 20:40 ` Yang Shi
2023-04-20 16:01 ` Pierre Gondois
2023-04-20 20:49 ` Yang Shi
2023-04-24 11:44 ` Ionela Voinescu
2023-04-26 1:32 ` Yang Shi
2023-04-26 19:01 ` Ionela Voinescu
2023-04-27 20:40 ` Yang Shi
2023-04-28 11:02 ` Sumit Gupta
2023-03-30 3:56 ` Viresh Kumar
2023-03-31 9:53 ` Pierre Gondois
2023-04-04 18:57 ` Yang Shi
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=41ae3b9e-c774-5061-b045-d5ec2a658880@arm.com \
--to=pierre.gondois@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=scott@os.amperecomputing.com \
--cc=viresh.kumar@linaro.org \
--cc=yang@os.amperecomputing.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
all inboxes | Powered by JetHome®