Skip to contentSkip to conversation

CPUFreq: Implement per policy instances of governors

PATCH Superseded Viresh Kumar 3 participants 26 messages Mar 4, 2013 – Mar 27, 2013

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Viresh Kumar

author maintainer
#0 lore raw

v3 cover CPUFreq: Implement per policy instances of governors

This is targetted for 3.10-rc1 or linux-next just after the merge window.

All patches are pushed here for others to apply:
http://git.linaro.org/gitweb?p=people/vireshk/linux.git;a=shortlog;h=refs/heads/for-3.10

Currently, there can't be multiple instances of single governor_type. If we have a multi-package system, where we have multiple instances of struct policy (per package), we can't have multiple instances of same governor. i.e. We can't have multiple instances of ondemand governor for multiple packages.

Governors directory in sysfs is created at /sys/devices/system/cpu/cpufreq/ governor-name/. Which again reflects that there can be only one instance of a governor_type in the system.

This is a bottleneck for multicluster system, where we want different packages to use same governor type, but with different tunables.

This patchset is inclined towards fixing this issue. Now we will create governors directory in cpu/cpu*/cpufreq/<gov> for platforms which have multiple struct policy alive at any moment. For others the interface is kept same:
cpu/cpufreq/<gov>.

@Rafael: Clearly, I don't want to have following patch: "cpufreq: Add Kconfig option to enable/disable have_multiple_policies" and added it because of comment from Borislov against which nobody else replied :)

So, please drop it if you agree over my comments with earlier version.

V2->V3:
- Fixed value of CPUFREQ_GOV_POLICY_EXIT in the correct patch
- Drop indentation fixes from intel_pstate.c

V1->V2:
- Few patches from V1 are already picked up by Rafael for 3.9-rc1
- Last two patches are new
- Added dbs_data->exit() routines to free up memory used for struct tuners.

Viresh Kumar (4):
cpufreq: Add per policy governor-init/exit infrastructure
cpufreq: governor: Implement per policy instances of governors
cpufreq: Get rid of "struct global_attr"
cpufreq: Add Kconfig option to enable/disable have_multiple_policies

 drivers/cpufreq/Kconfig                |   3 +
 drivers/cpufreq/acpi-cpufreq.c         |   9 +-
 drivers/cpufreq/cpufreq.c              |  27 +++--
 drivers/cpufreq/cpufreq_conservative.c | 148 +++++++++++++---------
 drivers/cpufreq/cpufreq_governor.c     | 159 ++++++++++++++----------
 drivers/cpufreq/cpufreq_governor.h     |  43 +++++--
 drivers/cpufreq/cpufreq_ondemand.c     | 216 +++++++++++++++++++--------------
 drivers/cpufreq/intel_pstate.c         |  20 +--
 include/linux/cpufreq.h                |  44 ++++---
 9 files changed, 397 insertions(+), 272 deletions(-)
Signature · 1 line
1.7.12.rc2.18.g61b472e
author maintainer
#1 lore raw

PATCH v3 1/4 cpufreq: Add per policy governor-init/exit infrastructure

Currently, there can't be multiple instances of single governor_type. If we have a multi-package system, where we have multiple instances of struct policy (per package), we can't have multiple instances of same governor. i.e. We can't have multiple instances of ondemand governor for multiple packages.

Governors directory in sysfs is created at /sys/devices/system/cpu/cpufreq/ governor-name/. Which again reflects that there can be only one instance of a governor_type in the system.

This is a bottleneck for multicluster system, where we want different packages to use same governor type, but with different tunables.

This patch is inclined towards providing this infrastructure. Because we are required to allocate governor's resources dynamically now, we must do it at policy creation and end. And so got CPUFREQ_GOV_POLICY_INIT/EXIT.

---
 drivers/cpufreq/cpufreq.c | 21 ++++++++++++++++++---
 include/linux/cpufreq.h   |  9 ++++++---
 2 files changed, 24 insertions(+), 6 deletions(-)
drivers/cpufreq/cpufreq.c +18 -3
index b02824d..7d59688 100644
@@ -1070,6 +1070,8 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif
 
 	/* If cpu is last user of policy, free policy */
 	if (cpus == 1) {
+		__cpufreq_governor(data, CPUFREQ_GOV_POLICY_EXIT);
+
 		lock_policy_rwsem_read(cpu);
 		kobj = &data->kobj;
 		cmp = &data->kobj_unregister;
@@ -1651,7 +1653,7 @@ EXPORT_SYMBOL(cpufreq_get_policy);
 static int __cpufreq_set_policy(struct cpufreq_policy *data,
 				struct cpufreq_policy *policy)
 {
-	int ret = 0;
+	int ret = 0, failed = 1;
 
 	pr_debug("setting new policy for CPU %u: %u - %u kHz\n", policy->cpu,
 		policy->min, policy->max);
@@ -1705,18 +1707,31 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data,
 			pr_debug("governor switch\n");
 
 			/* end old governor */
-			if (data->governor)
+			if (data->governor) {
 				__cpufreq_governor(data, CPUFREQ_GOV_STOP);
+				__cpufreq_governor(data,
+						CPUFREQ_GOV_POLICY_EXIT);
+			}
 
 			/* start new governor */
 			data->governor = policy->governor;
-			if (__cpufreq_governor(data, CPUFREQ_GOV_START)) {
+			if (!__cpufreq_governor(data, CPUFREQ_GOV_POLICY_INIT)) {
+				if (!__cpufreq_governor(data, CPUFREQ_GOV_START))
+					failed = 0;
+				else
+					__cpufreq_governor(data,
+							CPUFREQ_GOV_POLICY_EXIT);
+			}
+
+			if (failed) {
 				/* new governor failed, so re-start old one */
 				pr_debug("starting governor %s failed\n",
 							data->governor->name);
 				if (old_gov) {
 					data->governor = old_gov;
 					__cpufreq_governor(data,
+							CPUFREQ_GOV_POLICY_INIT);
+					__cpufreq_governor(data,
 							   CPUFREQ_GOV_START);
 				}
 				ret = -EINVAL;
include/linux/cpufreq.h +6 -3
index a22944c..b7393b5 100644
@@ -106,6 +106,7 @@ struct cpufreq_policy {
 					 * governors are used */
 	unsigned int		policy; /* see above */
 	struct cpufreq_governor	*governor; /* see below */
+	void			*governor_data;
 
 	struct work_struct	update; /* if update_policy() needs to be
 					 * called, but you're in IRQ context */
@@ -178,9 +179,11 @@ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mu
  *                          CPUFREQ GOVERNORS                        *
  *********************************************************************/
 
-#define CPUFREQ_GOV_START  1
-#define CPUFREQ_GOV_STOP   2
-#define CPUFREQ_GOV_LIMITS 3
+#define CPUFREQ_GOV_START	1
+#define CPUFREQ_GOV_STOP	2
+#define CPUFREQ_GOV_LIMITS	3
+#define CPUFREQ_GOV_POLICY_INIT	4
+#define CPUFREQ_GOV_POLICY_EXIT	5
 
 struct cpufreq_governor {
 	char	name[CPUFREQ_NAME_LEN];
Signature · 1 line
1.7.12.rc2.18.g61b472e
author maintainer
#2 lore raw

PATCH v3 2/4 cpufreq: governor: Implement per policy instances of governors

In reply to Viresh Kumar

Currently, there can't be multiple instances of single governor_type. If we have a multi-package system, where we have multiple instances of struct policy (per package), we can't have multiple instances of same governor. i.e. We can't have multiple instances of ondemand governor for multiple packages.

Governors directory in sysfs is created at /sys/devices/system/cpu/cpufreq/ governor-name/. Which again reflects that there can be only one instance of a governor_type in the system.

This is a bottleneck for multicluster system, where we want different packages to use same governor type, but with different tunables.

This patch uses the infrastructure provided by earlier patch and implements init/exit routines for ondemand and conservative governors.

---
 drivers/cpufreq/cpufreq.c              |   6 -
 drivers/cpufreq/cpufreq_conservative.c | 148 +++++++++++++---------
 drivers/cpufreq/cpufreq_governor.c     | 159 ++++++++++++++----------
 drivers/cpufreq/cpufreq_governor.h     |  43 +++++--
 drivers/cpufreq/cpufreq_ondemand.c     | 216 +++++++++++++++++++--------------
 include/linux/cpufreq.h                |  15 ++-
 6 files changed, 352 insertions(+), 235 deletions(-)
drivers/cpufreq/cpufreq.c +0 -6
index 7d59688..75b64e2 100644
@@ -1546,11 +1546,6 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
 						policy->cpu, event);
 	ret = policy->governor->governor(policy, event);
 
-	if (event == CPUFREQ_GOV_START)
-		policy->governor->initialized++;
-	else if (event == CPUFREQ_GOV_STOP)
-		policy->governor->initialized--;
-
 	/* we keep one module reference alive for
 			each CPU governed by this CPU */
 	if ((event != CPUFREQ_GOV_START) || ret)
@@ -1574,7 +1569,6 @@ int cpufreq_register_governor(struct cpufreq_governor *governor)
 
 	mutex_lock(&cpufreq_governor_mutex);
 
-	governor->initialized = 0;
 	err = -EBUSY;
 	if (__find_governor(governor->name) == NULL) {
 		err = 0;
drivers/cpufreq/cpufreq_conservative.c +89 -59

317 lines not on this page · raw message

drivers/cpufreq/cpufreq_governor.c +93 -66

277 lines not on this page · raw message

drivers/cpufreq/cpufreq_governor.h +30 -13

87 lines not on this page · raw message

drivers/cpufreq/cpufreq_ondemand.c +126 -90

448 lines not on this page · raw message

include/linux/cpufreq.h +14 -1
index b7393b5..c5ac9a5 100644
@@ -107,6 +107,11 @@ struct cpufreq_policy {
 	unsigned int		policy; /* see above */
 	struct cpufreq_governor	*governor; /* see below */
 	void			*governor_data;
+	/* This should be set by init() of platforms having multiple
+	 * clock-domains, i.e.  supporting multiple policies. With this sysfs
+	 * directories of governor would be created in cpu/cpu<num>/cpufreq/
+	 * directory */
+	bool			have_multiple_policies;
 
 	struct work_struct	update; /* if update_policy() needs to be
 					 * called, but you're in IRQ context */
@@ -134,6 +139,15 @@ static inline bool policy_is_shared(struct cpufreq_policy *policy)
 	return cpumask_weight(policy->cpus) > 1;
 }
 
+static inline struct kobject *
+get_governor_parent_kobj(struct cpufreq_policy *policy)
+{
+	if (policy->have_multiple_policies)
+		return &policy->kobj;
+	else
+		return cpufreq_global_kobject;
+}
+
 /******************** cpufreq transition notifiers *******************/
 
 #define CPUFREQ_PRECHANGE	(0)
@@ -187,7 +201,6 @@ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mu
 
 struct cpufreq_governor {
 	char	name[CPUFREQ_NAME_LEN];
-	int	initialized;
 	int	(*governor)	(struct cpufreq_policy *policy,
 				 unsigned int event);
 	ssize_t	(*show_setspeed)	(struct cpufreq_policy *policy,
Signature · 1 line
1.7.12.rc2.18.g61b472e
author maintainer
#3 lore raw

Re: [PATCH V3 2/4] cpufreq: governor: Implement per policy instances of governors

Quoted 9 lines · Viresh Kumar

Currently, there can't be multiple instances of single governor_type. If we have a multi-package system, where we have multiple instances of struct policy (per package), we can't have multiple instances of same governor. i.e. We can't have multiple instances of ondemand governor for multiple packages.

Governors directory in sysfs is created at /sys/devices/system/cpu/cpufreq/ governor-name/. Which again reflects that there can be only one instance of a governor_type in the system.

Quoted 7 lines

This is a bottleneck for multicluster system, where we want different packages to use same governor type, but with different tunables.

This patch uses the infrastructure provided by earlier patch and implements init/exit routines for ondemand and conservative governors.

As discussed in other patch thread, i dropped "cpufreq: Add Kconfig option to enable/disable have_multiple_policies" patch and following is the fixup to this patch:

I have queued all patches i had for 3.10 here:

http://git.linaro.org/gitweb?p=people/vireshk/linux.git;a=shortlog;h=refs/heads/for-3.10

commit f02fca9a2478088c4f7dadf82d998ae007a56285

Author: Viresh Kumar <[email protected]>
Date:   Wed Mar 20 10:50:33 2013 +0530

fixup! cpufreq: governor: Implement per policy instances of governors

---
 drivers/cpufreq/cpufreq.c |  8 ++++++++
 include/linux/cpufreq.h   | 22 ++++++++--------------
 2 files changed, 16 insertions(+), 14 deletions(-)
drivers/cpufreq/cpufreq.c +8 -0
index a843855..3d83b02 100644
@@ -128,6 +128,14 @@ void disable_cpufreq(void)
 static LIST_HEAD(cpufreq_governor_list);
 static DEFINE_MUTEX(cpufreq_governor_mutex);
 
+struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy)
+{
+       if (cpufreq_driver->have_multiple_policies)
+               return &policy->kobj;
+       else
+               return cpufreq_global_kobject;
+}
+
 static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs)
 {
        struct cpufreq_policy *data;
include/linux/cpufreq.h +0 -5
index 6e1abd2..805c4d3 100644
@@ -107,11 +107,6 @@ struct cpufreq_policy {
        unsigned int            policy; /* see above */
        struct cpufreq_governor *governor; /* see below */
        void                    *governor_data;
-       /* This should be set by init() of platforms having multiple
-        * clock-domains, i.e.  supporting multiple policies. With this sysfs
-        * directories of governor would be created in cpu/cpu<num>/cpufreq/
-        * directory */
-       bool                    have_multiple_policies;
 
        struct work_struct      update; /* if update_policy() needs to be
                                         * called, but you're in IRQ context */
@@ -139,15 +134,6 @@ static inline bool policy_is_shared(struct

cpufreq_policy *policy)

        return cpumask_weight(policy->cpus) > 1;

}

-static inline struct kobject * -get_governor_parent_kobj(struct cpufreq_policy *policy)
-{
- if (policy->have_multiple_policies)
- return &policy->kobj;
- else
- return cpufreq_global_kobject;
-}
-
/******************** cpufreq transition notifiers *******************/

#define CPUFREQ_PRECHANGE (0)

@@ -245,6 +231,13 @@ struct cpufreq_driver {
        struct module           *owner;
        char                    name[CPUFREQ_NAME_LEN];
        u8                      flags;
+       /*
+        * This should be set by init() of platforms having multiple
+        * clock-domains, i.e.  supporting multiple policies. With this sysfs
+        * directories of governor would be created in cpu/cpu<num>/cpufreq/
+        * directory
+        */

+ bool have_multiple_policies;

        /* needed by all drivers */
        int     (*init)         (struct cpufreq_policy *policy);

@@ -329,6 +322,7 @@ const char *cpufreq_get_current_driver(void);
*********************************************************************/
int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); int cpufreq_update_policy(unsigned int cpu);
+struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy);

#ifdef CONFIG_CPU_FREQ
/* query the current CPU frequency (in kHz). If zero, cpufreq
couldn't detect it */

#4 lore raw

Re: [PATCH V3 2/4] cpufreq: governor: Implement per policy instances of governors

Quoted 18 lines · Viresh Kumar
Quoted 9 lines · Viresh Kumar

Currently, there can't be multiple instances of single governor_type. If we have a multi-package system, where we have multiple instances of struct policy (per package), we can't have multiple instances of same governor. i.e. We can't have multiple instances of ondemand governor for multiple packages.

Governors directory in sysfs is created at /sys/devices/system/cpu/cpufreq/ governor-name/. Which again reflects that there can be only one instance of a governor_type in the system.

Quoted 7 lines

This is a bottleneck for multicluster system, where we want different packages to use same governor type, but with different tunables.

This patch uses the infrastructure provided by earlier patch and implements init/exit routines for ondemand and conservative governors.

Quoted 7 lines

As discussed in other patch thread, i dropped "cpufreq: Add Kconfig option to enable/disable have_multiple_policies" patch and following is the fixup to this patch:

I have queued all patches i had for 3.10 here:

http://git.linaro.org/gitweb?p=people/vireshk/linux.git;a=shortlog;h=refs/heads/for-3.10

OK, applied these to linux-pm.git/bleeding-edge.

At the moment bleeding-edge and linux-next diverged slightly on cpufreq, but I hope the bleeding-edge material won't cause build problems to occur, so I'll be able to move it to linux-next shortly.

Quoted 5 lines

commit f02fca9a2478088c4f7dadf82d998ae007a56285

Author: Viresh Kumar <[email protected]>
Date:   Wed Mar 20 10:50:33 2013 +0530

fixup! cpufreq: governor: Implement per policy instances of governors

I'd actually prefer you to post complete updated patches instead of these fixups. They are real PITA for me and probably for everybody else trying to follow the cpufreq development recently.

Thanks,
Rafael

Quoted 84 lines
---
 drivers/cpufreq/cpufreq.c |  8 ++++++++
 include/linux/cpufreq.h   | 22 ++++++++--------------
 2 files changed, 16 insertions(+), 14 deletions(-)
drivers/cpufreq/cpufreq.c +8 -0
index a843855..3d83b02 100644
@@ -128,6 +128,14 @@ void disable_cpufreq(void)
 static LIST_HEAD(cpufreq_governor_list);
 static DEFINE_MUTEX(cpufreq_governor_mutex);
 
+struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy)
+{
+       if (cpufreq_driver->have_multiple_policies)
+               return &policy->kobj;
+       else
+               return cpufreq_global_kobject;
+}
+
 static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs)
 {
        struct cpufreq_policy *data;
include/linux/cpufreq.h +0 -14
index 6e1abd2..805c4d3 100644
@@ -107,11 +107,6 @@ struct cpufreq_policy {
        unsigned int            policy; /* see above */
        struct cpufreq_governor *governor; /* see below */
        void                    *governor_data;
-       /* This should be set by init() of platforms having multiple
-        * clock-domains, i.e.  supporting multiple policies. With this sysfs
-        * directories of governor would be created in cpu/cpu<num>/cpufreq/
-        * directory */
-       bool                    have_multiple_policies;
 
        struct work_struct      update; /* if update_policy() needs to be
                                         * called, but you're in IRQ context */
@@ -139,15 +134,6 @@ static inline bool policy_is_shared(struct
 cpufreq_policy *policy)
        return cpumask_weight(policy->cpus) > 1;
 }
 
-static inline struct kobject *
-get_governor_parent_kobj(struct cpufreq_policy *policy)
-{
-       if (policy->have_multiple_policies)
-               return &policy->kobj;
-       else
-               return cpufreq_global_kobject;
-}
-
 /******************** cpufreq transition notifiers *******************/
 

#define CPUFREQ_PRECHANGE (0)

include/linux/cpufreq.h +8 -0
@@ -245,6 +231,13 @@ struct cpufreq_driver {
        struct module           *owner;
        char                    name[CPUFREQ_NAME_LEN];
        u8                      flags;
+       /*
+        * This should be set by init() of platforms having multiple
+        * clock-domains, i.e.  supporting multiple policies. With this sysfs
+        * directories of governor would be created in cpu/cpu<num>/cpufreq/
+        * directory
+        */
+       bool                    have_multiple_policies;
 
        /* needed by all drivers */
        int     (*init)         (struct cpufreq_policy *policy);
@@ -329,6 +322,7 @@ const char *cpufreq_get_current_driver(void);
  *********************************************************************/
 int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu);
 int cpufreq_update_policy(unsigned int cpu);
+struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy);
 
 #ifdef CONFIG_CPU_FREQ
 /* query the current CPU frequency (in kHz). If zero, cpufreq

couldn't detect it */
--
To unsubscribe from this list: send the line "unsubscribe cpufreq" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
author maintainer
#5 lore raw

Re: [PATCH V3 2/4] cpufreq: governor: Implement per policy instances of governors

Quoted 7 lines · Rafael J. Wysocki
Quoted 3 lines · Viresh Kumar

I have queued all patches i had for 3.10 here:

http://git.linaro.org/gitweb?p=people/vireshk/linux.git;a=shortlog;h=refs/heads/for-3.10

OK, applied these to linux-pm.git/bleeding-edge.

Thanks.

Quoted 3 lines

At the moment bleeding-edge and linux-next diverged slightly on cpufreq, but I hope the bleeding-edge material won't cause build problems to occur, so I'll be able to move it to linux-next shortly.

There shouldn't be any build problems not because i have done all build testing properly BUT because my tree is under continuously surveillance by Fengguang's bot. And any problem with my branches is reported very early :)

Quoted 9 lines
Quoted 5 lines

commit f02fca9a2478088c4f7dadf82d998ae007a56285

Author: Viresh Kumar <[email protected]>
Date:   Wed Mar 20 10:50:33 2013 +0530

fixup! cpufreq: governor: Implement per policy instances of governors

I'd actually prefer you to post complete updated patches instead of these fixups. They are real PITA for me and probably for everybody else trying to follow the cpufreq development recently.

Hmm... I always thought fixups are way easy to review (and i still believe that's
true) as they just contain what got changed and so people don't have to review whole patch again. BUT people who are looking for complete patches to apply would be annoyed by this and hence i always show them path of my repo where they can find it. So, what i may do is, post fixups and then resend patches. So that reviewer knows what changed and others can have complete patches too.

--
viresh

#6 lore raw

Re: [PATCH V3 2/4] cpufreq: governor: Implement per policy instances of governors

Quoted 25 lines · Viresh Kumar
Quoted 7 lines · Rafael J. Wysocki
Quoted 3 lines · Viresh Kumar

I have queued all patches i had for 3.10 here:

http://git.linaro.org/gitweb?p=people/vireshk/linux.git;a=shortlog;h=refs/heads/for-3.10

OK, applied these to linux-pm.git/bleeding-edge.

Thanks.

Quoted 3 lines

At the moment bleeding-edge and linux-next diverged slightly on cpufreq, but I hope the bleeding-edge material won't cause build problems to occur, so I'll be able to move it to linux-next shortly.

There shouldn't be any build problems not because i have done all build testing properly BUT because my tree is under continuously surveillance by Fengguang's bot. And any problem with my branches is reported very early :)

Quoted 6 lines
Quoted 5 lines

commit f02fca9a2478088c4f7dadf82d998ae007a56285

Author: Viresh Kumar <[email protected]>
Date:   Wed Mar 20 10:50:33 2013 +0530

fixup! cpufreq: governor: Implement per policy instances of governors

Quoted 8 lines
Quoted 3 lines

I'd actually prefer you to post complete updated patches instead of these fixups. They are real PITA for me and probably for everybody else trying to follow the cpufreq development recently.

Hmm... I always thought fixups are way easy to review (and i still believe that's
true) as they just contain what got changed and so people don't have to review whole patch again.

They won't have to if you write in the preamble what the differences from previous versions are.

Quoted 3 lines

BUT people who are looking for complete patches to apply would be annoyed by this and hence i always show them path of my repo where they can find it.

The problem with this approach is that the complete patches never make it to the mailing lists and people have problems with connecting commits to previously posted patches.

Moreover, it is *much* more convenient to me to take patches from kernel.org patchwork than from your repos, with all due respect.

Quoted 3 lines

So, what i may do is, post fixups and then resend
patches. So that reviewer knows what changed and others can have complete patches too.

Sure, that will work too.

Thanks,
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
author maintainer
#7 lore raw

Re: [PATCH V3 2/4] cpufreq: governor: Implement per policy instances of governors

Quoted 9 lines · Rafael J. Wysocki
Quoted 4 lines · Viresh Kumar

Hmm... I always thought fixups are way easy to review (and i still believe that's
true) as they just contain what got changed and so people don't have to review whole patch again.

They won't have to if you write in the preamble what the differences from previous versions are.

You didn't get me.. How will the reviewer check if author has done what he is saying in preamble and he hasn't broken anything new?

Quoted 10 lines
Quoted 3 lines

BUT people who are looking for complete patches to apply would be annoyed by this and hence i always show them path of my repo where they can find it.

The problem with this approach is that the complete patches never make it to the mailing lists and people have problems with connecting commits to previously posted patches.

Moreover, it is *much* more convenient to me to take patches from kernel.org patchwork than from your repos, with all due respect.

I understand.. I push them to repo only when they are broken, otherwise not.

#8 lore raw

Re: [PATCH V3 2/4] cpufreq: governor: Implement per policy instances of governors

Quoted 8 lines · Viresh Kumar
Quoted 7 lines · Rafael J. Wysocki
Quoted 4 lines · Viresh Kumar

Hmm... I always thought fixups are way easy to review (and i still believe that's
true) as they just contain what got changed and so people don't have to review whole patch again.

Quoted 5 lines
Quoted 2 lines

They won't have to if you write in the preamble what the differences from previous versions are.

You didn't get me.. How will the reviewer check if author has done what he is saying in preamble and he hasn't broken anything new?

Well, if the submitter wants to cheat, she/he certainly can this way, but what's the benefit, honestly? If the reviewer actually notices that there are more differences than the submitter admits to, the consequences may be quite unpleasant for the submitter (like the rejection of any future patches, for example). And mistakes are possible anyway (and the more patches you deal with, the greater the chances of making a mistake are).

Thanks.
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
author maintainer
#9 lore raw

Re: [PATCH V3 2/4] cpufreq: governor: Implement per policy instances of governors

Quoted 6 lines · Rafael J. Wysocki

Well, if the submitter wants to cheat, she/he certainly can this way, but what's the benefit, honestly? If the reviewer actually notices that there are more differences than the submitter admits to, the consequences may be quite unpleasant for the submitter (like the rejection of any future patches, for example). And mistakes are possible anyway (and the more patches you deal with, the greater the chances of making a mistake are).

Agreed.. I was focusing on the last part: mistakes.. People learn over time and can still commit mistakes.. So a diff is always better to see what changed.

#10 lore raw

Re: [PATCH V3 2/4] cpufreq: governor: Implement per policy instances of governors

In reply to Rafael J. Wysocki
Quoted 23 lines · Rafael J. Wysocki
Quoted 22 lines · Viresh Kumar
Quoted 9 lines · Viresh Kumar

Currently, there can't be multiple instances of single governor_type. If we have a multi-package system, where we have multiple instances of struct policy (per package), we can't have multiple instances of same governor. i.e. We can't have multiple instances of ondemand governor for multiple packages.

Governors directory in sysfs is created at /sys/devices/system/cpu/cpufreq/ governor-name/. Which again reflects that there can be only one instance of a governor_type in the system.

Quoted 7 lines

This is a bottleneck for multicluster system, where we want different packages to use same governor type, but with different tunables.

This patch uses the infrastructure provided by earlier patch and implements init/exit routines for ondemand and conservative governors.

As discussed in other patch thread, i dropped "cpufreq: Add Kconfig option to enable/disable have_multiple_policies" patch and following is the fixup to this patch:

Quoted 5 lines
Quoted 3 lines

I have queued all patches i had for 3.10 here:

http://git.linaro.org/gitweb?p=people/vireshk/linux.git;a=shortlog;h=refs/heads/for-3.10

OK, applied these to linux-pm.git/bleeding-edge.

Hi, latest bleeding-edge is spewing this out on boot:

[    3.585157] ------------[ cut here ]------------
[    3.592227] WARNING: at fs/sysfs/dir.c:536 sysfs_add_one+0xc8/0x100()
[    3.599521] Hardware name: Dinar
[    3.606878] sysfs: cannot create duplicate filename '/devices/system/cpu/cpufreq/ondemand'
[    3.614634] Modules linked in:
[    3.622382] Pid: 1, comm: swapper/0 Not tainted 3.9.0-rc4+ #7
[    3.630305] Call Trace:
[    3.638251]  [<ffffffff810589cf>] warn_slowpath_common+0x7f/0xc0
[    3.646435]  [<ffffffff81058ac6>] warn_slowpath_fmt+0x46/0x50
[    3.654586]  [<ffffffff8133e2f0>] ? strlcat+0x60/0x80
[    3.662765]  [<ffffffff811fe7d8>] sysfs_add_one+0xc8/0x100
[    3.670977]  [<ffffffff811fe9cc>] create_dir+0x7c/0xd0
[    3.679239]  [<ffffffff811fecaf>] sysfs_create_subdir+0x1f/0x30
[    3.687601]  [<ffffffff812006c4>] internal_create_group+0x64/0x210
[    3.696098]  [<ffffffff812008a3>] sysfs_create_group+0x13/0x20
[    3.704700]  [<ffffffff816bf800>] cpufreq_governor_dbs+0x400/0x590
[    3.713401]  [<ffffffff816bdc37>] od_cpufreq_governor_dbs+0x17/0x20
[    3.722191]  [<ffffffff816bb437>] __cpufreq_governor+0x47/0xc0
[    3.731071]  [<ffffffff816bb94d>] __cpufreq_set_policy+0x19d/0x1b0
[    3.739968]  [<ffffffff816bca89>] cpufreq_add_dev_interface+0x259/0x2b0
[    3.748960]  [<ffffffff813cdce6>] ? acpi_processor_get_performance_info+0x21c/0x452
[    3.758099]  [<ffffffff816bc210>] ? cpufreq_update_policy+0x130/0x130
[    3.767366]  [<ffffffff816bce90>] cpufreq_add_dev+0x3b0/0x4d0
[    3.776659]  [<ffffffff821579d4>] ? cpufreq_gov_dbs_init+0x12/0x12
[    3.785985]  [<ffffffff814e6a39>] subsys_interface_register+0x89/0xd0
[    3.795452]  [<ffffffff816baf5e>] cpufreq_register_driver+0x8e/0x180
[    3.804919]  [<ffffffff82157aca>] acpi_cpufreq_init+0xf6/0x1f8
[    3.814360]  [<ffffffff814f5030>] ? set_trace_device+0x80/0x80
[    3.823558]  [<ffffffff8100206f>] do_one_initcall+0x3f/0x170
[    3.832476]  [<ffffffff8211b00a>] kernel_init_freeable+0x13e/0x1cd
[    3.841131]  [<ffffffff8211a88e>] ? do_early_param+0x86/0x86
[    3.849506]  [<ffffffff817f4c20>] ? rest_init+0x80/0x80
[    3.857557]  [<ffffffff817f4c2e>] kernel_init+0xe/0xf0
[    3.865260]  [<ffffffff8181edec>] ret_from_fork+0x7c/0xb0
[    3.872886]  [<ffffffff817f4c20>] ? rest_init+0x80/0x80
[    3.880456] ---[ end trace 1a5c6247c6d9b0ac ]---
[    3.888201] ------------[ cut here ]------------

This warning is repeated for number of cpus - 1 times.

And when I do:

$ cat /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
[  489.103388] BUG: unable to handle kernel NULL pointer dereference at 0000000000000010
[  489.112064] IP: [<ffffffff816be02c>] show_up_threshold+0x1c/0x30
[  489.120511] PGD a285e6067 PUD a27085067 PMD 0 
[  489.128690] Oops: 0000 [#1] SMP 
[  489.136521] Modules linked in:
[  489.144134] CPU 15 
[  489.144229] Pid: 1565, comm: cat Tainted: G        W    3.9.0-rc4+ #7 AMD Dinar/Dinar
[  489.159654] RIP: 0010:[<ffffffff816be02c>]  [<ffffffff816be02c>] show_up_threshold+0x1c/0x30
[  489.167864] RSP: 0018:ffff880423859e88  EFLAGS: 00010246
[  489.176043] RAX: 0000000000000000 RBX: ffff880a271188c0 RCX: ffffffff81a41810
[  489.184372] RDX: 0000000000000000 RSI: ffffffff81e02dae RDI: ffffffff820d7860
[  489.184373] RBP: ffff880423859e88 R08: ffffea0028b6df80 R09: 00000000001f05b8
[  489.184374] R10: 0000000000001b97 R11: 0000000000000246 R12: ffff880423859f50
[  489.184374] R13: 0000000000008000 R14: ffff880a271188a0 R15: ffff8804251aa070
[  489.184377] FS:  00007f3278b31700(0000) GS:ffff880a2fcc0000(0000) knlGS:0000000000000000
[  489.184378] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  489.184378] CR2: 0000000000000010 CR3: 0000000a2db82000 CR4: 00000000000407e0
[  489.184380] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  489.184381] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
[  489.184382] Process cat (pid: 1565, threadinfo ffff880423858000, task ffff880424805c00)
[  489.184382] Stack:
[  489.184389]  ffff880423859e98 ffffffff8133814f ffff880423859ef8 ffffffff811fd62a
[  489.184394]  000000002bf67be2 ffff8808260b7a80 ffffffff81a41810 00000000012c8000
[  489.184399]  ffff880423859ef8 0000000000008000 00000000012c8000 ffff880423859f50
[  489.184400] Call Trace:
[  489.184406]  [<ffffffff8133814f>] kobj_attr_show+0xf/0x30
[  489.184411]  [<ffffffff811fd62a>] sysfs_read_file+0xaa/0x190
[  489.184415]  [<ffffffff81187e30>] vfs_read+0xb0/0x180
[  489.184418]  [<ffffffff81187f52>] sys_read+0x52/0xa0
[  489.184422]  [<ffffffff8181a7fe>] ? do_page_fault+0xe/0x10
[  489.184426]  [<ffffffff8181ee99>] system_call_fastpath+0x16/0x1b
[  489.184441] Code: 52 08 e8 78 2c c8 ff 5d 48 98 c3 0f 1f 40 00 66 66 66 66 90 55 48 8b 57 70 48 89 f0 48 89 c7 48 c7 c6 ae 2d e0 81 31 c0 48 89 e5 <48> 8b 52 10 8b 52 0c e8 48 2c c8 ff 5d 48 98 c3 0f 1f 40 00 66 
[  489.184443] RIP  [<ffffffff816be02c>] show_up_threshold+0x1c/0x30
[  489.184443]  RSP <ffff880423859e88>
[  489.184444] CR2: 0000000000000010
[  489.184507] ---[ end trace 1a5c6247c6d9b0c3 ]---

Any ideas?

Thanks,

author maintainer
#11 lore raw

Re: [PATCH V3 2/4] cpufreq: governor: Implement per policy instances of governors

Quoted 83 lines · Jacob Shin

Hi, latest bleeding-edge is spewing this out on boot:

[    3.585157] ------------[ cut here ]------------
[    3.592227] WARNING: at fs/sysfs/dir.c:536 sysfs_add_one+0xc8/0x100()
[    3.599521] Hardware name: Dinar
[    3.606878] sysfs: cannot create duplicate filename '/devices/system/cpu/cpufreq/ondemand'
[    3.614634] Modules linked in:
[    3.622382] Pid: 1, comm: swapper/0 Not tainted 3.9.0-rc4+ #7
[    3.630305] Call Trace:
[    3.638251]  [<ffffffff810589cf>] warn_slowpath_common+0x7f/0xc0
[    3.646435]  [<ffffffff81058ac6>] warn_slowpath_fmt+0x46/0x50
[    3.654586]  [<ffffffff8133e2f0>] ? strlcat+0x60/0x80
[    3.662765]  [<ffffffff811fe7d8>] sysfs_add_one+0xc8/0x100
[    3.670977]  [<ffffffff811fe9cc>] create_dir+0x7c/0xd0
[    3.679239]  [<ffffffff811fecaf>] sysfs_create_subdir+0x1f/0x30
[    3.687601]  [<ffffffff812006c4>] internal_create_group+0x64/0x210
[    3.696098]  [<ffffffff812008a3>] sysfs_create_group+0x13/0x20
[    3.704700]  [<ffffffff816bf800>] cpufreq_governor_dbs+0x400/0x590
[    3.713401]  [<ffffffff816bdc37>] od_cpufreq_governor_dbs+0x17/0x20
[    3.722191]  [<ffffffff816bb437>] __cpufreq_governor+0x47/0xc0
[    3.731071]  [<ffffffff816bb94d>] __cpufreq_set_policy+0x19d/0x1b0
[    3.739968]  [<ffffffff816bca89>] cpufreq_add_dev_interface+0x259/0x2b0
[    3.748960]  [<ffffffff813cdce6>] ? acpi_processor_get_performance_info+0x21c/0x452
[    3.758099]  [<ffffffff816bc210>] ? cpufreq_update_policy+0x130/0x130
[    3.767366]  [<ffffffff816bce90>] cpufreq_add_dev+0x3b0/0x4d0
[    3.776659]  [<ffffffff821579d4>] ? cpufreq_gov_dbs_init+0x12/0x12
[    3.785985]  [<ffffffff814e6a39>] subsys_interface_register+0x89/0xd0
[    3.795452]  [<ffffffff816baf5e>] cpufreq_register_driver+0x8e/0x180
[    3.804919]  [<ffffffff82157aca>] acpi_cpufreq_init+0xf6/0x1f8
[    3.814360]  [<ffffffff814f5030>] ? set_trace_device+0x80/0x80
[    3.823558]  [<ffffffff8100206f>] do_one_initcall+0x3f/0x170
[    3.832476]  [<ffffffff8211b00a>] kernel_init_freeable+0x13e/0x1cd
[    3.841131]  [<ffffffff8211a88e>] ? do_early_param+0x86/0x86
[    3.849506]  [<ffffffff817f4c20>] ? rest_init+0x80/0x80
[    3.857557]  [<ffffffff817f4c2e>] kernel_init+0xe/0xf0
[    3.865260]  [<ffffffff8181edec>] ret_from_fork+0x7c/0xb0
[    3.872886]  [<ffffffff817f4c20>] ? rest_init+0x80/0x80
[    3.880456] ---[ end trace 1a5c6247c6d9b0ac ]---
[    3.888201] ------------[ cut here ]------------

This warning is repeated for number of cpus - 1 times.

And when I do:

$ cat /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
[  489.103388] BUG: unable to handle kernel NULL pointer dereference at 0000000000000010
[  489.112064] IP: [<ffffffff816be02c>] show_up_threshold+0x1c/0x30
[  489.120511] PGD a285e6067 PUD a27085067 PMD 0
[  489.128690] Oops: 0000 [#1] SMP
[  489.136521] Modules linked in:
[  489.144134] CPU 15
[  489.144229] Pid: 1565, comm: cat Tainted: G        W    3.9.0-rc4+ #7 AMD Dinar/Dinar
[  489.159654] RIP: 0010:[<ffffffff816be02c>]  [<ffffffff816be02c>] show_up_threshold+0x1c/0x30
[  489.167864] RSP: 0018:ffff880423859e88  EFLAGS: 00010246
[  489.176043] RAX: 0000000000000000 RBX: ffff880a271188c0 RCX: ffffffff81a41810
[  489.184372] RDX: 0000000000000000 RSI: ffffffff81e02dae RDI: ffffffff820d7860
[  489.184373] RBP: ffff880423859e88 R08: ffffea0028b6df80 R09: 00000000001f05b8
[  489.184374] R10: 0000000000001b97 R11: 0000000000000246 R12: ffff880423859f50
[  489.184374] R13: 0000000000008000 R14: ffff880a271188a0 R15: ffff8804251aa070
[  489.184377] FS:  00007f3278b31700(0000) GS:ffff880a2fcc0000(0000) knlGS:0000000000000000
[  489.184378] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  489.184378] CR2: 0000000000000010 CR3: 0000000a2db82000 CR4: 00000000000407e0
[  489.184380] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  489.184381] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
[  489.184382] Process cat (pid: 1565, threadinfo ffff880423858000, task ffff880424805c00)
[  489.184382] Stack:
[  489.184389]  ffff880423859e98 ffffffff8133814f ffff880423859ef8 ffffffff811fd62a
[  489.184394]  000000002bf67be2 ffff8808260b7a80 ffffffff81a41810 00000000012c8000
[  489.184399]  ffff880423859ef8 0000000000008000 00000000012c8000 ffff880423859f50
[  489.184400] Call Trace:
[  489.184406]  [<ffffffff8133814f>] kobj_attr_show+0xf/0x30
[  489.184411]  [<ffffffff811fd62a>] sysfs_read_file+0xaa/0x190
[  489.184415]  [<ffffffff81187e30>] vfs_read+0xb0/0x180
[  489.184418]  [<ffffffff81187f52>] sys_read+0x52/0xa0
[  489.184422]  [<ffffffff8181a7fe>] ? do_page_fault+0xe/0x10
[  489.184426]  [<ffffffff8181ee99>] system_call_fastpath+0x16/0x1b
[  489.184441] Code: 52 08 e8 78 2c c8 ff 5d 48 98 c3 0f 1f 40 00 66 66 66 66 90 55 48 8b 57 70 48 89 f0 48 89 c7 48 c7 c6 ae 2d e0 81 31 c0 48 89 e5 <48> 8b 52 10 8b 52 0c e8 48 2c c8 ff 5d 48 98 c3 0f 1f 40 00 66
[  489.184443] RIP  [<ffffffff816be02c>] show_up_threshold+0x1c/0x30
[  489.184443]  RSP <ffff880423859e88>
[  489.184444] CR2: 0000000000000010
[  489.184507] ---[ end trace 1a5c6247c6d9b0c3 ]---
Quoted 1 line

Any ideas?

Yes, i believe i have enough idea about it :)

There are two kind of systems i know:
1 - Single group of cpus controlled by a single clock line,
i.e. only one policy instance at any time
2 - multipolicy systems where we have more than one group of cpus
and every group have one clock line.

For the second case also there are two cases:
2.1 - support have_multiple_policies (i.e. have separate instance of governor
for each policy struct)
2.2 - doesn't support have_multiple_policies

The last one (2.2) is broken with my patch and attached is the fix. I have tested
it on my Lenovo Thinkpad which is more like 2.2 case.

cat of cpufreq/ondemand/** is still broken and i am too tired of fixing it now...
Its already midnight here 01:01 AM.

--
viresh

From c95ca544325f40f55858e02526d0bd6a1740480d Mon Sep 17 00:00:00 2001
Message-Id: <c95ca544325f40f55858e02526d0bd6a1740480d.1364322587.git.viresh.kumar@linaro.org>
From: Viresh Kumar <[email protected]>
Date: Tue, 26 Mar 2013 23:20:18 +0530
Subject: [PATCH] fixup! cpufreq: governor: Implement per policy instances of
governors

---
 drivers/cpufreq/cpufreq.c          | 13 +++++++
 drivers/cpufreq/cpufreq_governor.c | 74 +++++++++++++++++++++++++++-----------
 include/linux/cpufreq.h            |  2 ++
 3 files changed, 68 insertions(+), 21 deletions(-)
drivers/cpufreq/cpufreq.c +13 -0
index 8f2a603..3c79025 100644
@@ -136,6 +136,11 @@ struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy)
 		return cpufreq_global_kobject;
 }
 
+bool have_multiple_policies(void)
+{
+	return cpufreq_driver->have_multiple_policies;
+}
+
 static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs)
 {
 	struct cpufreq_policy *data;
@@ -1561,6 +1566,13 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
 						policy->cpu, event);
 	ret = policy->governor->governor(policy, event);
 
+	if (!ret) {
+		if (event == CPUFREQ_GOV_POLICY_INIT)
+			policy->governor->initialized++;
+		else if (event == CPUFREQ_GOV_POLICY_EXIT)
+			policy->governor->initialized--;
+	}
+
 	/* we keep one module reference alive for
 			each CPU governed by this CPU */
 	if ((event != CPUFREQ_GOV_START) || ret)
@@ -1584,6 +1596,7 @@ int cpufreq_register_governor(struct cpufreq_governor *governor)
 
 	mutex_lock(&cpufreq_governor_mutex);
 
+	governor->initialized = 0;
 	err = -EBUSY;
 	if (__find_governor(governor->name) == NULL) {
 		err = 0;
drivers/cpufreq/cpufreq_governor.c +53 -21

136 lines not on this page · raw message

include/linux/cpufreq.h +2 -0
index 8fe9b10..f253a3e 100644
@@ -187,6 +187,7 @@ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mu
 
 struct cpufreq_governor {
 	char	name[CPUFREQ_NAME_LEN];
+	int	initialized;
 	int	(*governor)	(struct cpufreq_policy *policy,
 				 unsigned int event);
 	ssize_t	(*show_setspeed)	(struct cpufreq_policy *policy,
@@ -323,6 +324,7 @@ const char *cpufreq_get_current_driver(void);
 int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu);
 int cpufreq_update_policy(unsigned int cpu);
 struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy);
+bool have_multiple_policies(void);
 
 #ifdef CONFIG_CPU_FREQ
 /* query the current CPU frequency (in kHz). If zero, cpufreq couldn't detect it */
Signature · 1 line
1.7.12.rc2.18.g61b472e
#12 lore raw

Re: [PATCH V3 2/4] cpufreq: governor: Implement per policy instances of governors

Quoted 115 lines · Viresh Kumar
Quoted 83 lines · Jacob Shin

Hi, latest bleeding-edge is spewing this out on boot:

[    3.585157] ------------[ cut here ]------------
[    3.592227] WARNING: at fs/sysfs/dir.c:536 sysfs_add_one+0xc8/0x100()
[    3.599521] Hardware name: Dinar
[    3.606878] sysfs: cannot create duplicate filename '/devices/system/cpu/cpufreq/ondemand'
[    3.614634] Modules linked in:
[    3.622382] Pid: 1, comm: swapper/0 Not tainted 3.9.0-rc4+ #7
[    3.630305] Call Trace:
[    3.638251]  [<ffffffff810589cf>] warn_slowpath_common+0x7f/0xc0
[    3.646435]  [<ffffffff81058ac6>] warn_slowpath_fmt+0x46/0x50
[    3.654586]  [<ffffffff8133e2f0>] ? strlcat+0x60/0x80
[    3.662765]  [<ffffffff811fe7d8>] sysfs_add_one+0xc8/0x100
[    3.670977]  [<ffffffff811fe9cc>] create_dir+0x7c/0xd0
[    3.679239]  [<ffffffff811fecaf>] sysfs_create_subdir+0x1f/0x30
[    3.687601]  [<ffffffff812006c4>] internal_create_group+0x64/0x210
[    3.696098]  [<ffffffff812008a3>] sysfs_create_group+0x13/0x20
[    3.704700]  [<ffffffff816bf800>] cpufreq_governor_dbs+0x400/0x590
[    3.713401]  [<ffffffff816bdc37>] od_cpufreq_governor_dbs+0x17/0x20
[    3.722191]  [<ffffffff816bb437>] __cpufreq_governor+0x47/0xc0
[    3.731071]  [<ffffffff816bb94d>] __cpufreq_set_policy+0x19d/0x1b0
[    3.739968]  [<ffffffff816bca89>] cpufreq_add_dev_interface+0x259/0x2b0
[    3.748960]  [<ffffffff813cdce6>] ? acpi_processor_get_performance_info+0x21c/0x452
[    3.758099]  [<ffffffff816bc210>] ? cpufreq_update_policy+0x130/0x130
[    3.767366]  [<ffffffff816bce90>] cpufreq_add_dev+0x3b0/0x4d0
[    3.776659]  [<ffffffff821579d4>] ? cpufreq_gov_dbs_init+0x12/0x12
[    3.785985]  [<ffffffff814e6a39>] subsys_interface_register+0x89/0xd0
[    3.795452]  [<ffffffff816baf5e>] cpufreq_register_driver+0x8e/0x180
[    3.804919]  [<ffffffff82157aca>] acpi_cpufreq_init+0xf6/0x1f8
[    3.814360]  [<ffffffff814f5030>] ? set_trace_device+0x80/0x80
[    3.823558]  [<ffffffff8100206f>] do_one_initcall+0x3f/0x170
[    3.832476]  [<ffffffff8211b00a>] kernel_init_freeable+0x13e/0x1cd
[    3.841131]  [<ffffffff8211a88e>] ? do_early_param+0x86/0x86
[    3.849506]  [<ffffffff817f4c20>] ? rest_init+0x80/0x80
[    3.857557]  [<ffffffff817f4c2e>] kernel_init+0xe/0xf0
[    3.865260]  [<ffffffff8181edec>] ret_from_fork+0x7c/0xb0
[    3.872886]  [<ffffffff817f4c20>] ? rest_init+0x80/0x80
[    3.880456] ---[ end trace 1a5c6247c6d9b0ac ]---
[    3.888201] ------------[ cut here ]------------

This warning is repeated for number of cpus - 1 times.

And when I do:

$ cat /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
[  489.103388] BUG: unable to handle kernel NULL pointer dereference at 0000000000000010
[  489.112064] IP: [<ffffffff816be02c>] show_up_threshold+0x1c/0x30
[  489.120511] PGD a285e6067 PUD a27085067 PMD 0
[  489.128690] Oops: 0000 [#1] SMP
[  489.136521] Modules linked in:
[  489.144134] CPU 15
[  489.144229] Pid: 1565, comm: cat Tainted: G        W    3.9.0-rc4+ #7 AMD Dinar/Dinar
[  489.159654] RIP: 0010:[<ffffffff816be02c>]  [<ffffffff816be02c>] show_up_threshold+0x1c/0x30
[  489.167864] RSP: 0018:ffff880423859e88  EFLAGS: 00010246
[  489.176043] RAX: 0000000000000000 RBX: ffff880a271188c0 RCX: ffffffff81a41810
[  489.184372] RDX: 0000000000000000 RSI: ffffffff81e02dae RDI: ffffffff820d7860
[  489.184373] RBP: ffff880423859e88 R08: ffffea0028b6df80 R09: 00000000001f05b8
[  489.184374] R10: 0000000000001b97 R11: 0000000000000246 R12: ffff880423859f50
[  489.184374] R13: 0000000000008000 R14: ffff880a271188a0 R15: ffff8804251aa070
[  489.184377] FS:  00007f3278b31700(0000) GS:ffff880a2fcc0000(0000) knlGS:0000000000000000
[  489.184378] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  489.184378] CR2: 0000000000000010 CR3: 0000000a2db82000 CR4: 00000000000407e0
[  489.184380] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  489.184381] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
[  489.184382] Process cat (pid: 1565, threadinfo ffff880423858000, task ffff880424805c00)
[  489.184382] Stack:
[  489.184389]  ffff880423859e98 ffffffff8133814f ffff880423859ef8 ffffffff811fd62a
[  489.184394]  000000002bf67be2 ffff8808260b7a80 ffffffff81a41810 00000000012c8000
[  489.184399]  ffff880423859ef8 0000000000008000 00000000012c8000 ffff880423859f50
[  489.184400] Call Trace:
[  489.184406]  [<ffffffff8133814f>] kobj_attr_show+0xf/0x30
[  489.184411]  [<ffffffff811fd62a>] sysfs_read_file+0xaa/0x190
[  489.184415]  [<ffffffff81187e30>] vfs_read+0xb0/0x180
[  489.184418]  [<ffffffff81187f52>] sys_read+0x52/0xa0
[  489.184422]  [<ffffffff8181a7fe>] ? do_page_fault+0xe/0x10
[  489.184426]  [<ffffffff8181ee99>] system_call_fastpath+0x16/0x1b
[  489.184441] Code: 52 08 e8 78 2c c8 ff 5d 48 98 c3 0f 1f 40 00 66 66 66 66 90 55 48 8b 57 70 48 89 f0 48 89 c7 48 c7 c6 ae 2d e0 81 31 c0 48 89 e5 <48> 8b 52 10 8b 52 0c e8 48 2c c8 ff 5d 48 98 c3 0f 1f 40 00 66
[  489.184443] RIP  [<ffffffff816be02c>] show_up_threshold+0x1c/0x30
[  489.184443]  RSP <ffff880423859e88>
[  489.184444] CR2: 0000000000000010
[  489.184507] ---[ end trace 1a5c6247c6d9b0c3 ]---
Quoted 1 line

Any ideas?

Yes, i believe i have enough idea about it :)

There are two kind of systems i know:
1 - Single group of cpus controlled by a single clock line,
i.e. only one policy instance at any time
2 - multipolicy systems where we have more than one group of cpus
and every group have one clock line.

For the second case also there are two cases:
2.1 - support have_multiple_policies (i.e. have separate instance of governor
for each policy struct)
2.2 - doesn't support have_multiple_policies

The last one (2.2) is broken with my patch and attached is the fix. I have tested
it on my Lenovo Thinkpad which is more like 2.2 case.

cat of cpufreq/ondemand/** is still broken and i am too tired of fixing it now...
Its already midnight here 01:01 AM.

--
viresh

drivers/cpufreq/cpufreq_governor.c +0 -0
index 41e5e56..f29feb4 100644

drivers/cpufreq/cpufreq_governor.c line 34

Quoted 6 lines
drivers/cpufreq/cpufreq_governor.c +3 -0
@@ -29,6 +29,9 @@
 
 #include "cpufreq_governor.h"
 
+/* Common data for platforms that don't need governor instance per policy */
+struct dbs_data *gdbs_data;
+

Hmm .. I don't think this works for both ondemand and conservative governors running at the same time .

author maintainer
#13 lore raw

Re: [PATCH V3 2/4] cpufreq: governor: Implement per policy instances of governors

Quoted 6 lines · Jacob Shin

Review

Quoted 2 lines · Viresh Kumar
(quoted diff) +2 -0
+struct dbs_data *gdbs_data;
+

Hmm .. I don't think this works for both ondemand and conservative governors running at the same time .

Yes, this should fix it (untested for now, i will provide a complete fix today):

(quoted diff) +0 -0

b/drivers/cpufreq/cpufreq_governor.c
index f29feb4..54ca5fc 100644

drivers/cpufreq/cpufreq_governor.c +3 -6
@@ -29,9 +29,6 @@
 
 #include "cpufreq_governor.h"
 
-/* Common data for platforms that don't need governor instance per policy */
-struct dbs_data *gdbs_data;
-
 static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall)
 {
        u64 idle_time;
@@ -233,7 +230,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
        if (have_multiple_policies())
                dbs_data = policy->governor_data;
        else
-               dbs_data = gdbs_data;
+               dbs_data = cdata->gdbs_data;
 
        WARN_ON(!dbs_data && (event != CPUFREQ_GOV_POLICY_INIT));
 
@@ -289,7 +286,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
                }
 
                if (!have_multiple_policies())
-                       gdbs_data = dbs_data;
+                       cdata->gdbs_data = dbs_data;
 
                return 0;
        case CPUFREQ_GOV_POLICY_EXIT:
@@ -307,7 +304,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
 
                        cdata->exit(dbs_data);
                        kfree(dbs_data);
-                       gdbs_data = NULL;
+                       cdata->gdbs_data = NULL;
                }
 
                policy->governor_data = NULL;
(quoted diff) +0 -0

b/drivers/cpufreq/cpufreq_governor.h
index 1f7de13..cc4a189 100644

drivers/cpufreq/cpufreq_governor.h +3 -0
@@ -133,6 +133,9 @@ struct common_dbs_data {
        int governor;
        struct attribute_group *attr_group;
 
+       /* Common data for platforms that don't set have_multiple_policies */
+       struct dbs_data *gdbs_data;
+
        struct cpu_dbs_common_info *(*get_cpu_cdbs)(int cpu);
        void *(*get_cpu_dbs_info_s)(int cpu);
        void (*gov_dbs_timer)(struct work_struct *work);
author maintainer
#14 lore raw

Re: [PATCH V3 2/4] cpufreq: governor: Implement per policy instances of governors

Quoted 4 lines · Viresh Kumar
Quoted 2 lines · Jacob Shin

Hmm .. I don't think this works for both ondemand and conservative governors running at the same time .

Hi Jacob,

This must be early morning for you and you must be looking for something to start with.

I am still stuck at a issue, which i am not able to fix.
- cat of */cpufreq/ondemand/** isn't showing anything on console, but all pointers are correctly set and i can see the right values with printk()
- I am able to see all prints for have_multiple_policies enabled.
- Due to this, i haven't tested any corner cases for now.

@Rafael: I will post all this as a separate patch later which you can then fold into original commit. I am just waiting for a complete fix.

Following is the work i have done until now (attached too), leave earlier fixups:

--------x-------------x------------------

From: Viresh Kumar <[email protected]>
Date: Tue, 26 Mar 2013 23:20:18 +0530
Subject: [PATCH] fixup! cpufreq: governor: Implement per policy instances of
governors

---
 drivers/cpufreq/cpufreq.c              | 13 +++++++
 drivers/cpufreq/cpufreq_conservative.c | 24 ++++++------
 drivers/cpufreq/cpufreq_governor.c     | 71 ++++++++++++++++++++++++----------
 drivers/cpufreq/cpufreq_governor.h     | 28 ++++++++++++--
 drivers/cpufreq/cpufreq_ondemand.c     | 25 ++++++------
 include/linux/cpufreq.h                |  2 +
 6 files changed, 113 insertions(+), 50 deletions(-)
drivers/cpufreq/cpufreq.c +0 -0
index 3d83b02..3d990b4 100644
@@ -136,6 +136,11 @@ struct kobject *get_governor_parent_kobj(struct

cpufreq_policy *policy)
return cpufreq_global_kobject;
}

+bool have_multiple_policies(void)
+{
+ return cpufreq_driver->have_multiple_policies;
+}
+
static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs) {
struct cpufreq_policy *data;
@@ -1554,6 +1559,13 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
policy->cpu, event);
ret = policy->governor->governor(policy, event);

+ if (!ret) {
+ if (event == CPUFREQ_GOV_POLICY_INIT)
+ policy->governor->initialized++;
+ else if (event == CPUFREQ_GOV_POLICY_EXIT)
+ policy->governor->initialized--;
+ }
+
/* we keep one module reference alive for
each CPU governed by this CPU */
if ((event != CPUFREQ_GOV_START) || ret)
@@ -1577,6 +1589,7 @@ int cpufreq_register_governor(struct cpufreq_governor *governor)

  mutex_lock(&cpufreq_governor_mutex);

+ governor->initialized = 0;
err = -EBUSY;
if (__find_governor(governor->name) == NULL) { err = 0;

(quoted diff) +0 -0

b/drivers/cpufreq/cpufreq_conservative.c index 63499c8..c09d7c8 100644

drivers/cpufreq/cpufreq_conservative.c +0 -0
@@ -157,11 +157,13 @@ static int dbs_cpufreq_notifier(struct

notifier_block *nb, unsigned long val,
}

/************************** sysfs interface ************************/
+static struct common_dbs_data cs_dbs_cdata; +declare_get_tuners(cs);
+
static ssize_t store_sampling_down_factor(struct cpufreq_policy *policy,
const char *buf, size_t count)
{
- struct dbs_data *dbs_data = policy->governor_data;
- struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
+ struct cs_dbs_tuners *cs_tuners = cs_get_tuners(policy, NULL); unsigned int input;
int ret;
ret = sscanf(buf, "%u", &input);
@@ -176,8 +178,8 @@ static ssize_t store_sampling_down_factor(struct cpufreq_policy *policy,
static ssize_t store_sampling_rate(struct cpufreq_policy *policy,
const char *buf, size_t count)
{
- struct dbs_data *dbs_data = policy->governor_data;
- struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
+ struct dbs_data *dbs_data = NULL;
+ struct cs_dbs_tuners *cs_tuners = cs_get_tuners(policy, &dbs_data); unsigned int input;
int ret;
ret = sscanf(buf, "%u", &input);
@@ -192,8 +194,7 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *policy,
static ssize_t store_up_threshold(struct cpufreq_policy *policy,
const char *buf, size_t count)
{
- struct dbs_data *dbs_data = policy->governor_data;
- struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
+ struct cs_dbs_tuners *cs_tuners = cs_get_tuners(policy, NULL); unsigned int input;
int ret;
ret = sscanf(buf, "%u", &input);
@@ -208,8 +209,7 @@ static ssize_t store_up_threshold(struct cpufreq_policy *policy,
static ssize_t store_down_threshold(struct cpufreq_policy *policy,
const char *buf, size_t count)
{
- struct dbs_data *dbs_data = policy->governor_data;
- struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
+ struct cs_dbs_tuners *cs_tuners = cs_get_tuners(policy, NULL); unsigned int input;
int ret;
ret = sscanf(buf, "%u", &input);
@@ -226,8 +226,7 @@ static ssize_t store_down_threshold(struct cpufreq_policy *policy,
static ssize_t store_ignore_nice(struct cpufreq_policy *policy,
const char *buf, size_t count)
{
- struct dbs_data *dbs_data = policy->governor_data;
- struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
+ struct cs_dbs_tuners *cs_tuners = cs_get_tuners(policy, NULL); unsigned int input, j;
int ret;

@@ -259,8 +258,7 @@ static ssize_t store_ignore_nice(struct cpufreq_policy *policy,
static ssize_t store_freq_step(struct cpufreq_policy *policy,
const char *buf, size_t count)
{
- struct dbs_data *dbs_data = policy->governor_data;
- struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
+ struct cs_dbs_tuners *cs_tuners = cs_get_tuners(policy, NULL); unsigned int input;
int ret;
ret = sscanf(buf, "%u", &input);
@@ -285,7 +283,7 @@ show_one(cs, up_threshold, up_threshold);
show_one(cs, down_threshold, down_threshold); show_one(cs, ignore_nice, ignore_nice);
show_one(cs, freq_step, freq_step);
-declare_show_sampling_rate_min(); +declare_show_sampling_rate_min(cs);

cpufreq_freq_attr_rw(sampling_rate); cpufreq_freq_attr_rw(sampling_down_factor);

(quoted diff) +0 -0

b/drivers/cpufreq/cpufreq_governor.c index 41e5e56..54ca5fc 100644

drivers/cpufreq/cpufreq_governor.c +50 -21

127 lines not on this page · raw message

(quoted diff) +0 -0

b/drivers/cpufreq/cpufreq_governor.h index 8b18d25..fcf10d9 100644

drivers/cpufreq/cpufreq_governor.h +21 -2
@@ -40,13 +40,29 @@
 /* Ondemand Sampling types */
 enum {OD_NORMAL_SAMPLE, OD_SUB_SAMPLE};
 
+
+#define declare_get_tuners(_gov) \
+static struct _gov##_dbs_tuners *_gov##_get_tuners \
+(struct cpufreq_policy *policy, struct dbs_data **ldbs_data) \
+{ \
+ if (have_multiple_policies()) { \
+ struct dbs_data *dbs_data = policy->governor_data; \
+ if (ldbs_data) \
+ *ldbs_data = dbs_data; \
+ return dbs_data->tuners; \
+ } else { \
+ if (ldbs_data) \
+ *ldbs_data = _gov##_dbs_cdata.gdbs_data; \
+ return _gov##_dbs_cdata.gdbs_data->tuners; \
+ } \
+}
+
 /* Macro creating sysfs show routines */
 #define show_one(_gov, file_name, object) \
 static ssize_t show_##file_name \
 (struct cpufreq_policy *policy, char *buf) \
 { \
- struct dbs_data *dbs_data = policy->governor_data; \
- struct _gov##_dbs_tuners *tuners = dbs_data->tuners; \
+ struct _gov##_dbs_tuners *tuners = _gov##_get_tuners(policy, NULL); \
  return sprintf(buf, "%u\n", tuners->file_name); \
 }
 
@@ -133,6 +149,9 @@ struct common_dbs_data {
  int governor;
  struct attribute_group *attr_group;
 
+ /* Common data for platforms that don't set have_multiple_policies */
+ struct dbs_data *gdbs_data;
+
  struct cpu_dbs_common_info *(*get_cpu_cdbs)(int cpu);
  void *(*get_cpu_dbs_info_s)(int cpu);
  void (*gov_dbs_timer)(struct work_struct *work);
@@ -177,11 +196,12 @@ static inline int

delay_for_sampling_rate(unsigned int sampling_rate)
return delay;
}

-#define declare_show_sampling_rate_min() \
+#define declare_show_sampling_rate_min(_gov) \
static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, \
char *buf) \
{ \
- struct dbs_data *dbs_data = policy->governor_data; \
+ struct dbs_data *dbs_data = NULL; \
+ _gov##_get_tuners(policy, &dbs_data); \
return sprintf(buf, "%u\n", dbs_data->min_sampling_rate); \
}

(quoted diff) +0 -0

b/drivers/cpufreq/cpufreq_ondemand.c index 29ed48a..4860137 100644

drivers/cpufreq/cpufreq_ondemand.c +3 -0
@@ -257,6 +257,9 @@ max_delay:
 }
 
 /************************** sysfs interface ************************/
+static struct common_dbs_data od_dbs_cdata;
+declare_get_tuners(od);
+
 /**
  * update_sampling_rate - update sampling rate effective immediately if needed.
  * @new_rate: new sampling rate
@@ -321,12 +324,14 @@ static void update_sampling_rate(struct dbs_data

*dbs_data,
static ssize_t store_sampling_rate(struct cpufreq_policy *policy,
const char *buf, size_t count)
{
- struct dbs_data *dbs_data = policy->governor_data;
+ struct dbs_data *dbs_data = NULL;
unsigned int input;
int ret;
ret = sscanf(buf, "%u", &input);
if (ret != 1)
return -EINVAL;
+
+ od_get_tuners(policy, &dbs_data);
update_sampling_rate(dbs_data, input);
return count;
}
@@ -334,8 +339,7 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *policy,
static ssize_t store_io_is_busy(struct cpufreq_policy *policy, const char *buf,
size_t count)
{
- struct dbs_data *dbs_data = policy->governor_data;
- struct od_dbs_tuners *od_tuners = dbs_data->tuners;
+ struct od_dbs_tuners *od_tuners = od_get_tuners(policy, NULL); unsigned int input;
int ret;
unsigned int j;
@@ -358,8 +362,7 @@ static ssize_t store_io_is_busy(struct cpufreq_policy *policy, const char *buf,
static ssize_t store_up_threshold(struct cpufreq_policy *policy,
const char *buf, size_t count)
{
- struct dbs_data *dbs_data = policy->governor_data;
- struct od_dbs_tuners *od_tuners = dbs_data->tuners;
+ struct od_dbs_tuners *od_tuners = od_get_tuners(policy, NULL); unsigned int input;
int ret;
ret = sscanf(buf, "%u", &input);
@@ -379,8 +382,7 @@ static ssize_t store_up_threshold(struct cpufreq_policy *policy,
static ssize_t store_sampling_down_factor(struct cpufreq_policy *policy,
const char *buf, size_t count)
{
- struct dbs_data *dbs_data = policy->governor_data;
- struct od_dbs_tuners *od_tuners = dbs_data->tuners;
+ struct od_dbs_tuners *od_tuners = od_get_tuners(policy, NULL); unsigned int input, j;
int ret;
ret = sscanf(buf, "%u", &input);
@@ -401,8 +403,7 @@ static ssize_t store_sampling_down_factor(struct cpufreq_policy *policy,
static ssize_t store_ignore_nice(struct cpufreq_policy *policy, const
char *buf,
size_t count)
{
- struct dbs_data *dbs_data = policy->governor_data;
- struct od_dbs_tuners *od_tuners = dbs_data->tuners;
+ struct od_dbs_tuners *od_tuners = od_get_tuners(policy, NULL); unsigned int input;
int ret;

@@ -437,8 +438,7 @@ static ssize_t store_ignore_nice(struct cpufreq_policy *policy, const char *buf,
static ssize_t store_powersave_bias(struct cpufreq_policy *policy,
const char *buf, size_t count)
{
- struct dbs_data *dbs_data = policy->governor_data;
- struct od_dbs_tuners *od_tuners = dbs_data->tuners;
+ struct od_dbs_tuners *od_tuners = od_get_tuners(policy, NULL); unsigned int input;
int ret;
ret = sscanf(buf, "%u", &input);
@@ -460,7 +460,7 @@ show_one(od, up_threshold, up_threshold);
show_one(od, sampling_down_factor, sampling_down_factor); show_one(od, ignore_nice, ignore_nice);
show_one(od, powersave_bias, powersave_bias);
-declare_show_sampling_rate_min(); +declare_show_sampling_rate_min(od);

cpufreq_freq_attr_rw(sampling_rate); cpufreq_freq_attr_rw(io_is_busy);
@@ -530,6 +530,7 @@ static int od_init(struct dbs_data *dbs_data)
tuners->io_is_busy = should_io_be_busy();

dbs_data->tuners = tuners;
+ pr_info("%s: tuners %p\n", __func__, tuners); mutex_init(&dbs_data->mutex);
return 0;
}

include/linux/cpufreq.h +0 -0
index dd53cea..394ea0d 100644
@@ -187,6 +187,7 @@ static inline unsigned long cpufreq_scale(unsigned

long old, u_int div, u_int mu

struct cpufreq_governor {
char name[CPUFREQ_NAME_LEN];
+ int initialized;
int (*governor) (struct cpufreq_policy *policy,
unsigned int event);
ssize_t (*show_setspeed) (struct cpufreq_policy *policy,
@@ -323,6 +324,7 @@ const char *cpufreq_get_current_driver(void);
int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); int cpufreq_update_policy(unsigned int cpu);
struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy);
+bool have_multiple_policies(void);

#ifdef CONFIG_CPU_FREQ
/* query the current CPU frequency (in kHz). If zero, cpufreq
couldn't detect it */

From caca8b15798ecc5ae1a46dc2dc8ed66c2ff7519b Mon Sep 17 00:00:00 2001
Message-Id: <caca8b15798ecc5ae1a46dc2dc8ed66c2ff7519b.1364378275.git.viresh.kumar@linaro.org>
From: Viresh Kumar <[email protected]>
Date: Tue, 26 Mar 2013 23:20:18 +0530
Subject: [PATCH] fixup! cpufreq: governor: Implement per policy instances of
governors

---
 drivers/cpufreq/cpufreq.c              | 13 +++++++
 drivers/cpufreq/cpufreq_conservative.c | 24 ++++++------
 drivers/cpufreq/cpufreq_governor.c     | 71 ++++++++++++++++++++++++----------
 drivers/cpufreq/cpufreq_governor.h     | 28 ++++++++++++--
 drivers/cpufreq/cpufreq_ondemand.c     | 25 ++++++------
 include/linux/cpufreq.h                |  2 +
 6 files changed, 113 insertions(+), 50 deletions(-)
drivers/cpufreq/cpufreq.c +13 -0
index 3d83b02..3d990b4 100644
@@ -136,6 +136,11 @@ struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy)
 		return cpufreq_global_kobject;
 }
 
+bool have_multiple_policies(void)
+{
+	return cpufreq_driver->have_multiple_policies;
+}
+
 static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs)
 {
 	struct cpufreq_policy *data;
@@ -1554,6 +1559,13 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
 						policy->cpu, event);
 	ret = policy->governor->governor(policy, event);
 
+	if (!ret) {
+		if (event == CPUFREQ_GOV_POLICY_INIT)
+			policy->governor->initialized++;
+		else if (event == CPUFREQ_GOV_POLICY_EXIT)
+			policy->governor->initialized--;
+	}
+
 	/* we keep one module reference alive for
 			each CPU governed by this CPU */
 	if ((event != CPUFREQ_GOV_START) || ret)
@@ -1577,6 +1589,7 @@ int cpufreq_register_governor(struct cpufreq_governor *governor)
 
 	mutex_lock(&cpufreq_governor_mutex);
 
+	governor->initialized = 0;
 	err = -EBUSY;
 	if (__find_governor(governor->name) == NULL) {
 		err = 0;
drivers/cpufreq/cpufreq_conservative.c +11 -13
index 63499c8..c09d7c8 100644
@@ -157,11 +157,13 @@ static int dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
 }
 
 /************************** sysfs interface ************************/
+static struct common_dbs_data cs_dbs_cdata;
+declare_get_tuners(cs);
+
 static ssize_t store_sampling_down_factor(struct cpufreq_policy *policy,
 		const char *buf, size_t count)
 {
-	struct dbs_data *dbs_data = policy->governor_data;
-	struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
+	struct cs_dbs_tuners *cs_tuners = cs_get_tuners(policy, NULL);
 	unsigned int input;
 	int ret;
 	ret = sscanf(buf, "%u", &input);
@@ -176,8 +178,8 @@ static ssize_t store_sampling_down_factor(struct cpufreq_policy *policy,
 static ssize_t store_sampling_rate(struct cpufreq_policy *policy,
 		const char *buf, size_t count)
 {
-	struct dbs_data *dbs_data = policy->governor_data;
-	struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
+	struct dbs_data *dbs_data = NULL;
+	struct cs_dbs_tuners *cs_tuners = cs_get_tuners(policy, &dbs_data);
 	unsigned int input;
 	int ret;
 	ret = sscanf(buf, "%u", &input);
@@ -192,8 +194,7 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *policy,
 static ssize_t store_up_threshold(struct cpufreq_policy *policy,
 		const char *buf, size_t count)
 {
-	struct dbs_data *dbs_data = policy->governor_data;
-	struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
+	struct cs_dbs_tuners *cs_tuners = cs_get_tuners(policy, NULL);
 	unsigned int input;
 	int ret;
 	ret = sscanf(buf, "%u", &input);
@@ -208,8 +209,7 @@ static ssize_t store_up_threshold(struct cpufreq_policy *policy,
 static ssize_t store_down_threshold(struct cpufreq_policy *policy,
 		const char *buf, size_t count)
 {
-	struct dbs_data *dbs_data = policy->governor_data;
-	struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
+	struct cs_dbs_tuners *cs_tuners = cs_get_tuners(policy, NULL);
 	unsigned int input;
 	int ret;
 	ret = sscanf(buf, "%u", &input);
@@ -226,8 +226,7 @@ static ssize_t store_down_threshold(struct cpufreq_policy *policy,
 static ssize_t store_ignore_nice(struct cpufreq_policy *policy,
 		const char *buf, size_t count)
 {
-	struct dbs_data *dbs_data = policy->governor_data;
-	struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
+	struct cs_dbs_tuners *cs_tuners = cs_get_tuners(policy, NULL);
 	unsigned int input, j;
 	int ret;
 
@@ -259,8 +258,7 @@ static ssize_t store_ignore_nice(struct cpufreq_policy *policy,
 static ssize_t store_freq_step(struct cpufreq_policy *policy,
 		const char *buf, size_t count)
 {
-	struct dbs_data *dbs_data = policy->governor_data;
-	struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
+	struct cs_dbs_tuners *cs_tuners = cs_get_tuners(policy, NULL);
 	unsigned int input;
 	int ret;
 	ret = sscanf(buf, "%u", &input);
@@ -285,7 +283,7 @@ show_one(cs, up_threshold, up_threshold);
 show_one(cs, down_threshold, down_threshold);
 show_one(cs, ignore_nice, ignore_nice);
 show_one(cs, freq_step, freq_step);
-declare_show_sampling_rate_min();
+declare_show_sampling_rate_min(cs);
 
 cpufreq_freq_attr_rw(sampling_rate);
 cpufreq_freq_attr_rw(sampling_down_factor);
drivers/cpufreq/cpufreq_governor.c +50 -21

127 lines not on this page · raw message

drivers/cpufreq/cpufreq_governor.h +24 -4
index 8b18d25..fcf10d9 100644
@@ -40,13 +40,29 @@
 /* Ondemand Sampling types */
 enum {OD_NORMAL_SAMPLE, OD_SUB_SAMPLE};
 
+
+#define declare_get_tuners(_gov)					\
+static struct _gov##_dbs_tuners *_gov##_get_tuners			\
+(struct cpufreq_policy *policy, struct dbs_data **ldbs_data)		\
+{									\
+	if (have_multiple_policies()) {					\
+		struct dbs_data *dbs_data = policy->governor_data;	\
+		if (ldbs_data)						\
+			*ldbs_data = dbs_data;				\
+		return dbs_data->tuners;				\
+	} else {							\
+		if (ldbs_data)						\
+			*ldbs_data = _gov##_dbs_cdata.gdbs_data;	\
+		return _gov##_dbs_cdata.gdbs_data->tuners;		\
+	}								\
+}
+
 /* Macro creating sysfs show routines */
 #define show_one(_gov, file_name, object)				\
 static ssize_t show_##file_name						\
 (struct cpufreq_policy *policy, char *buf)				\
 {									\
-	struct dbs_data *dbs_data = policy->governor_data;		\
-	struct _gov##_dbs_tuners *tuners = dbs_data->tuners;		\
+	struct _gov##_dbs_tuners *tuners = _gov##_get_tuners(policy, NULL); \
 	return sprintf(buf, "%u\n", tuners->file_name);			\
 }
 
@@ -133,6 +149,9 @@ struct common_dbs_data {
 	int governor;
 	struct attribute_group *attr_group;
 
+	/* Common data for platforms that don't set have_multiple_policies */
+	struct dbs_data *gdbs_data;
+
 	struct cpu_dbs_common_info *(*get_cpu_cdbs)(int cpu);
 	void *(*get_cpu_dbs_info_s)(int cpu);
 	void (*gov_dbs_timer)(struct work_struct *work);
@@ -177,11 +196,12 @@ static inline int delay_for_sampling_rate(unsigned int sampling_rate)
 	return delay;
 }
 
-#define declare_show_sampling_rate_min()				\
+#define declare_show_sampling_rate_min(_gov)				\
 static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy,	\
 		char *buf)						\
 {									\
-	struct dbs_data *dbs_data = policy->governor_data;		\
+	struct dbs_data *dbs_data = NULL;				\
+	_gov##_get_tuners(policy, &dbs_data);				\
 	return sprintf(buf, "%u\n", dbs_data->min_sampling_rate);	\
 }
 
drivers/cpufreq/cpufreq_ondemand.c +13 -12
index 29ed48a..4860137 100644
@@ -257,6 +257,9 @@ max_delay:
 }
 
 /************************** sysfs interface ************************/
+static struct common_dbs_data od_dbs_cdata;
+declare_get_tuners(od);
+
 /**
  * update_sampling_rate - update sampling rate effective immediately if needed.
  * @new_rate: new sampling rate
@@ -321,12 +324,14 @@ static void update_sampling_rate(struct dbs_data *dbs_data,
 static ssize_t store_sampling_rate(struct cpufreq_policy *policy,
 		const char *buf, size_t count)
 {
-	struct dbs_data *dbs_data = policy->governor_data;
+	struct dbs_data *dbs_data = NULL;
 	unsigned int input;
 	int ret;
 	ret = sscanf(buf, "%u", &input);
 	if (ret != 1)
 		return -EINVAL;
+
+	od_get_tuners(policy, &dbs_data);
 	update_sampling_rate(dbs_data, input);
 	return count;
 }
@@ -334,8 +339,7 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *policy,
 static ssize_t store_io_is_busy(struct cpufreq_policy *policy, const char *buf,
 		size_t count)
 {
-	struct dbs_data *dbs_data = policy->governor_data;
-	struct od_dbs_tuners *od_tuners = dbs_data->tuners;
+	struct od_dbs_tuners *od_tuners = od_get_tuners(policy, NULL);
 	unsigned int input;
 	int ret;
 	unsigned int j;
@@ -358,8 +362,7 @@ static ssize_t store_io_is_busy(struct cpufreq_policy *policy, const char *buf,
 static ssize_t store_up_threshold(struct cpufreq_policy *policy,
 		const char *buf, size_t count)
 {
-	struct dbs_data *dbs_data = policy->governor_data;
-	struct od_dbs_tuners *od_tuners = dbs_data->tuners;
+	struct od_dbs_tuners *od_tuners = od_get_tuners(policy, NULL);
 	unsigned int input;
 	int ret;
 	ret = sscanf(buf, "%u", &input);
@@ -379,8 +382,7 @@ static ssize_t store_up_threshold(struct cpufreq_policy *policy,
 static ssize_t store_sampling_down_factor(struct cpufreq_policy *policy,
 		const char *buf, size_t count)
 {
-	struct dbs_data *dbs_data = policy->governor_data;
-	struct od_dbs_tuners *od_tuners = dbs_data->tuners;
+	struct od_dbs_tuners *od_tuners = od_get_tuners(policy, NULL);
 	unsigned int input, j;
 	int ret;
 	ret = sscanf(buf, "%u", &input);
@@ -401,8 +403,7 @@ static ssize_t store_sampling_down_factor(struct cpufreq_policy *policy,
 static ssize_t store_ignore_nice(struct cpufreq_policy *policy, const char *buf,
 		size_t count)
 {
-	struct dbs_data *dbs_data = policy->governor_data;
-	struct od_dbs_tuners *od_tuners = dbs_data->tuners;
+	struct od_dbs_tuners *od_tuners = od_get_tuners(policy, NULL);
 	unsigned int input;
 	int ret;
 
@@ -437,8 +438,7 @@ static ssize_t store_ignore_nice(struct cpufreq_policy *policy, const char *buf,
 static ssize_t store_powersave_bias(struct cpufreq_policy *policy,
 		const char *buf, size_t count)
 {
-	struct dbs_data *dbs_data = policy->governor_data;
-	struct od_dbs_tuners *od_tuners = dbs_data->tuners;
+	struct od_dbs_tuners *od_tuners = od_get_tuners(policy, NULL);
 	unsigned int input;
 	int ret;
 	ret = sscanf(buf, "%u", &input);
@@ -460,7 +460,7 @@ show_one(od, up_threshold, up_threshold);
 show_one(od, sampling_down_factor, sampling_down_factor);
 show_one(od, ignore_nice, ignore_nice);
 show_one(od, powersave_bias, powersave_bias);
-declare_show_sampling_rate_min();
+declare_show_sampling_rate_min(od);
 
 cpufreq_freq_attr_rw(sampling_rate);
 cpufreq_freq_attr_rw(io_is_busy);
@@ -530,6 +530,7 @@ static int od_init(struct dbs_data *dbs_data)
 	tuners->io_is_busy = should_io_be_busy();
 
 	dbs_data->tuners = tuners;
+	pr_info("%s: tuners %p\n", __func__, tuners);
 	mutex_init(&dbs_data->mutex);
 	return 0;
 }
include/linux/cpufreq.h +2 -0
index dd53cea..394ea0d 100644
@@ -187,6 +187,7 @@ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mu
 
 struct cpufreq_governor {
 	char	name[CPUFREQ_NAME_LEN];
+	int	initialized;
 	int	(*governor)	(struct cpufreq_policy *policy,
 				 unsigned int event);
 	ssize_t	(*show_setspeed)	(struct cpufreq_policy *policy,
@@ -323,6 +324,7 @@ const char *cpufreq_get_current_driver(void);
 int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu);
 int cpufreq_update_policy(unsigned int cpu);
 struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy);
+bool have_multiple_policies(void);
 
 #ifdef CONFIG_CPU_FREQ
 /* query the current CPU frequency (in kHz). If zero, cpufreq couldn't detect it */
Signature · 1 line
1.7.12.rc2.18.g61b472e
author maintainer
#15 lore raw

Re: [PATCH V3 2/4] cpufreq: governor: Implement per policy instances of governors

Quoted 3 lines · Viresh Kumar

I am still stuck at a issue, which i am not able to fix.
- cat of */cpufreq/ondemand/** isn't showing anything on console, but all pointers are correctly set and i can see the right values with printk()

The culprit is the part where i changed prototypes of all show/store functions. I am still trying to understand how that part works, and will fix it soon.

--
viresh

author maintainer
#16 lore raw

Re: [PATCH V3 2/4] cpufreq: governor: Implement per policy instances of governors

Quoted 7 lines · Viresh Kumar
Quoted 3 lines · Viresh Kumar

I am still stuck at a issue, which i am not able to fix.
- cat of */cpufreq/ondemand/** isn't showing anything on console, but all pointers are correctly set and i can see the right values with printk()

The culprit is the part where i changed prototypes of all show/store functions. I am still trying to understand how that part works, and will fix it soon.

It seems i have broken some other stuff too with this patch:

commit 63173d01761a442ac5a7c73de996acbe9b0b3da7

Author: Viresh Kumar <[email protected]>
Date:   Wed Feb 6 15:37:37 2013 +0530

cpufreq: Get rid of "struct global_attr"

We don't need to keep two structures for file attributes, global_attr and freq_attr. Lets use freq_attr only for cpufreq core and drivers.

---
 drivers/cpufreq/acpi-cpufreq.c |  9 ++++-----
 drivers/cpufreq/intel_pstate.c | 20 ++++++++++----------
 include/linux/cpufreq.h        | 16 ----------------

Atleast both acpi-cpufreq and intel_pstate (including cpufreq as a whole). :(

And i don't want to post any more fixups now.. they are huge and will create more confusion..

Rather i will send next version of my patchset and ask Rafael to drop earlier patches.

Will cc you, please try them at your end.

--
viresh

author maintainer
#17 lore raw

PATCH v3 3/4 cpufreq: Get rid of "struct global_attr"

In reply to Viresh Kumar

We don't need to keep two structures for file attributes, global_attr and freq_attr. Lets use freq_attr only for cpufreq core and drivers.

---
 drivers/cpufreq/acpi-cpufreq.c |  9 ++++-----
 drivers/cpufreq/intel_pstate.c | 20 ++++++++++----------
 include/linux/cpufreq.h        | 16 ----------------
 3 files changed, 14 insertions(+), 31 deletions(-)
drivers/cpufreq/acpi-cpufreq.c +4 -5
index 937bc28..14219c3 100644
@@ -160,19 +160,18 @@ static ssize_t _store_boost(const char *buf, size_t count)
 	return count;
 }
 
-static ssize_t store_global_boost(struct kobject *kobj, struct attribute *attr,
-				  const char *buf, size_t count)
+static ssize_t store_global_boost(struct cpufreq_policy *policy,
+		const char *buf, size_t count)
 {
 	return _store_boost(buf, count);
 }
 
-static ssize_t show_global_boost(struct kobject *kobj,
-				 struct attribute *attr, char *buf)
+static ssize_t show_global_boost(struct cpufreq_policy *policy, char *buf)
 {
 	return sprintf(buf, "%u\n", boost_enabled);
 }
 
-static struct global_attr global_boost = __ATTR(boost, 0644,
+static struct freq_attr global_boost = __ATTR(boost, 0644,
 						show_global_boost,
 						store_global_boost);
 
drivers/cpufreq/intel_pstate.c +10 -10
index 096fde0..49846b9 100644
@@ -275,13 +275,13 @@ static void intel_pstate_debug_expose_params(void)
 /************************** sysfs begin ************************/
 #define show_one(file_name, object)					\
 	static ssize_t show_##file_name					\
-	(struct kobject *kobj, struct attribute *attr, char *buf)	\
+	(struct cpufreq_policy *policy, char *buf)			\
 	{								\
 		return sprintf(buf, "%u\n", limits.object);		\
 	}
 
-static ssize_t store_no_turbo(struct kobject *a, struct attribute *b,
-				const char *buf, size_t count)
+static ssize_t store_no_turbo(struct cpufreq_policy *policy, const char *buf,
+		size_t count)
 {
 	unsigned int input;
 	int ret;
@@ -293,8 +293,8 @@ static ssize_t store_no_turbo(struct kobject *a, struct attribute *b,
 	return count;
 }
 
-static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b,
-				const char *buf, size_t count)
+static ssize_t store_max_perf_pct(struct cpufreq_policy *policy,
+		const char *buf, size_t count)
 {
 	unsigned int input;
 	int ret;
@@ -307,8 +307,8 @@ static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b,
 	return count;
 }
 
-static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b,
-				const char *buf, size_t count)
+static ssize_t store_min_perf_pct(struct cpufreq_policy *policy,
+		const char *buf, size_t count)
 {
 	unsigned int input;
 	int ret;
@@ -325,9 +325,9 @@ show_one(no_turbo, no_turbo);
 show_one(max_perf_pct, max_perf_pct);
 show_one(min_perf_pct, min_perf_pct);
 
-define_one_global_rw(no_turbo);
-define_one_global_rw(max_perf_pct);
-define_one_global_rw(min_perf_pct);
+cpufreq_freq_attr_rw(no_turbo);
+cpufreq_freq_attr_rw(max_perf_pct);
+cpufreq_freq_attr_rw(min_perf_pct);
 
 static struct attribute *intel_pstate_attributes[] = {
 	&no_turbo.attr,
include/linux/cpufreq.h +0 -16
index c5ac9a5..6e1abd2 100644
@@ -320,22 +320,6 @@ __ATTR(_name, _perm, show_##_name, NULL)
 static struct freq_attr _name =			\
 __ATTR(_name, 0644, show_##_name, store_##_name)
 
-struct global_attr {
-	struct attribute attr;
-	ssize_t (*show)(struct kobject *kobj,
-			struct attribute *attr, char *buf);
-	ssize_t (*store)(struct kobject *a, struct attribute *b,
-			 const char *c, size_t count);
-};
-
-#define define_one_global_ro(_name)		\
-static struct global_attr _name =		\
-__ATTR(_name, 0444, show_##_name, NULL)
-
-#define define_one_global_rw(_name)		\
-static struct global_attr _name =		\
-__ATTR(_name, 0644, show_##_name, store_##_name)
-
 struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu);
 void cpufreq_cpu_put(struct cpufreq_policy *data);
 const char *cpufreq_get_current_driver(void);
Signature · 1 line
1.7.12.rc2.18.g61b472e
author maintainer
#18 lore raw

PATCH v3 4/4 cpufreq: Add Kconfig option to enable/disable have_multiple_policies

In reply to Viresh Kumar

have_multiple_policies is required by platforms having multiple clock-domains for cpus, i.e. supporting multiple policies for cpus. This patch adds in a Kconfig option for enabling execution of this code.

---
 drivers/cpufreq/Kconfig | 3 +++
 include/linux/cpufreq.h | 4 ++++
 2 files changed, 7 insertions(+)
drivers/cpufreq/Kconfig +3 -0
index cbcb21e..e6e6939 100644
@@ -23,6 +23,9 @@ config CPU_FREQ_TABLE
 config CPU_FREQ_GOV_COMMON
 	bool
 
+config CPU_FREQ_HAVE_MULTIPLE_POLICIES
+	bool
+
 config CPU_FREQ_STAT
 	tristate "CPU frequency translation statistics"
 	select CPU_FREQ_TABLE
include/linux/cpufreq.h +4 -0
index 6e1abd2..a092fcb 100644
@@ -107,11 +107,13 @@ struct cpufreq_policy {
 	unsigned int		policy; /* see above */
 	struct cpufreq_governor	*governor; /* see below */
 	void			*governor_data;
+#ifdef CONFIG_CPU_FREQ_HAVE_MULTIPLE_POLICIES
 	/* This should be set by init() of platforms having multiple
 	 * clock-domains, i.e.  supporting multiple policies. With this sysfs
 	 * directories of governor would be created in cpu/cpu<num>/cpufreq/
 	 * directory */
 	bool			have_multiple_policies;
+#endif
 
 	struct work_struct	update; /* if update_policy() needs to be
 					 * called, but you're in IRQ context */
@@ -142,9 +144,11 @@ static inline bool policy_is_shared(struct cpufreq_policy *policy)
 static inline struct kobject *
 get_governor_parent_kobj(struct cpufreq_policy *policy)
 {
+#ifdef CONFIG_CPU_FREQ_HAVE_MULTIPLE_POLICIES
 	if (policy->have_multiple_policies)
 		return &policy->kobj;
 	else
+#endif
 		return cpufreq_global_kobject;
 }
 
Signature · 1 line
1.7.12.rc2.18.g61b472e
#19 lore raw

Re: [PATCH V3 4/4] cpufreq: Add Kconfig option to enable/disable have_multiple_policies

Quoted 44 lines · Viresh Kumar

have_multiple_policies is required by platforms having multiple clock-domains for cpus, i.e. supporting multiple policies for cpus. This patch adds in a Kconfig option for enabling execution of this code.

---
 drivers/cpufreq/Kconfig | 3 +++
 include/linux/cpufreq.h | 4 ++++
 2 files changed, 7 insertions(+)
drivers/cpufreq/Kconfig +3 -0
index cbcb21e..e6e6939 100644
@@ -23,6 +23,9 @@ config CPU_FREQ_TABLE
 config CPU_FREQ_GOV_COMMON
 	bool
 
+config CPU_FREQ_HAVE_MULTIPLE_POLICIES
+	bool
+
 config CPU_FREQ_STAT
 	tristate "CPU frequency translation statistics"
 	select CPU_FREQ_TABLE
include/linux/cpufreq.h +2 -0
index 6e1abd2..a092fcb 100644
@@ -107,11 +107,13 @@ struct cpufreq_policy {
 	unsigned int		policy; /* see above */
 	struct cpufreq_governor	*governor; /* see below */
 	void			*governor_data;
+#ifdef CONFIG_CPU_FREQ_HAVE_MULTIPLE_POLICIES
 	/* This should be set by init() of platforms having multiple
 	 * clock-domains, i.e.  supporting multiple policies. With this sysfs
 	 * directories of governor would be created in cpu/cpu<num>/cpufreq/
 	 * directory */
 	bool			have_multiple_policies;
+#endif
 
 	struct work_struct	update; /* if update_policy() needs to be
 					 * called, but you're in IRQ context */

include/linux/cpufreq.h static inline bool policy_is_shared(struct cpufreq_policy *policy) · line 153

Quoted 10 lines
include/linux/cpufreq.h +2 -0
@@ -142,9 +144,11 @@ static inline bool policy_is_shared(struct cpufreq_policy *policy)
 static inline struct kobject *
 get_governor_parent_kobj(struct cpufreq_policy *policy)
 {
+#ifdef CONFIG_CPU_FREQ_HAVE_MULTIPLE_POLICIES
 	if (policy->have_multiple_policies)
 		return &policy->kobj;
 	else
+#endif
 		return cpufreq_global_kobject;
 }

One more question before I apply it.

Is there any architecture/platform that will set CONFIG_CPU_FREQ_HAVE_MULTIPLE_POLICIES and keep have_multiple_policies unset at the same time?

Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
author maintainer
#20 lore raw

Re: [PATCH V3 4/4] cpufreq: Add Kconfig option to enable/disable have_multiple_policies

Quoted 5 lines · Rafael J. Wysocki

One more question before I apply it.

Is there any architecture/platform that will set CONFIG_CPU_FREQ_HAVE_MULTIPLE_POLICIES and keep have_multiple_policies unset at the same time?

No, they are redundant. That's why i have been forcing to drop this patch.

#21 lore raw

Re: [PATCH V3 4/4] cpufreq: Add Kconfig option to enable/disable have_multiple_policies

Quoted 8 lines · Viresh Kumar
Quoted 5 lines · Rafael J. Wysocki

One more question before I apply it.

Is there any architecture/platform that will set CONFIG_CPU_FREQ_HAVE_MULTIPLE_POLICIES and keep have_multiple_policies unset at the same time?

No, they are redundant. That's why i have been forcing to drop this patch.

I see.

What about having the Kconfig option alone, however?

Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
author maintainer
#22 lore raw

Re: [PATCH V3 4/4] cpufreq: Add Kconfig option to enable/disable have_multiple_policies

Quoted 8 lines · Rafael J. Wysocki
Quoted 7 lines · Viresh Kumar
Quoted 5 lines · Rafael J. Wysocki

One more question before I apply it.

Is there any architecture/platform that will set CONFIG_CPU_FREQ_HAVE_MULTIPLE_POLICIES and keep have_multiple_policies unset at the same time?

Quoted 5 lines
Quoted 1 line

No, they are redundant. That's why i have been forcing to drop this patch.

I see.

What about having the Kconfig option alone, however?

Even that is not enough. We build multiplatform kernels and so need a variable to be set by platform.

#23 lore raw

Re: [PATCH V3 4/4] cpufreq: Add Kconfig option to enable/disable have_multiple_policies

Quoted 9 lines · Viresh Kumar
Quoted 8 lines · Rafael J. Wysocki
Quoted 7 lines · Viresh Kumar
Quoted 5 lines · Rafael J. Wysocki

One more question before I apply it.

Is there any architecture/platform that will set CONFIG_CPU_FREQ_HAVE_MULTIPLE_POLICIES and keep have_multiple_policies unset at the same time?

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

No, they are redundant. That's why i have been forcing to drop this patch.

I see.

What about having the Kconfig option alone, however?

Even that is not enough. We build multiplatform kernels and so need a variable to be set by platform.

Which means the Kconfig option and the field are not redundant in fact.

But do we need the field to reside in the policy structure? It looks like it may just be a global bool variable (in which case the Kconfig option could be dropped IMO). Is there any particular reason to put that thing into struct cpufreq_policy?

Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
author maintainer
#24 lore raw

Re: [PATCH V3 4/4] cpufreq: Add Kconfig option to enable/disable have_multiple_policies

Quoted 12 lines · Rafael J. Wysocki
Quoted 11 lines · Viresh Kumar
Quoted 10 lines · Rafael J. Wysocki
Quoted 8 lines · Viresh Kumar
Quoted 5 lines · Rafael J. Wysocki

One more question before I apply it.

Is there any architecture/platform that will set CONFIG_CPU_FREQ_HAVE_MULTIPLE_POLICIES and keep have_multiple_policies unset at the same time?

No, they are redundant. That's why i have been forcing to drop this patch.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

I see.

What about having the Kconfig option alone, however?

Even that is not enough. We build multiplatform kernels and so need a variable to be set by platform.

Which means the Kconfig option and the field are not redundant in fact.

Yes. Redundant was the wrong word. Actually Kconfig option is just not required as we can work efficiently without it.

Quoted 2 lines

But do we need the field to reside in the policy structure? It looks like it may just be a global bool variable

Yes. It is not per policy but per cpufreq driver. And this can be done by sharing
a function from cpufreq core to driver. But when do you want me to call this function
(which will set this global variable). If we do it from init, then we will end up calling it
again and again. Then it has to be called before calling cpufreq_register_driver(),
as init() gets called internally.

Quoted 1 line

(in which case the Kconfig option could be dropped IMO).

We are aligned now :)

Quoted 2 lines

Is there any particular reason to put that thing into struct cpufreq_policy?

Just the problem i mentioned to you.

author maintainer
#25 lore raw

Re: [PATCH V3 4/4] cpufreq: Add Kconfig option to enable/disable have_multiple_policies

Quoted 1 line · Viresh Kumar

But when do you want me to call this function

Guess what, i got answer to this question: struct cpufreq_driver :)