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,
ego@linux.vnet.ibm.com, paulus@samba.org,
shilpa.bhat@linux.vnet.ibm.com, prarit@redhat.com,
robert.schoene@tu-dresden.de, skannan@codeaurora.org
Subject: Re: [PATCH 1/3] cpufreq: governor: register notifier from cs_init()
Date: Thu, 04 Jun 2015 11:08:18 +0530 [thread overview]
Message-ID: <556FE44A.8080806@linux.vnet.ibm.com> (raw)
In-Reply-To: <7c79b6ede0407a940da2076f562360990ef0061a.1433326032.git.viresh.kumar@linaro.org>
On 06/03/2015 03:57 PM, Viresh Kumar wrote:
> Notifiers are required only for conservative governor and the common
> governor code is unnecessarily polluted with that. Handle that from
> cs_init/exit() instead of cpufreq_governor_dbs().
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> drivers/cpufreq/cpufreq_conservative.c | 26 +++++++++++++++-----------
> drivers/cpufreq/cpufreq_governor.c | 22 +++-------------------
> drivers/cpufreq/cpufreq_governor.h | 8 ++------
> drivers/cpufreq/cpufreq_ondemand.c | 4 ++--
> 4 files changed, 22 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
> index 25a70d06c5bf..75f875bb155e 100644
> --- a/drivers/cpufreq/cpufreq_conservative.c
> +++ b/drivers/cpufreq/cpufreq_conservative.c
> @@ -148,6 +148,10 @@ static int dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
> return 0;
> }
>
> +static struct notifier_block cs_cpufreq_notifier_block = {
> + .notifier_call = dbs_cpufreq_notifier,
> +};
> +
> /************************** sysfs interface ************************/
> static struct common_dbs_data cs_dbs_cdata;
>
> @@ -317,7 +321,7 @@ static struct attribute_group cs_attr_group_gov_pol = {
>
> /************************** sysfs end ************************/
>
> -static int cs_init(struct dbs_data *dbs_data)
> +static int cs_init(struct dbs_data *dbs_data, bool notify)
> {
> struct cs_dbs_tuners *tuners;
>
> @@ -336,25 +340,26 @@ static int cs_init(struct dbs_data *dbs_data)
> dbs_data->tuners = tuners;
> dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO *
> jiffies_to_usecs(10);
> +
> + if (notify)
> + cpufreq_register_notifier(&cs_cpufreq_notifier_block,
> + CPUFREQ_TRANSITION_NOTIFIER);
> +
> mutex_init(&dbs_data->mutex);
> return 0;
> }
>
> -static void cs_exit(struct dbs_data *dbs_data)
> +static void cs_exit(struct dbs_data *dbs_data, bool notify)
> {
> + if (notify)
> + cpufreq_unregister_notifier(&cs_cpufreq_notifier_block,
> + CPUFREQ_TRANSITION_NOTIFIER);
> +
> kfree(dbs_data->tuners);
> }
>
> define_get_cpu_dbs_routines(cs_cpu_dbs_info);
>
> -static struct notifier_block cs_cpufreq_notifier_block = {
> - .notifier_call = dbs_cpufreq_notifier,
> -};
> -
> -static struct cs_ops cs_ops = {
> - .notifier_block = &cs_cpufreq_notifier_block,
> -};
> -
> static struct common_dbs_data cs_dbs_cdata = {
> .governor = GOV_CONSERVATIVE,
> .attr_group_gov_sys = &cs_attr_group_gov_sys,
> @@ -363,7 +368,6 @@ static struct common_dbs_data cs_dbs_cdata = {
> .get_cpu_dbs_info_s = get_cpu_dbs_info_s,
> .gov_dbs_timer = cs_dbs_timer,
> .gov_check_cpu = cs_check_cpu,
> - .gov_ops = &cs_ops,
> .init = cs_init,
> .exit = cs_exit,
> };
> diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
> index 1b44496b2d2b..d64a82e6481a 100644
> --- a/drivers/cpufreq/cpufreq_governor.c
> +++ b/drivers/cpufreq/cpufreq_governor.c
> @@ -278,7 +278,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
>
> dbs_data->cdata = cdata;
> dbs_data->usage_count = 1;
> - rc = cdata->init(dbs_data);
> + rc = cdata->init(dbs_data, !policy->governor->initialized);
> if (rc) {
> pr_err("%s: POLICY_INIT: init() failed\n", __func__);
> kfree(dbs_data);
> @@ -291,7 +291,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
> rc = sysfs_create_group(get_governor_parent_kobj(policy),
> get_sysfs_attr(dbs_data));
> if (rc) {
> - cdata->exit(dbs_data);
> + cdata->exit(dbs_data, !policy->governor->initialized);
> kfree(dbs_data);
> return rc;
> }
> @@ -309,14 +309,6 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
> set_sampling_rate(dbs_data, max(dbs_data->min_sampling_rate,
> latency * LATENCY_MULTIPLIER));
>
> - if ((cdata->governor == GOV_CONSERVATIVE) &&
> - (!policy->governor->initialized)) {
> - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
> -
> - cpufreq_register_notifier(cs_ops->notifier_block,
> - CPUFREQ_TRANSITION_NOTIFIER);
> - }
> -
> if (!have_governor_per_policy())
> cdata->gdbs_data = dbs_data;
>
> @@ -329,15 +321,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
> if (!have_governor_per_policy())
> cpufreq_put_global_kobject();
>
> - if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
> - (policy->governor->initialized == 1)) {
> - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
> -
> - cpufreq_unregister_notifier(cs_ops->notifier_block,
> - CPUFREQ_TRANSITION_NOTIFIER);
> - }
> -
> - cdata->exit(dbs_data);
> + cdata->exit(dbs_data, policy->governor->initialized == 1);
> kfree(dbs_data);
> cdata->gdbs_data = NULL;
I don't see why we need the check on policy->governor->initialized
because we call cdata->init() and cdata->exit(), *only* when the first
and last references to the governor are being made respectively
(filtered by dbs_data->usage_count), which is precisely what the
initialized flag checks. So passing policy->governor->initialized seems
to be redundant? And this is the case for both gov_per_policy and otherwise.
Regards
Preeti U Murthy
next prev parent reply other threads:[~2015-06-04 5:38 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-03 10:27 [PATCH 0/3] cpufreq: governor: Fix potential races Viresh Kumar
2015-06-03 10:27 ` [PATCH 1/3] cpufreq: governor: register notifier from cs_init() Viresh Kumar
2015-06-04 5:38 ` Preeti U Murthy [this message]
2015-06-04 6:02 ` Viresh Kumar
2015-06-04 7:33 ` Preeti U Murthy
2015-06-03 10:27 ` [PATCH 2/3] cpufreq: governor: split cpufreq_governor_dbs() Viresh Kumar
2015-06-04 10:04 ` Preeti U Murthy
2015-06-04 10:17 ` Viresh Kumar
2015-06-04 11:13 ` [PATCH V2 " Viresh Kumar
2015-06-05 2:51 ` Preeti U Murthy
2015-06-03 10:27 ` [PATCH 3/3] cpufreq: governor: Serialize governor callbacks Viresh Kumar
2015-06-04 10:47 ` Preeti U Murthy
2015-06-04 5:14 ` [PATCH 0/3] cpufreq: governor: Fix potential races Preeti U Murthy
2015-06-04 6:08 ` Preeti U Murthy
2015-06-04 6:11 ` Viresh Kumar
2015-06-04 6:36 ` Preeti U Murthy
2015-06-04 6:42 ` Viresh Kumar
2015-06-04 7:04 ` Preeti U Murthy
2015-06-04 7:13 ` Viresh Kumar
2015-06-04 7:27 ` Preeti U Murthy
2015-06-05 3:00 ` Viresh Kumar
2015-06-05 3:04 ` Preeti U Murthy
2015-06-05 4:05 ` Preeti U Murthy
2015-06-15 23:48 ` 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=556FE44A.8080806@linux.vnet.ibm.com \
--to=preeti@linux.vnet.ibm.com \
--cc=ego@linux.vnet.ibm.com \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-pm@vger.kernel.org \
--cc=paulus@samba.org \
--cc=prarit@redhat.com \
--cc=rjw@rjwysocki.net \
--cc=robert.schoene@tu-dresden.de \
--cc=shilpa.bhat@linux.vnet.ibm.com \
--cc=skannan@codeaurora.org \
--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).