* [PATCH] cpufreq: Implement light weight cpufreq_get_policy_table() routine
@ 2016-05-26 5:42 Viresh Kumar
2016-05-31 22:40 ` Rafael J. Wysocki
0 siblings, 1 reply; 3+ messages in thread
From: Viresh Kumar @ 2016-05-26 5:42 UTC (permalink / raw)
To: Rafael Wysocki, Viresh Kumar; +Cc: linaro-kernel, linux-pm, steve.muckle
Most of the callers of cpufreq_frequency_get_table() already have the
pointer to a valid policy structure and they don't really need to go
through the per-cpu variable first and then a check to validate the
frequency, in order to find the freq-table for the policy.
Implement a light weight call for this and update users.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/cpufreq.c | 4 ++--
drivers/cpufreq/cpufreq_ondemand.c | 2 +-
drivers/cpufreq/cpufreq_stats.c | 3 +--
drivers/cpufreq/freq_table.c | 4 ++--
drivers/cpufreq/ppc_cbe_cpufreq_pmi.c | 2 +-
include/linux/cpufreq.h | 7 +++++++
6 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 90f4bf03701d..0b5cf0e4bd4f 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1989,7 +1989,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
if (!cpufreq_driver->target_index)
return -EINVAL;
- freq_table = cpufreq_frequency_get_table(policy->cpu);
+ freq_table = cpufreq_get_policy_table(policy);
if (unlikely(!freq_table)) {
pr_err("%s: Unable to find freq_table\n", __func__);
return -EINVAL;
@@ -2343,7 +2343,7 @@ static int cpufreq_boost_set_sw(int state)
int ret = -EINVAL;
for_each_active_policy(policy) {
- freq_table = cpufreq_frequency_get_table(policy->cpu);
+ freq_table = cpufreq_get_policy_table(policy);
if (freq_table) {
ret = cpufreq_frequency_table_cpuinfo(policy,
freq_table);
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 300163430516..23f526726e0b 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -113,7 +113,7 @@ static void ondemand_powersave_bias_init(struct cpufreq_policy *policy)
{
struct od_policy_dbs_info *dbs_info = to_dbs_info(policy->governor_data);
- dbs_info->freq_table = cpufreq_frequency_get_table(policy->cpu);
+ dbs_info->freq_table = cpufreq_get_policy_table(policy);
dbs_info->freq_lo = 0;
}
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index d4618144b4c0..5fd1354925d9 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -151,11 +151,10 @@ static int cpufreq_stats_create_table(struct cpufreq_policy *policy)
unsigned int i = 0, count = 0, ret = -ENOMEM;
struct cpufreq_stats *stats;
unsigned int alloc_size;
- unsigned int cpu = policy->cpu;
struct cpufreq_frequency_table *pos, *table;
/* We need cpufreq table for creating stats table */
- table = cpufreq_frequency_get_table(cpu);
+ table = cpufreq_get_policy_table(policy);
if (unlikely(!table))
return 0;
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index a8f1daffc9bc..5683ea4b7a03 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -109,7 +109,7 @@ EXPORT_SYMBOL_GPL(cpufreq_frequency_table_verify);
int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy)
{
struct cpufreq_frequency_table *table =
- cpufreq_frequency_get_table(policy->cpu);
+ cpufreq_get_policy_table(policy);
if (!table)
return -ENODEV;
@@ -214,7 +214,7 @@ int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy,
{
struct cpufreq_frequency_table *pos, *table;
- table = cpufreq_frequency_get_table(policy->cpu);
+ table = cpufreq_get_policy_table(policy);
if (unlikely(!table)) {
pr_debug("%s: Unable to find frequency table\n", __func__);
return -ENOENT;
diff --git a/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c b/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c
index 7c4cd5c634f2..e228d51beeba 100644
--- a/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c
+++ b/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c
@@ -103,7 +103,7 @@ static int pmi_notifier(struct notifier_block *nb,
if (event == CPUFREQ_START)
return 0;
- cbe_freqs = cpufreq_frequency_get_table(policy->cpu);
+ cbe_freqs = cpufreq_get_policy_table(policy);
node = cbe_cpu_to_node(policy->cpu);
pr_debug("got notified, event=%lu, node=%u\n", event, node);
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 4e81e08db752..42ea01fb8dce 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -620,6 +620,13 @@ static inline bool policy_has_boost_freq(struct cpufreq_policy *policy)
/* the following funtion is for cpufreq core use only */
struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu);
+static inline struct cpufreq_frequency_table *
+cpufreq_get_policy_table(struct cpufreq_policy *policy)
+{
+ return policy->freq_table;
+}
+
+
/* the following are really really optional */
extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;
extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs;
--
2.7.1.410.g6faf27b
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] cpufreq: Implement light weight cpufreq_get_policy_table() routine
2016-05-26 5:42 [PATCH] cpufreq: Implement light weight cpufreq_get_policy_table() routine Viresh Kumar
@ 2016-05-31 22:40 ` Rafael J. Wysocki
2016-06-01 1:54 ` Viresh Kumar
0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2016-05-31 22:40 UTC (permalink / raw)
To: Viresh Kumar
Cc: Rafael Wysocki, Lists linaro-kernel, linux-pm@vger.kernel.org,
Steve Muckle
On Thu, May 26, 2016 at 7:42 AM, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> Most of the callers of cpufreq_frequency_get_table() already have the
> pointer to a valid policy structure and they don't really need to go
> through the per-cpu variable first and then a check to validate the
> frequency, in order to find the freq-table for the policy.
>
> Implement a light weight call for this and update users.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> drivers/cpufreq/cpufreq.c | 4 ++--
> drivers/cpufreq/cpufreq_ondemand.c | 2 +-
> drivers/cpufreq/cpufreq_stats.c | 3 +--
> drivers/cpufreq/freq_table.c | 4 ++--
> drivers/cpufreq/ppc_cbe_cpufreq_pmi.c | 2 +-
> include/linux/cpufreq.h | 7 +++++++
> 6 files changed, 14 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 90f4bf03701d..0b5cf0e4bd4f 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1989,7 +1989,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
> if (!cpufreq_driver->target_index)
> return -EINVAL;
>
> - freq_table = cpufreq_frequency_get_table(policy->cpu);
> + freq_table = cpufreq_get_policy_table(policy);
Maybe rename cpufreq_get_policy_table() to cpufreq_policy_freq_table()?
> if (unlikely(!freq_table)) {
> pr_err("%s: Unable to find freq_table\n", __func__);
> return -EINVAL;
> @@ -2343,7 +2343,7 @@ static int cpufreq_boost_set_sw(int state)
> int ret = -EINVAL;
>
> for_each_active_policy(policy) {
> - freq_table = cpufreq_frequency_get_table(policy->cpu);
> + freq_table = cpufreq_get_policy_table(policy);
> if (freq_table) {
> ret = cpufreq_frequency_table_cpuinfo(policy,
> freq_table);
> diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
> index 300163430516..23f526726e0b 100644
> --- a/drivers/cpufreq/cpufreq_ondemand.c
> +++ b/drivers/cpufreq/cpufreq_ondemand.c
> @@ -113,7 +113,7 @@ static void ondemand_powersave_bias_init(struct cpufreq_policy *policy)
> {
> struct od_policy_dbs_info *dbs_info = to_dbs_info(policy->governor_data);
>
> - dbs_info->freq_table = cpufreq_frequency_get_table(policy->cpu);
> + dbs_info->freq_table = cpufreq_get_policy_table(policy);
> dbs_info->freq_lo = 0;
> }
>
> diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
> index d4618144b4c0..5fd1354925d9 100644
> --- a/drivers/cpufreq/cpufreq_stats.c
> +++ b/drivers/cpufreq/cpufreq_stats.c
> @@ -151,11 +151,10 @@ static int cpufreq_stats_create_table(struct cpufreq_policy *policy)
> unsigned int i = 0, count = 0, ret = -ENOMEM;
> struct cpufreq_stats *stats;
> unsigned int alloc_size;
> - unsigned int cpu = policy->cpu;
> struct cpufreq_frequency_table *pos, *table;
>
> /* We need cpufreq table for creating stats table */
> - table = cpufreq_frequency_get_table(cpu);
> + table = cpufreq_get_policy_table(policy);
> if (unlikely(!table))
> return 0;
>
> diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
> index a8f1daffc9bc..5683ea4b7a03 100644
> --- a/drivers/cpufreq/freq_table.c
> +++ b/drivers/cpufreq/freq_table.c
> @@ -109,7 +109,7 @@ EXPORT_SYMBOL_GPL(cpufreq_frequency_table_verify);
> int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy)
> {
> struct cpufreq_frequency_table *table =
> - cpufreq_frequency_get_table(policy->cpu);
> + cpufreq_get_policy_table(policy);
> if (!table)
> return -ENODEV;
>
> @@ -214,7 +214,7 @@ int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy,
> {
> struct cpufreq_frequency_table *pos, *table;
>
> - table = cpufreq_frequency_get_table(policy->cpu);
> + table = cpufreq_get_policy_table(policy);
> if (unlikely(!table)) {
> pr_debug("%s: Unable to find frequency table\n", __func__);
> return -ENOENT;
> diff --git a/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c b/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c
> index 7c4cd5c634f2..e228d51beeba 100644
> --- a/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c
> +++ b/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c
> @@ -103,7 +103,7 @@ static int pmi_notifier(struct notifier_block *nb,
> if (event == CPUFREQ_START)
> return 0;
>
> - cbe_freqs = cpufreq_frequency_get_table(policy->cpu);
> + cbe_freqs = cpufreq_get_policy_table(policy);
> node = cbe_cpu_to_node(policy->cpu);
>
> pr_debug("got notified, event=%lu, node=%u\n", event, node);
> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
> index 4e81e08db752..42ea01fb8dce 100644
> --- a/include/linux/cpufreq.h
> +++ b/include/linux/cpufreq.h
> @@ -620,6 +620,13 @@ static inline bool policy_has_boost_freq(struct cpufreq_policy *policy)
> /* the following funtion is for cpufreq core use only */
> struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu);
>
> +static inline struct cpufreq_frequency_table *
> +cpufreq_get_policy_table(struct cpufreq_policy *policy)
Please don't break this line.
> +{
> + return policy->freq_table;
> +}
> +
> +
> /* the following are really really optional */
> extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;
> extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs;
> --
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cpufreq: Implement light weight cpufreq_get_policy_table() routine
2016-05-31 22:40 ` Rafael J. Wysocki
@ 2016-06-01 1:54 ` Viresh Kumar
0 siblings, 0 replies; 3+ messages in thread
From: Viresh Kumar @ 2016-06-01 1:54 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Rafael Wysocki, Lists linaro-kernel, linux-pm@vger.kernel.org,
Steve Muckle
On 01-06-16, 00:40, Rafael J. Wysocki wrote:
> On Thu, May 26, 2016 at 7:42 AM, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> > Most of the callers of cpufreq_frequency_get_table() already have the
> > pointer to a valid policy structure and they don't really need to go
> > through the per-cpu variable first and then a check to validate the
> > frequency, in order to find the freq-table for the policy.
> >
> > Implement a light weight call for this and update users.
> >
> > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> > ---
> > drivers/cpufreq/cpufreq.c | 4 ++--
> > drivers/cpufreq/cpufreq_ondemand.c | 2 +-
> > drivers/cpufreq/cpufreq_stats.c | 3 +--
> > drivers/cpufreq/freq_table.c | 4 ++--
> > drivers/cpufreq/ppc_cbe_cpufreq_pmi.c | 2 +-
> > include/linux/cpufreq.h | 7 +++++++
> > 6 files changed, 14 insertions(+), 8 deletions(-)
Submitted another version which accesses policy->freq_table directly
instead.
--
viresh
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-06-01 1:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-26 5:42 [PATCH] cpufreq: Implement light weight cpufreq_get_policy_table() routine Viresh Kumar
2016-05-31 22:40 ` Rafael J. Wysocki
2016-06-01 1:54 ` Viresh Kumar
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).