linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpufreq: governors: implement generic policy_is_shared
@ 2013-01-31  8:14 Fabio Baltieri
  2013-01-31  8:31 ` Viresh Kumar
  0 siblings, 1 reply; 6+ messages in thread
From: Fabio Baltieri @ 2013-01-31  8:14 UTC (permalink / raw)
  To: Rafael J. Wysocki, cpufreq, linux-pm
  Cc: Viresh Kumar, Linus Walleij, linaro-dev, linux-kernel,
	Fabio Baltieri

Implement a generic helper function policy_is_shared() to replace the
current dbs_sw_coordinated_cpus() at cpufreq level, so that it can be
used by code other than cpufreq governors.

Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
---
 drivers/cpufreq/cpufreq_conservative.c | 2 +-
 drivers/cpufreq/cpufreq_governor.c     | 8 --------
 drivers/cpufreq/cpufreq_governor.h     | 1 -
 drivers/cpufreq/cpufreq_ondemand.c     | 2 +-
 include/linux/cpufreq.h                | 5 +++++
 5 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index 5d8e894..653fb06 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -154,7 +154,7 @@ static void cs_dbs_timer(struct work_struct *work)
 	struct cs_cpu_dbs_info_s *dbs_info = container_of(work,
 			struct cs_cpu_dbs_info_s, cdbs.work.work);
 
-	if (dbs_sw_coordinated_cpus(&dbs_info->cdbs)) {
+	if (policy_is_shared(dbs_info->cdbs.cur_policy)) {
 		cs_timer_coordinated(dbs_info, dw);
 	} else {
 		mutex_lock(&dbs_info->cdbs.timer_mutex);
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
index 46f96a4..67e235a 100644
--- a/drivers/cpufreq/cpufreq_governor.c
+++ b/drivers/cpufreq/cpufreq_governor.c
@@ -161,14 +161,6 @@ void dbs_check_cpu(struct dbs_data *dbs_data, int cpu)
 }
 EXPORT_SYMBOL_GPL(dbs_check_cpu);
 
-bool dbs_sw_coordinated_cpus(struct cpu_dbs_common_info *cdbs)
-{
-	struct cpufreq_policy *policy = cdbs->cur_policy;
-
-	return cpumask_weight(policy->cpus) > 1;
-}
-EXPORT_SYMBOL_GPL(dbs_sw_coordinated_cpus);
-
 static inline void dbs_timer_init(struct dbs_data *dbs_data, int cpu,
 				  unsigned int sampling_rate)
 {
diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
index aaf073d..b72e628 100644
--- a/drivers/cpufreq/cpufreq_governor.h
+++ b/drivers/cpufreq/cpufreq_governor.h
@@ -172,7 +172,6 @@ static inline int delay_for_sampling_rate(unsigned int sampling_rate)
 
 u64 get_cpu_idle_time(unsigned int cpu, u64 *wall);
 void dbs_check_cpu(struct dbs_data *dbs_data, int cpu);
-bool dbs_sw_coordinated_cpus(struct cpu_dbs_common_info *cdbs);
 int cpufreq_governor_dbs(struct dbs_data *dbs_data,
 		struct cpufreq_policy *policy, unsigned int event);
 #endif /* _CPUFREQ_GOVERNER_H */
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 1017b90..5ae84ff 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -277,7 +277,7 @@ static void od_dbs_timer(struct work_struct *work)
 	struct od_cpu_dbs_info_s *dbs_info =
 		container_of(work, struct od_cpu_dbs_info_s, cdbs.work.work);
 
-	if (dbs_sw_coordinated_cpus(&dbs_info->cdbs)) {
+	if (policy_is_shared(dbs_info->cdbs.cur_policy)) {
 		od_timer_coordinated(dbs_info, dw);
 	} else {
 		mutex_lock(&dbs_info->cdbs.timer_mutex);
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 5fdc6c6..f106406 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -125,6 +125,11 @@ struct cpufreq_policy {
 #define CPUFREQ_SHARED_TYPE_ALL	 (2) /* All dependent CPUs should set freq */
 #define CPUFREQ_SHARED_TYPE_ANY	 (3) /* Freq can be set from any dependent CPU*/
 
+static inline bool policy_is_shared(struct cpufreq_policy *policy)
+{
+	return cpumask_weight(policy->cpus) > 1;
+}
+
 /******************** cpufreq transition notifiers *******************/
 
 #define CPUFREQ_PRECHANGE	(0)
-- 
1.7.12.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] cpufreq: governors: implement generic policy_is_shared
  2013-01-31  8:14 [PATCH] cpufreq: governors: implement generic policy_is_shared Fabio Baltieri
@ 2013-01-31  8:31 ` Viresh Kumar
  2013-01-31  8:55   ` Fabio Baltieri
  0 siblings, 1 reply; 6+ messages in thread
From: Viresh Kumar @ 2013-01-31  8:31 UTC (permalink / raw)
  To: Fabio Baltieri
  Cc: Rafael J. Wysocki, cpufreq, linux-pm, Linus Walleij, linaro-dev,
	linux-kernel

On 31 January 2013 13:44, Fabio Baltieri <fabio.baltieri@linaro.org> wrote:
> Implement a generic helper function policy_is_shared() to replace the
> current dbs_sw_coordinated_cpus() at cpufreq level, so that it can be
> used by code other than cpufreq governors.
>
> Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
> ---
>  drivers/cpufreq/cpufreq_conservative.c | 2 +-
>  drivers/cpufreq/cpufreq_governor.c     | 8 --------
>  drivers/cpufreq/cpufreq_governor.h     | 1 -
>  drivers/cpufreq/cpufreq_ondemand.c     | 2 +-
>  include/linux/cpufreq.h                | 5 +++++

Great,

But, you missed few places:

drivers/cpufreq/acpi-cpufreq.c:        if (bios_with_sw_any_bug &&
cpumask_weight(policy->cpus) == 1) {
drivers/cpufreq/cpufreq_stats.c:       if (policy &&
(cpumask_weight(policy->cpus) == 1)) {

get these fixed too and add my

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cpufreq: governors: implement generic policy_is_shared
  2013-01-31  8:31 ` Viresh Kumar
@ 2013-01-31  8:55   ` Fabio Baltieri
  2013-01-31  8:58     ` Viresh Kumar
  0 siblings, 1 reply; 6+ messages in thread
From: Fabio Baltieri @ 2013-01-31  8:55 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Rafael J. Wysocki, cpufreq, linux-pm, Linus Walleij, linaro-dev,
	linux-kernel

On Thu, Jan 31, 2013 at 02:01:27PM +0530, Viresh Kumar wrote:
> On 31 January 2013 13:44, Fabio Baltieri <fabio.baltieri@linaro.org> wrote:
> > Implement a generic helper function policy_is_shared() to replace the
> > current dbs_sw_coordinated_cpus() at cpufreq level, so that it can be
> > used by code other than cpufreq governors.
> >
> > Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> > Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
> > ---
> >  drivers/cpufreq/cpufreq_conservative.c | 2 +-
> >  drivers/cpufreq/cpufreq_governor.c     | 8 --------
> >  drivers/cpufreq/cpufreq_governor.h     | 1 -
> >  drivers/cpufreq/cpufreq_ondemand.c     | 2 +-
> >  include/linux/cpufreq.h                | 5 +++++
> 
> Great,
> 
> But, you missed few places:
> 
> drivers/cpufreq/acpi-cpufreq.c:        if (bios_with_sw_any_bug &&
> cpumask_weight(policy->cpus) == 1) {
> drivers/cpufreq/cpufreq_stats.c:       if (policy &&
> (cpumask_weight(policy->cpus) == 1)) {

This doesn't look like the same thing to me!  Isn't this check here just
to trigger during init (exit) on the first (last) cpu?  How would you
replace it?

Fabio

> get these fixed too and add my
> 
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
Fabio Baltieri

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cpufreq: governors: implement generic policy_is_shared
  2013-01-31  8:55   ` Fabio Baltieri
@ 2013-01-31  8:58     ` Viresh Kumar
       [not found]       ` <CAOh2x==1ru3bddHnJOge=1rbpc6xwzKV5F5isJhAgwX_R=2TCw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Viresh Kumar @ 2013-01-31  8:58 UTC (permalink / raw)
  To: Fabio Baltieri
  Cc: Rafael J. Wysocki, cpufreq, linux-pm, Linus Walleij, linaro-dev,
	linux-kernel

On Thu, Jan 31, 2013 at 2:25 PM, Fabio Baltieri
<fabio.baltieri@linaro.org> wrote:
> On Thu, Jan 31, 2013 at 02:01:27PM +0530, Viresh Kumar wrote:
>> On 31 January 2013 13:44, Fabio Baltieri <fabio.baltieri@linaro.org> wrote:
>> > Implement a generic helper function policy_is_shared() to replace the
>> > current dbs_sw_coordinated_cpus() at cpufreq level, so that it can be
>> > used by code other than cpufreq governors.
>> >
>> > Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
>> > Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
>> > ---
>> >  drivers/cpufreq/cpufreq_conservative.c | 2 +-
>> >  drivers/cpufreq/cpufreq_governor.c     | 8 --------
>> >  drivers/cpufreq/cpufreq_governor.h     | 1 -
>> >  drivers/cpufreq/cpufreq_ondemand.c     | 2 +-
>> >  include/linux/cpufreq.h                | 5 +++++
>>
>> Great,
>>
>> But, you missed few places:
>>
>> drivers/cpufreq/acpi-cpufreq.c:        if (bios_with_sw_any_bug &&
>> cpumask_weight(policy->cpus) == 1) {
>> drivers/cpufreq/cpufreq_stats.c:       if (policy &&
>> (cpumask_weight(policy->cpus) == 1)) {
>
> This doesn't look like the same thing to me!  Isn't this check here just
> to trigger during init (exit) on the first (last) cpu?  How would you
> replace it?

I don't think i am wrong, but i can be :)

So, i would replace these as:
drivers/cpufreq/acpi-cpufreq.c:        if (bios_with_sw_any_bug &&
cpumask_weight(policy->cpus) == 1) {
AS
drivers/cpufreq/acpi-cpufreq.c:        if (bios_with_sw_any_bug &&
!policy_is_shared(policy)) {

similarly for the other one too. The whole point is about checking if policy
is managing just one cpu or multiple cpus.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] cpufreq: governors: implement generic policy_is_shared
       [not found]       ` <CAOh2x==1ru3bddHnJOge=1rbpc6xwzKV5F5isJhAgwX_R=2TCw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2013-01-31  9:44         ` Fabio Baltieri
  2013-01-31  9:53           ` Viresh Kumar
  0 siblings, 1 reply; 6+ messages in thread
From: Fabio Baltieri @ 2013-01-31  9:44 UTC (permalink / raw)
  To: Rafael J. Wysocki, cpufreq-u79uwXL29TY76Z2rM5mHXA,
	linux-pm-u79uwXL29TY76Z2rM5mHXA
  Cc: Viresh Kumar, linaro-dev-cunTk1MwBs8s++Sfvej+rw,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

Implement a generic helper function policy_is_shared() to replace the
current dbs_sw_coordinated_cpus() at cpufreq level, so that it can be
used by code other than cpufreq governors.

Suggested-by: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---

Changes from v1:
- replaced cpumask_weight in acpi-cpufreq.c and cpufreq_stats.c, through the
  actual check is different the semantic should be the same.

Fabio

 drivers/cpufreq/acpi-cpufreq.c         | 2 +-
 drivers/cpufreq/cpufreq_conservative.c | 2 +-
 drivers/cpufreq/cpufreq_governor.c     | 8 --------
 drivers/cpufreq/cpufreq_governor.h     | 1 -
 drivers/cpufreq/cpufreq_ondemand.c     | 2 +-
 drivers/cpufreq/cpufreq_stats.c        | 2 +-
 include/linux/cpufreq.h                | 5 +++++
 7 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 22f9b47..937bc28 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -734,7 +734,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
 
 #ifdef CONFIG_SMP
 	dmi_check_system(sw_any_bug_dmi_table);
-	if (bios_with_sw_any_bug && cpumask_weight(policy->cpus) == 1) {
+	if (bios_with_sw_any_bug && !policy_is_shared(policy)) {
 		policy->shared_type = CPUFREQ_SHARED_TYPE_ALL;
 		cpumask_copy(policy->cpus, cpu_core_mask(cpu));
 	}
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index 5d8e894..653fb06 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -154,7 +154,7 @@ static void cs_dbs_timer(struct work_struct *work)
 	struct cs_cpu_dbs_info_s *dbs_info = container_of(work,
 			struct cs_cpu_dbs_info_s, cdbs.work.work);
 
-	if (dbs_sw_coordinated_cpus(&dbs_info->cdbs)) {
+	if (policy_is_shared(dbs_info->cdbs.cur_policy)) {
 		cs_timer_coordinated(dbs_info, dw);
 	} else {
 		mutex_lock(&dbs_info->cdbs.timer_mutex);
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
index 46f96a4..67e235a 100644
--- a/drivers/cpufreq/cpufreq_governor.c
+++ b/drivers/cpufreq/cpufreq_governor.c
@@ -161,14 +161,6 @@ void dbs_check_cpu(struct dbs_data *dbs_data, int cpu)
 }
 EXPORT_SYMBOL_GPL(dbs_check_cpu);
 
-bool dbs_sw_coordinated_cpus(struct cpu_dbs_common_info *cdbs)
-{
-	struct cpufreq_policy *policy = cdbs->cur_policy;
-
-	return cpumask_weight(policy->cpus) > 1;
-}
-EXPORT_SYMBOL_GPL(dbs_sw_coordinated_cpus);
-
 static inline void dbs_timer_init(struct dbs_data *dbs_data, int cpu,
 				  unsigned int sampling_rate)
 {
diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
index aaf073d..b72e628 100644
--- a/drivers/cpufreq/cpufreq_governor.h
+++ b/drivers/cpufreq/cpufreq_governor.h
@@ -172,7 +172,6 @@ static inline int delay_for_sampling_rate(unsigned int sampling_rate)
 
 u64 get_cpu_idle_time(unsigned int cpu, u64 *wall);
 void dbs_check_cpu(struct dbs_data *dbs_data, int cpu);
-bool dbs_sw_coordinated_cpus(struct cpu_dbs_common_info *cdbs);
 int cpufreq_governor_dbs(struct dbs_data *dbs_data,
 		struct cpufreq_policy *policy, unsigned int event);
 #endif /* _CPUFREQ_GOVERNER_H */
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 1017b90..5ae84ff 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -277,7 +277,7 @@ static void od_dbs_timer(struct work_struct *work)
 	struct od_cpu_dbs_info_s *dbs_info =
 		container_of(work, struct od_cpu_dbs_info_s, cdbs.work.work);
 
-	if (dbs_sw_coordinated_cpus(&dbs_info->cdbs)) {
+	if (policy_is_shared(dbs_info->cdbs.cur_policy)) {
 		od_timer_coordinated(dbs_info, dw);
 	} else {
 		mutex_lock(&dbs_info->cdbs.timer_mutex);
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index beef6b5..572124c 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -185,7 +185,7 @@ static void cpufreq_stats_free_table(unsigned int cpu)
 static void cpufreq_stats_free_sysfs(unsigned int cpu)
 {
 	struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
-	if (policy && (cpumask_weight(policy->cpus) == 1)) {
+	if (policy && !policy_is_shared(policy)) {
 		pr_debug("%s: Free sysfs stat\n", __func__);
 		sysfs_remove_group(&policy->kobj, &stats_attr_group);
 	}
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 5fdc6c6..f106406 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -125,6 +125,11 @@ struct cpufreq_policy {
 #define CPUFREQ_SHARED_TYPE_ALL	 (2) /* All dependent CPUs should set freq */
 #define CPUFREQ_SHARED_TYPE_ANY	 (3) /* Freq can be set from any dependent CPU*/
 
+static inline bool policy_is_shared(struct cpufreq_policy *policy)
+{
+	return cpumask_weight(policy->cpus) > 1;
+}
+
 /******************** cpufreq transition notifiers *******************/
 
 #define CPUFREQ_PRECHANGE	(0)
-- 
1.7.12.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] cpufreq: governors: implement generic policy_is_shared
  2013-01-31  9:44         ` [PATCH v2] " Fabio Baltieri
@ 2013-01-31  9:53           ` Viresh Kumar
  0 siblings, 0 replies; 6+ messages in thread
From: Viresh Kumar @ 2013-01-31  9:53 UTC (permalink / raw)
  To: Fabio Baltieri
  Cc: Rafael J. Wysocki, cpufreq, linux-pm, Linus Walleij, linaro-dev,
	linux-kernel

On 31 January 2013 15:14, Fabio Baltieri <fabio.baltieri@linaro.org> wrote:
> Implement a generic helper function policy_is_shared() to replace the
> current dbs_sw_coordinated_cpus() at cpufreq level, so that it can be
> used by code other than cpufreq governors.
>
> Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
> ---
>
> Changes from v1:
> - replaced cpumask_weight in acpi-cpufreq.c and cpufreq_stats.c, through the
>   actual check is different the semantic should be the same.

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-01-31  9:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-31  8:14 [PATCH] cpufreq: governors: implement generic policy_is_shared Fabio Baltieri
2013-01-31  8:31 ` Viresh Kumar
2013-01-31  8:55   ` Fabio Baltieri
2013-01-31  8:58     ` Viresh Kumar
     [not found]       ` <CAOh2x==1ru3bddHnJOge=1rbpc6xwzKV5F5isJhAgwX_R=2TCw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-01-31  9:44         ` [PATCH v2] " Fabio Baltieri
2013-01-31  9:53           ` 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).