From: Viresh Kumar <viresh.kumar@linaro.org>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org,
preeti.lkml@gmail.com, open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V2 3/9] cpufreq: ondemand: only queue canceled works from update_sampling_rate()
Date: Tue, 8 Sep 2015 07:28:31 +0530 [thread overview]
Message-ID: <20150908015831.GY26760@linux> (raw)
In-Reply-To: <1806697.T1XSqGqSN5@vostro.rjw.lan>
On 08-09-15, 03:11, Rafael J. Wysocki wrote:
> There really are two cases, either you pass a CPU or gov_queue_work() has to
> walk policy->cpus.
Right (At least for now, we are doing just that.)
> Doing it the way you did hides that IMO.
Maybe. But I see it otherwise. Adding special meaning to a variable
(like int cpu == -1 being the special case to specify policy->cpus)
hides things morei, as we need to look at how it is decoded finally in
the routine gov_queue_work().
But if we send a mask instead, it is very clear by reading the callers
site, what we are trying to do.
> I'd simply pass an int and use a special value to indicate that policy->cpus
> is to be walked.
Like cpu == -1 thing? Or something else?
> > - if (!all_cpus) {
> > - /*
> > - * Use raw_smp_processor_id() to avoid preemptible warnings.
> > - * We know that this is only called with all_cpus == false from
> > - * works that have been queued with *_work_on() functions and
> > - * those works are canceled during CPU_DOWN_PREPARE so they
> > - * can't possibly run on any other CPU.
> > - */
>
> This was a useful comment and it should be moved along the logic it was supposed
> to explain and not just dropped.
Sigh
> > - __gov_queue_work(raw_smp_processor_id(), dbs_data, delay);
> > - } else {
> > - for_each_cpu(i, policy->cpus)
> > - __gov_queue_work(i, dbs_data, delay);
> > - }
> > + for_each_cpu(i, cpus)
> > + __gov_queue_work(i, dbs_data, delay);
> >
> > out_unlock:
> > mutex_unlock(&cpufreq_governor_lock);
> > @@ -232,7 +221,8 @@ static void dbs_timer(struct work_struct *work)
> > struct cpufreq_policy *policy = shared->policy;
> > struct dbs_data *dbs_data = policy->governor_data;
> > unsigned int sampling_rate, delay;
> > - bool modify_all = true;
> > + const struct cpumask *cpus;
>
> I don't think this local variable is necessary.
>
> > + bool load_eval;
> >
> > mutex_lock(&shared->timer_mutex);
> >
> > @@ -246,11 +236,11 @@ static void dbs_timer(struct work_struct *work)
> > sampling_rate = od_tuners->sampling_rate;
> > }
> >
> > - if (!need_load_eval(cdbs->shared, sampling_rate))
> > - modify_all = false;
> > + load_eval = need_load_eval(cdbs->shared, sampling_rate);
> > + cpus = load_eval ? policy->cpus : cpumask_of(raw_smp_processor_id());
> >
> > - delay = dbs_data->cdata->gov_dbs_timer(cdbs, dbs_data, modify_all);
> > - gov_queue_work(dbs_data, policy, delay, modify_all);
> > + delay = dbs_data->cdata->gov_dbs_timer(cdbs, dbs_data, load_eval);
> > + gov_queue_work(dbs_data, policy, delay, cpus);
Avoiding that local variable would have made this a little longer, but
I can surely drop it :)
gov_queue_work(dbs_data, policy, delay,
load_eval ? policy->cpus :
cpumask_of(raw_smp_processor_id());
--
viresh
next prev parent reply other threads:[~2015-09-08 1:58 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-27 12:28 [PATCH V2 0/9] CPUFreq: governors: further cleanups Viresh Kumar
2015-07-27 12:28 ` [PATCH V2 1/9] cpufreq: Use __func__ to print function's name Viresh Kumar
2015-07-27 12:28 ` Viresh Kumar
2015-09-07 23:42 ` Rafael J. Wysocki
2015-07-27 12:28 ` [PATCH V2 2/9] cpufreq: conservative: remove 'enable' field Viresh Kumar
2015-07-27 12:28 ` Viresh Kumar
2015-09-08 0:17 ` Rafael J. Wysocki
2015-09-08 1:33 ` Viresh Kumar
2015-09-08 1:40 ` [PATCH V3 " Viresh Kumar
2015-09-08 1:40 ` Viresh Kumar
2015-07-27 12:28 ` [PATCH V2 3/9] cpufreq: ondemand: only queue canceled works from update_sampling_rate() Viresh Kumar
2015-07-27 12:28 ` Viresh Kumar
2015-09-08 1:11 ` Rafael J. Wysocki
2015-09-08 1:58 ` Viresh Kumar [this message]
2015-09-09 1:06 ` Rafael J. Wysocki
2015-09-09 2:30 ` Viresh Kumar
2015-09-09 20:10 ` Rafael J. Wysocki
2015-07-27 12:28 ` [PATCH V2 4/9] cpufreq: governor: Drop __gov_queue_work() Viresh Kumar
2015-07-27 12:28 ` Viresh Kumar
2015-09-08 1:15 ` Rafael J. Wysocki
2015-09-08 2:00 ` Viresh Kumar
2015-09-09 1:04 ` Rafael J. Wysocki
2015-07-27 12:28 ` [PATCH V2 5/9] cpufreq: ondemand: Drop unnecessary locks from update_sampling_rate() Viresh Kumar
2015-07-27 12:28 ` Viresh Kumar
2015-07-27 12:28 ` [PATCH V2 6/9] cpufreq: ondemand: queue work for policy->cpus together Viresh Kumar
2015-07-27 12:28 ` Viresh Kumar
2015-09-08 1:33 ` Rafael J. Wysocki
2015-09-08 2:11 ` Viresh Kumar
2015-09-08 2:13 ` Viresh Kumar
2015-07-27 12:28 ` [PATCH V2 7/9] cpufreq: ondemand: update sampling rate immidiately Viresh Kumar
2015-07-27 12:28 ` Viresh Kumar
2015-07-27 12:28 ` [PATCH V2 8/9] cpufreq: governor: Quit work-handlers early if governor is stopped Viresh Kumar
2015-07-27 12:28 ` Viresh Kumar
2015-07-27 12:28 ` [PATCH V2 9/9] cpufreq: Get rid of ->governor_enabled and its lock Viresh Kumar
2015-07-27 12:28 ` Viresh Kumar
2015-09-03 4:44 ` [PATCH V2 0/9] CPUFreq: governors: further cleanups Viresh Kumar
2015-09-04 14:47 ` Rafael J. Wysocki
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=20150908015831.GY26760@linux \
--to=viresh.kumar@linaro.org \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=preeti.lkml@gmail.com \
--cc=rjw@rjwysocki.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.