LKML Archive mirror
 help / color / mirror / Atom feed
From: Saravana Kannan <skannan@codeaurora.org>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Linux PM list <linux-pm@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Juri Lelli <juri.lelli@arm.com>,
	Steve Muckle <steve.muckle@linaro.org>
Subject: Re: [PATCH 5/11] cpufreq: governor: Put governor structure into common_dbs_data
Date: Wed, 03 Feb 2016 17:57:35 -0800	[thread overview]
Message-ID: <56B2B00F.1040303@codeaurora.org> (raw)
In-Reply-To: <1821497.WBZDRuCQYW@vostro.rjw.lan>

On 02/03/2016 03:31 PM, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> For the ondemand and conservative governors (generally, governors
> that use the common code in cpufreq_governor.c), there are two static
> data structures representing the governor, the struct governor
> structure (the interface to the cpufreq core) and the struct
> common_dbs_data one (the interface to the cpufreq_governor.c code).
>
> There's no fundamental reason why those two structures have to be
> separate.  Moreover, if the struct governor one is included into
> struct common_dbs_data, it will be possible to reach the latter from
> the policy via its policy->governor pointer, so it won't be necessary
> to pass a separate pointer to it around.  For this reason, embed
> struct governor in struct common_dbs_data.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>   drivers/cpufreq/cpufreq_conservative.c |   78 +++++++++++++++++----------------
>   drivers/cpufreq/cpufreq_ondemand.c     |   26 ++++++-----
>   2 files changed, 56 insertions(+), 48 deletions(-)
>
> Index: linux-pm/drivers/cpufreq/cpufreq_ondemand.c
> ===================================================================
> --- linux-pm.orig/drivers/cpufreq/cpufreq_ondemand.c
> +++ linux-pm/drivers/cpufreq/cpufreq_ondemand.c
> @@ -539,7 +539,16 @@ static struct od_ops od_ops = {
>   	.freq_increase = dbs_freq_increase,
>   };
>
> +static int od_cpufreq_governor_dbs(struct cpufreq_policy *policy,
> +				   unsigned int event);
> +
>   static struct common_dbs_data od_dbs_cdata = {
> +	.gov = {
> +		.name = "ondemand",
> +		.governor = od_cpufreq_governor_dbs,
> +		.max_transition_latency	= TRANSITION_LATENCY_LIMIT,
> +		.owner = THIS_MODULE,
> +	},
>   	.governor = GOV_ONDEMAND,
>   	.attr_group_gov_sys = &od_attr_group_gov_sys,
>   	.attr_group_gov_pol = &od_attr_group_gov_pol,
> @@ -552,19 +561,14 @@ static struct common_dbs_data od_dbs_cda
>   	.exit = od_exit,
>   };
>
> +#define CPU_FREQ_GOV_ONDEMAND	(&od_dbs_cdata.gov)
> +
>   static int od_cpufreq_governor_dbs(struct cpufreq_policy *policy,
>   		unsigned int event)
>   {
>   	return cpufreq_governor_dbs(policy, &od_dbs_cdata, event);
>   }
>
> -static struct cpufreq_governor cpufreq_gov_ondemand = {
> -	.name			= "ondemand",
> -	.governor		= od_cpufreq_governor_dbs,
> -	.max_transition_latency	= TRANSITION_LATENCY_LIMIT,
> -	.owner			= THIS_MODULE,
> -};
> -
>   static void od_set_powersave_bias(unsigned int powersave_bias)
>   {
>   	struct cpufreq_policy *policy;
> @@ -590,7 +594,7 @@ static void od_set_powersave_bias(unsign
>   		policy = shared->policy;
>   		cpumask_or(&done, &done, policy->cpus);
>
> -		if (policy->governor != &cpufreq_gov_ondemand)
> +		if (policy->governor != CPU_FREQ_GOV_ONDEMAND)
>   			continue;
>
>   		dbs_data = policy->governor_data;
> @@ -618,12 +622,12 @@ EXPORT_SYMBOL_GPL(od_unregister_powersav
>
>   static int __init cpufreq_gov_dbs_init(void)
>   {
> -	return cpufreq_register_governor(&cpufreq_gov_ondemand);
> +	return cpufreq_register_governor(CPU_FREQ_GOV_ONDEMAND);
>   }
>
>   static void __exit cpufreq_gov_dbs_exit(void)
>   {
> -	cpufreq_unregister_governor(&cpufreq_gov_ondemand);
> +	cpufreq_unregister_governor(CPU_FREQ_GOV_ONDEMAND);
>   }
>
>   MODULE_AUTHOR("Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>");
> @@ -635,7 +639,7 @@ MODULE_LICENSE("GPL");
>   #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND
>   struct cpufreq_governor *cpufreq_default_governor(void)
>   {
> -	return &cpufreq_gov_ondemand;
> +	return CPU_FREQ_GOV_ONDEMAND;
>   }
>
>   fs_initcall(cpufreq_gov_dbs_init);
> Index: linux-pm/drivers/cpufreq/cpufreq_conservative.c
> ===================================================================
> --- linux-pm.orig/drivers/cpufreq/cpufreq_conservative.c
> +++ linux-pm/drivers/cpufreq/cpufreq_conservative.c
> @@ -23,16 +23,6 @@
>
>   static DEFINE_PER_CPU(struct cs_cpu_dbs_info_s, cs_cpu_dbs_info);
>
> -static int cs_cpufreq_governor_dbs(struct cpufreq_policy *policy,
> -				   unsigned int event);
> -
> -static struct cpufreq_governor cpufreq_gov_conservative = {
> -	.name			= "conservative",
> -	.governor		= cs_cpufreq_governor_dbs,
> -	.max_transition_latency	= TRANSITION_LATENCY_LIMIT,
> -	.owner			= THIS_MODULE,
> -};
> -
>   static inline unsigned int get_freq_target(struct cs_dbs_tuners *cs_tuners,
>   					   struct cpufreq_policy *policy)
>   {
> @@ -122,30 +112,7 @@ static unsigned int cs_dbs_timer(struct
>   }
>
>   static int dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
> -		void *data)
> -{
> -	struct cpufreq_freqs *freq = data;
> -	struct cs_cpu_dbs_info_s *dbs_info =
> -					&per_cpu(cs_cpu_dbs_info, freq->cpu);
> -	struct cpufreq_policy *policy = cpufreq_cpu_get_raw(freq->cpu);
> -
> -	if (!policy)
> -		return 0;
> -
> -	/* policy isn't governed by conservative governor */
> -	if (policy->governor != &cpufreq_gov_conservative)
> -		return 0;
> -
> -	/*
> -	 * we only care if our internally tracked freq moves outside the 'valid'
> -	 * ranges of frequency available to us otherwise we do not change it
> -	*/
> -	if (dbs_info->requested_freq > policy->max
> -			|| dbs_info->requested_freq < policy->min)
> -		dbs_info->requested_freq = freq->new;
> -
> -	return 0;
> -}
> +				void *data);
>
>   static struct notifier_block cs_cpufreq_notifier_block = {
>   	.notifier_call = dbs_cpufreq_notifier,
> @@ -358,7 +325,16 @@ static void cs_exit(struct dbs_data *dbs
>
>   define_get_cpu_dbs_routines(cs_cpu_dbs_info);
>
> +static int cs_cpufreq_governor_dbs(struct cpufreq_policy *policy,
> +				   unsigned int event);
> +
>   static struct common_dbs_data cs_dbs_cdata = {
> +	.gov = {
> +		.name = "conservative",
> +		.governor = cs_cpufreq_governor_dbs,
> +		.max_transition_latency = TRANSITION_LATENCY_LIMIT,
> +		.owner = THIS_MODULE,
> +	},
>   	.governor = GOV_CONSERVATIVE,
>   	.attr_group_gov_sys = &cs_attr_group_gov_sys,
>   	.attr_group_gov_pol = &cs_attr_group_gov_pol,
> @@ -370,20 +346,48 @@ static struct common_dbs_data cs_dbs_cda
>   	.exit = cs_exit,
>   };
>
> +#define CPU_FREQ_GOV_CONSERVATIVE	(&cs_dbs_cdata.gov)
> +
>   static int cs_cpufreq_governor_dbs(struct cpufreq_policy *policy,
>   				   unsigned int event)
>   {
>   	return cpufreq_governor_dbs(policy, &cs_dbs_cdata, event);
>   }
>
> +static int dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
> +				void *data)
> +{
> +	struct cpufreq_freqs *freq = data;
> +	struct cs_cpu_dbs_info_s *dbs_info =
> +					&per_cpu(cs_cpu_dbs_info, freq->cpu);
> +	struct cpufreq_policy *policy = cpufreq_cpu_get_raw(freq->cpu);
> +
> +	if (!policy)
> +		return 0;
> +
> +	/* policy isn't governed by conservative governor */
> +	if (policy->governor != CPU_FREQ_GOV_CONSERVATIVE)
> +		return 0;
> +
> +	/*
> +	 * we only care if our internally tracked freq moves outside the 'valid'
> +	 * ranges of frequency available to us otherwise we do not change it
> +	*/
> +	if (dbs_info->requested_freq > policy->max
> +			|| dbs_info->requested_freq < policy->min)
> +		dbs_info->requested_freq = freq->new;
> +
> +	return 0;
> +}
> +
>   static int __init cpufreq_gov_dbs_init(void)
>   {
> -	return cpufreq_register_governor(&cpufreq_gov_conservative);
> +	return cpufreq_register_governor(CPU_FREQ_GOV_CONSERVATIVE);
>   }
>
>   static void __exit cpufreq_gov_dbs_exit(void)
>   {
> -	cpufreq_unregister_governor(&cpufreq_gov_conservative);
> +	cpufreq_unregister_governor(CPU_FREQ_GOV_CONSERVATIVE);
>   }
>
>   MODULE_AUTHOR("Alexander Clouter <alex@digriz.org.uk>");
> @@ -395,7 +399,7 @@ MODULE_LICENSE("GPL");
>   #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE
>   struct cpufreq_governor *cpufreq_default_governor(void)
>   {
> -	return &cpufreq_gov_conservative;
> +	return CPU_FREQ_GOV_CONSERVATIVE;
>   }
>
>   fs_initcall(cpufreq_gov_dbs_init);
>

I'm not sold on the macros/#defines for the &blah.gov, but not a strong 
opinion.

Acked-by: Saravana Kannan <skannan@codeaurora.org>

-Saravana

-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

  reply	other threads:[~2016-02-04  1:57 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-03 23:12 [PATCH 0/11] cpufreq: governor: ondemand/conservative data structures rework Rafael J. Wysocki
2016-02-03 23:14 ` [PATCH 1/11] cpufreq: Clean up default and fallback governor setup Rafael J. Wysocki
2016-02-04  0:55   ` Saravana Kannan
2016-02-04  5:03   ` Viresh Kumar
2016-02-03 23:16 ` [PATCH 2/11] cpufreq: governor: Use common mutex for dbs_data protection Rafael J. Wysocki
2016-02-04  0:59   ` Saravana Kannan
2016-02-04  5:09   ` Viresh Kumar
2016-02-04 16:46     ` Rafael J. Wysocki
2016-02-05  2:59       ` Viresh Kumar
2016-02-05  3:06         ` Rafael J. Wysocki
2016-02-05  3:15           ` Rafael J. Wysocki
2016-02-05  3:17             ` Rafael J. Wysocki
2016-02-05  3:24               ` Viresh Kumar
2016-02-05  3:33                 ` Rafael J. Wysocki
2016-02-05  3:22           ` Viresh Kumar
2016-02-03 23:22 ` [PATCH 3/11] cpufreq: governor: Use common global_dbs_data pointer Rafael J. Wysocki
2016-02-04  1:11   ` Saravana Kannan
2016-02-04  1:25     ` Rafael J. Wysocki
2016-02-04  1:40       ` Saravana Kannan
2016-02-04  5:38       ` Viresh Kumar
2016-02-04  1:47     ` Saravana Kannan
2016-02-04  5:36   ` Viresh Kumar
     [not found]     ` <CAHZ_5WxJSDtFyFdCc-D2=HSaPON=3rzUxpxPYsCyZvrV1Nv3qw@mail.gmail.com>
2016-02-04  8:25       ` Viresh Kumar
2016-02-04 11:31         ` Gautham R Shenoy
2016-02-04 11:35           ` Viresh Kumar
2016-02-04 16:52     ` Rafael J. Wysocki
2016-02-05  3:02       ` Viresh Kumar
2016-02-05  3:10         ` Rafael J. Wysocki
2016-02-03 23:29 ` [PATCH 4/11] cpufreq: governor: Avoid passing dbs_data pointers around unnecessarily Rafael J. Wysocki
2016-02-04  1:37   ` Saravana Kannan
2016-02-03 23:31 ` [PATCH 5/11] cpufreq: governor: Put governor structure into common_dbs_data Rafael J. Wysocki
2016-02-04  1:57   ` Saravana Kannan [this message]
2016-02-03 23:32 ` [PATCH 6/11] cpufreq: governor: Rename some data types and variables Rafael J. Wysocki
2016-02-03 23:33 ` [PATCH 7/11] cpufreq: governor: Rework cpufreq_governor_dbs() Rafael J. Wysocki
2016-02-04  2:03   ` Saravana Kannan
2016-02-03 23:35 ` [PATCH 8/11] cpufreq: governor: Drop the gov pointer from struct dbs_data Rafael J. Wysocki
2016-02-03 23:35 ` [PATCH 9/11] cpufreq: governor: Rename cpu_common_dbs_info to policy_dbs_info Rafael J. Wysocki
2016-02-03 23:37 ` [PATCH 10/11] cpufreq: governor: Rearrange governor data structures Rafael J. Wysocki
2016-02-03 23:38 ` [PATCH 11/11] cpufreq: governor: Drop cpu argument from dbs_check_cpu() Rafael J. Wysocki
2016-02-04  5:40 ` [PATCH 0/11] cpufreq: governor: ondemand/conservative data structures rework Viresh Kumar
2016-02-04 17:22   ` Rafael J. Wysocki
2016-02-05  2:07 ` [PATCH v2 0/10] " Rafael J. Wysocki
2016-02-05  2:11   ` [PATCH v2 1/10] cpufreq: Clean up default and fallback governor setup Rafael J. Wysocki
2016-02-10  5:15     ` Gautham R Shenoy
2016-02-10  5:48       ` Gautham R Shenoy
2016-02-05  2:14   ` [PATCH v2 2/10] cpufreq: governor: Use common mutex for dbs_data protection Rafael J. Wysocki
2016-02-05  6:53     ` Viresh Kumar
2016-02-05 22:59       ` Rafael J. Wysocki
2016-02-07  9:31         ` Viresh Kumar
2016-02-07 14:33           ` Rafael J. Wysocki
2016-02-05  2:15   ` [PATCH v2 3/10] cpufreq: governor: Avoid passing dbs_data pointers around unnecessarily Rafael J. Wysocki
2016-02-05  7:09     ` Viresh Kumar
2016-02-05  2:16   ` [PATCH v2 4/10] cpufreq: governor: Put governor structure into common_dbs_data Rafael J. Wysocki
2016-02-05  7:13     ` Viresh Kumar
2016-02-05  2:17   ` [PATCH v2 5/10] cpufreq: governor: Rename some data types and variables Rafael J. Wysocki
2016-02-05  7:17     ` Viresh Kumar
2016-02-05  2:18   ` [PATCH v2 6/10] cpufreq: governor: Rework cpufreq_governor_dbs() Rafael J. Wysocki
2016-02-05  8:14     ` Viresh Kumar
2016-02-05  2:19   ` [PATCH v2 7/10] cpufreq: governor: Drop the gov pointer from struct dbs_data Rafael J. Wysocki
2016-02-05  8:28     ` Viresh Kumar
2016-02-05  2:20   ` [PATCH v2 8/10] cpufreq: governor: Rename cpu_common_dbs_info to policy_dbs_info Rafael J. Wysocki
2016-02-05  8:34     ` Viresh Kumar
2016-02-05 22:50       ` Rafael J. Wysocki
2016-02-06 12:48     ` [PATCH v3 " Rafael J. Wysocki
2016-02-07  9:31       ` Viresh Kumar
2016-02-05  2:21   ` [PATCH v2 9/10] cpufreq: governor: Rearrange governor data structures Rafael J. Wysocki
2016-02-05  9:13     ` Viresh Kumar
2016-02-05 22:47       ` Rafael J. Wysocki
2016-02-07  9:29         ` Viresh Kumar
2016-02-07 14:34           ` Rafael J. Wysocki
2016-02-05  2:21   ` [PATCH v2 10/10] cpufreq: governor: Drop cpu argument from dbs_check_cpu() Rafael J. Wysocki
2016-02-05  9:15     ` Viresh Kumar
2016-02-06 12:50     ` [PATCH v3 " Rafael J. Wysocki
2016-02-07  9:32       ` Viresh Kumar
2016-02-06 12:44   ` [PATCH v2 0/10] cpufreq: governor: ondemand/conservative data structures rework Rafael J. Wysocki
2016-02-07 15:22   ` [PATCH 0/3] cpufreq: governor: Data structure rearrangement Rafael J. Wysocki
2016-02-07 15:23     ` [PATCH 1/3] cpufreq: governor: Simplify cpufreq_governor_limits() Rafael J. Wysocki
2016-02-07 15:40       ` Viresh Kumar
2016-02-08  0:59         ` Rafael J. Wysocki
2016-02-07 15:24     ` [PATCH 2/3] cpufreq: governor: Rearrange governor data structures Rafael J. Wysocki
2016-02-07 15:45       ` Viresh Kumar
2016-02-07 15:54         ` Viresh Kumar
2016-02-07 15:55       ` Viresh Kumar
2016-02-07 15:25     ` [PATCH 3/3] cpufreq: governor: Symmetrize cpu_dbs_info initialization and cleanup Rafael J. Wysocki
2016-02-07 15:52       ` 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=56B2B00F.1040303@codeaurora.org \
    --to=skannan@codeaurora.org \
    --cc=juri.lelli@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=steve.muckle@linaro.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 read-only IMAP folder(s) and NNTP newsgroup(s).