From: Preeti U Murthy <preeti@linux.vnet.ibm.com>
To: Viresh Kumar <viresh.kumar@linaro.org>,
Rafael Wysocki <rjw@rjwysocki.net>
Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH 07/10] cpufreq: ondemand: queue work for policy->cpus together
Date: Fri, 26 Jun 2015 13:58:34 +0530 [thread overview]
Message-ID: <558D0D32.7060001@linux.vnet.ibm.com> (raw)
In-Reply-To: <66980e2b51a83bf34f6fd18ee55155b6c667aa6a.1434959517.git.viresh.kumar@linaro.org>
On 06/22/2015 01:32 PM, Viresh Kumar wrote:
> Currently update_sampling_rate() runs over each online CPU and
> cancels/queues work on it. Its very inefficient for the case where a
> single policy manages multiple CPUs, as they can be processed together.
>
> Also drop the unnecessary cancel_delayed_work_sync() as we are doing a
> mod_delayed_work_on() in gov_queue_work(), which will take care of
> pending works for us.
This looks fine, except for one point. See below:
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> drivers/cpufreq/cpufreq_ondemand.c | 32 ++++++++++++++++++++------------
> 1 file changed, 20 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
> index 841e1fa96ee7..cfecd3b67cb3 100644
> --- a/drivers/cpufreq/cpufreq_ondemand.c
> +++ b/drivers/cpufreq/cpufreq_ondemand.c
> @@ -247,40 +247,48 @@ static void update_sampling_rate(struct dbs_data *dbs_data,
> unsigned int new_rate)
> {
> struct od_dbs_tuners *od_tuners = dbs_data->tuners;
> + struct cpufreq_policy *policy;
> + struct od_cpu_dbs_info_s *dbs_info;
> + unsigned long next_sampling, appointed_at;
> + struct cpumask cpumask;
> int cpu;
>
> + cpumask_copy(&cpumask, cpu_online_mask);
> +
> od_tuners->sampling_rate = new_rate = max(new_rate,
> dbs_data->min_sampling_rate);
>
> - for_each_online_cpu(cpu) {
> - struct cpufreq_policy *policy;
> - struct od_cpu_dbs_info_s *dbs_info;
> - unsigned long next_sampling, appointed_at;
> -
> + for_each_cpu(cpu, &cpumask) {
> policy = cpufreq_cpu_get(cpu);
> if (!policy)
> continue;
> +
> + /* clear all CPUs of this policy */
> + cpumask_andnot(&cpumask, &cpumask, policy->cpus);
> +
> if (policy->governor != &cpufreq_gov_ondemand) {
> cpufreq_cpu_put(policy);
> continue;
> }
> +
> dbs_info = &per_cpu(od_cpu_dbs_info, cpu);
> cpufreq_cpu_put(policy);
>
> + /*
> + * Checking this for any CPU of the policy is fine. As either
> + * all would have queued work or none.
Are you sure that the state of the work will be the same across all
policy cpus ? 'Pending' only refers to twork awaiting for the timer to
fire and then queue itself on the runqueue right ? On some of the
policy->cpus, timers may be yet to fire, while on others it might
already have ?
> + */
> if (!delayed_work_pending(&dbs_info->cdbs.dwork))
> continue;
>
> next_sampling = jiffies + usecs_to_jiffies(new_rate);
> appointed_at = dbs_info->cdbs.dwork.timer.expires;
>
> - if (time_before(next_sampling, appointed_at)) {
> - cancel_delayed_work_sync(&dbs_info->cdbs.dwork);
> -
> - gov_queue_work(dbs_data, policy,
> - usecs_to_jiffies(new_rate),
> - cpumask_of(cpu));
> + if (!time_before(next_sampling, appointed_at))
> + continue;
>
> - }
> + gov_queue_work(dbs_data, policy, usecs_to_jiffies(new_rate),
> + policy->cpus);
> }
> }
>
Regards
Preeti U Murthy
next prev parent reply other threads:[~2015-06-26 8:28 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-22 8:02 [PATCH 00/10] cpufreq: governor: Further cleanups (v4.3) Viresh Kumar
2015-06-22 8:02 ` [PATCH 01/10] cpufreq: Use __func__ to print function's name Viresh Kumar
2015-06-23 15:39 ` Preeti U Murthy
2015-06-22 8:02 ` [PATCH 02/10] cpufreq: conservative: Avoid races with transition notifier Viresh Kumar
2015-06-23 15:53 ` Preeti U Murthy
2015-06-24 1:11 ` Viresh Kumar
2015-06-25 7:59 ` Viresh Kumar
2015-06-22 8:02 ` [PATCH 03/10] cpufreq: conservative: remove 'enable' field Viresh Kumar
2015-06-26 5:57 ` Preeti U Murthy
2015-06-26 6:19 ` Viresh Kumar
2015-06-22 8:02 ` [PATCH 04/10] cpufreq: ondemand: only queue canceled works from update_sampling_rate() Viresh Kumar
2015-06-26 6:50 ` Preeti U Murthy
2015-06-26 7:28 ` Viresh Kumar
2015-06-22 8:02 ` [PATCH 05/10] cpufreq: governor: Drop __gov_queue_work() Viresh Kumar
2015-06-26 7:03 ` Preeti U Murthy
2015-06-26 7:32 ` Viresh Kumar
2015-06-22 8:02 ` [PATCH 06/10] cpufreq: ondemand: Drop unnecessary locks from update_sampling_rate() Viresh Kumar
2015-06-26 7:20 ` Preeti U Murthy
2015-06-22 8:02 ` [PATCH 07/10] cpufreq: ondemand: queue work for policy->cpus together Viresh Kumar
2015-06-26 8:28 ` Preeti U Murthy [this message]
2015-06-26 8:52 ` Viresh Kumar
2015-06-22 8:02 ` [PATCH 08/10] cpufreq: ondemand: update sampling rate immidiately Viresh Kumar
2015-06-22 8:02 ` [PATCH 09/10] cpufreq: governor: Quit work-handlers early if governor is stopped Viresh Kumar
2015-06-22 8:02 ` [PATCH 10/10] cpufreq: Get rid of ->governor_enabled and its lock Viresh Kumar
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=558D0D32.7060001@linux.vnet.ibm.com \
--to=preeti@linux.vnet.ibm.com \
--cc=linaro-kernel@lists.linaro.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 NNTP newsgroup(s).