From: Stratos Karafotis <stratosk@semaphore.gr>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Viresh Kumar <viresh.kumar@linaro.org>
Cc: "cpufreq@vger.kernel.org" <cpufreq@vger.kernel.org>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] cpufreq: Break out early when frequency equals target_freq
Date: Thu, 08 May 2014 18:46:09 +0300 [thread overview]
Message-ID: <536BA6C1.5000200@semaphore.gr> (raw)
In-Reply-To: <53600B71.2050904@semaphore.gr>
On 29/04/2014 11:28 μμ, Stratos Karafotis wrote:
> Many drivers keep frequencies in frequency table in ascending
> or descending order. When governor tries to change to policy->min
> or policy->max respectively then the cpufreq_frequency_table_target
> could return on first iteration. This will save some iteration cycles.
>
> So, break out early when a frequency in cpufreq_frequency_table
> equals to target one.
>
> Testing this during kernel compilation using ondemand governor
> with a frequency table in ascending order, the
> cpufreq_frequency_table_target returned early on the first
> iteration at about 30% of times called.
>
> Signed-off-by: Stratos Karafotis <stratosk@semaphore.gr>
> ---
> drivers/cpufreq/freq_table.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
> index 8e518c6..1632981 100644
> --- a/drivers/cpufreq/freq_table.c
> +++ b/drivers/cpufreq/freq_table.c
> @@ -137,9 +137,13 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
> i = pos - table;
> if ((freq < policy->min) || (freq > policy->max))
> continue;
> + if (freq == target_freq) {
> + optimal.driver_data = i;
> + break;
> + }
> switch (relation) {
> case CPUFREQ_RELATION_H:
> - if (freq <= target_freq) {
> + if (freq < target_freq) {
> if (freq >= optimal.frequency) {
> optimal.frequency = freq;
> optimal.driver_data = i;
> @@ -152,7 +156,7 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
> }
> break;
> case CPUFREQ_RELATION_L:
> - if (freq >= target_freq) {
> + if (freq > target_freq) {
> if (freq <= optimal.frequency) {
> optimal.frequency = freq;
> optimal.driver_data = i;
>
Gentle reminder.
Thanks,
Stratos
prev parent reply other threads:[~2014-05-08 15:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-29 20:28 [PATCH] cpufreq: Break out early when frequency equals target_freq Stratos Karafotis
2014-05-08 15:46 ` Stratos Karafotis [this message]
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=536BA6C1.5000200@semaphore.gr \
--to=stratosk@semaphore.gr \
--cc=cpufreq@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=viresh.kumar@linaro.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).