Skip to contentSkip to conversation

cpuidle: simplify multiple driver support

PATCH Superseded Daniel Lezcano 2 participants 6 messages May 22, 2013 – Jun 5, 2013 CPU idle time management framework

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cpuidle: simplify multiple driver support

Commit bf4d1b5ddb78f86078ac6ae0415802d5f0c68f92 brought the multiple driver support. The code added a couple of new API to register the driver per cpu. That led to some code complexity to handle the kernel config options when the multiple driver support is enabled or not, which is not really necessary. The code has to be compatible when the multiple driver support is not enabled, and the multiple driver support has to be compatible with the old api.

This patch removes this API, which is not yet used by any driver but needed for the HMP cpuidle drivers which will come soon, and replaces its usage by a cpumask pointer in the cpuidle driver structure telling what cpus are handled by the driver. That let the API cpuidle_[un]register_driver to be used for the multipled driver support and also the cpuidle_[un]register functions, added recently in the cpuidle framework.

The current code, a bit poor in comments, has been commented and simplified.

---

[V2]:
- fixed bad refcount check
- inverted clockevent notify off order at unregister time

 drivers/cpuidle/cpuidle.c |    4 +-
 drivers/cpuidle/driver.c  |  324 ++++++++++++++++++++++++++++-----------------
 include/linux/cpuidle.h   |   21 +--
 3 files changed, 213 insertions(+), 136 deletions(-)
drivers/cpuidle/cpuidle.c +2 -2
index c3a93fe..fdc432f 100644
@@ -466,7 +466,7 @@ void cpuidle_unregister(struct cpuidle_driver *drv)
 	int cpu;
 	struct cpuidle_device *device;
 
-	for_each_possible_cpu(cpu) {
+	for_each_cpu(cpu, drv->cpumask) {
 		device = &per_cpu(cpuidle_dev, cpu);
 		cpuidle_unregister_device(device);
 	}
@@ -498,7 +498,7 @@ int cpuidle_register(struct cpuidle_driver *drv,
 		return ret;
 	}
 
-	for_each_possible_cpu(cpu) {
+	for_each_cpu(cpu, drv->cpumask) {
 		device = &per_cpu(cpuidle_dev, cpu);
 		device->cpu = cpu;
 
drivers/cpuidle/driver.c +200 -124

425 lines not on this page · raw message

include/linux/cpuidle.h +11 -10
index 8f04062..63d78b1 100644
@@ -101,16 +101,20 @@ static inline int cpuidle_get_last_residency(struct cpuidle_device *dev)
  ****************************/
 
 struct cpuidle_driver {
-	const char		*name;
-	struct module 		*owner;
-	int                     refcnt;
+	const char	     *name;
+	struct module 	     *owner;
+	int                  refcnt;
 
         /* used by the cpuidle framework to setup the broadcast timer */
-	unsigned int            bctimer:1;
+	unsigned int         bctimer:1;
+
 	/* states array must be ordered in decreasing power consumption */
-	struct cpuidle_state	states[CPUIDLE_STATE_MAX];
-	int			state_count;
-	int			safe_state_index;
+	struct cpuidle_state states[CPUIDLE_STATE_MAX];
+	int		     state_count;
+	int		     safe_state_index;
+
+	/* the driver handles the cpus in cpumask */
+	struct cpumask       *cpumask;
 };
 
 #ifdef CONFIG_CPU_IDLE
@@ -135,9 +139,6 @@ extern void cpuidle_disable_device(struct cpuidle_device *dev);
 extern int cpuidle_play_dead(void);
 
 extern struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev);
-extern int cpuidle_register_cpu_driver(struct cpuidle_driver *drv, int cpu);
-extern void cpuidle_unregister_cpu_driver(struct cpuidle_driver *drv, int cpu);
-
 #else
 static inline void disable_cpuidle(void) { }
 static inline int cpuidle_idle_call(void) { return -ENODEV; }
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 14 lines · Daniel Lezcano

Commit bf4d1b5ddb78f86078ac6ae0415802d5f0c68f92 brought the multiple driver support. The code added a couple of new API to register the driver per cpu. That led to some code complexity to handle the kernel config options when the multiple driver support is enabled or not, which is not really necessary. The code has to be compatible when the multiple driver support is not enabled, and the multiple driver support has to be compatible with the old api.

This patch removes this API, which is not yet used by any driver but needed for the HMP cpuidle drivers which will come soon, and replaces its usage by a cpumask pointer in the cpuidle driver structure telling what cpus are handled by the driver. That let the API cpuidle_[un]register_driver to be used for the multipled driver support and also the cpuidle_[un]register functions, added recently in the cpuidle framework.

Quoted 8 lines

The current code, a bit poor in comments, has been commented and simplified.

---

[V2]:
- fixed bad refcount check
- inverted clockevent notify off order at unregister time

Hi Rafael,

could you consider this patch for merging ? I took into account Francesco's comments.

Thanks
-- Daniel

-- <http://www.linaro.org/> Linaro.org │ Open source software for ARM
SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |

<http://www.linaro.org/linaro-blog/> Blog

#2 lore raw
Quoted 20 lines · Daniel Lezcano
Quoted 19 lines · Daniel Lezcano

Commit bf4d1b5ddb78f86078ac6ae0415802d5f0c68f92 brought the multiple driver support. The code added a couple of new API to register the driver per cpu. That led to some code complexity to handle the kernel config options when the multiple driver support is enabled or not, which is not really necessary. The code has to be compatible when the multiple driver support is not enabled, and the multiple driver support has to be compatible with the old api.

This patch removes this API, which is not yet used by any driver but needed for the HMP cpuidle drivers which will come soon, and replaces its usage by a cpumask pointer in the cpuidle driver structure telling what cpus are handled by the driver. That let the API cpuidle_[un]register_driver to be used for the multipled driver support and also the cpuidle_[un]register functions, added recently in the cpuidle framework.

The current code, a bit poor in comments, has been commented and simplified.

---

Quoted 8 lines
Quoted 3 lines

[V2]:
- fixed bad refcount check
- inverted clockevent notify off order at unregister time

Hi Rafael,

could you consider this patch for merging ? I took into account Francesco's comments.

I'm waiting for Len to have a look at it which may take a few days more.

Thanks,
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#3 lore raw
Quoted 21 lines · Rafael J. Wysocki
Quoted 20 lines · Daniel Lezcano
Quoted 19 lines · Daniel Lezcano

Commit bf4d1b5ddb78f86078ac6ae0415802d5f0c68f92 brought the multiple driver support. The code added a couple of new API to register the driver per cpu. That led to some code complexity to handle the kernel config options when the multiple driver support is enabled or not, which is not really necessary. The code has to be compatible when the multiple driver support is not enabled, and the multiple driver support has to be compatible with the old api.

This patch removes this API, which is not yet used by any driver but needed for the HMP cpuidle drivers which will come soon, and replaces its usage by a cpumask pointer in the cpuidle driver structure telling what cpus are handled by the driver. That let the API cpuidle_[un]register_driver to be used for the multipled driver support and also the cpuidle_[un]register functions, added recently in the cpuidle framework.

The current code, a bit poor in comments, has been commented and simplified.

---

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

[V2]:
- fixed bad refcount check
- inverted clockevent notify off order at unregister time

Hi Rafael,

could you consider this patch for merging ? I took into account Francesco's comments.

I'm waiting for Len to have a look at it which may take a few days more.

Ok, is it possible to queue the patch for 3.11 now ?

Thanks
-- Daniel

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#4 lore raw
Quoted 25 lines · Daniel Lezcano
Quoted 24 lines · Rafael J. Wysocki
Quoted 23 lines · Daniel Lezcano
Quoted 22 lines · Daniel Lezcano

Commit bf4d1b5ddb78f86078ac6ae0415802d5f0c68f92 brought the multiple driver support. The code added a couple of new API to register the driver per cpu. That led to some code complexity to handle the kernel config options when the multiple driver support is enabled or not, which is not really necessary. The code has to be compatible when the multiple driver support is not enabled, and the multiple driver support has to be compatible with the old api.

This patch removes this API, which is not yet used by any driver but needed for the HMP cpuidle drivers which will come soon, and replaces its usage by a cpumask pointer in the cpuidle driver structure telling what cpus are handled by the driver. That let the API cpuidle_[un]register_driver to be used for the multipled driver support and also the cpuidle_[un]register functions, added recently in the cpuidle framework.

The current code, a bit poor in comments, has been commented and simplified.

---

[V2]:
- fixed bad refcount check
- inverted clockevent notify off order at unregister time

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

Hi Rafael,

could you consider this patch for merging ? I took into account Francesco's comments.

I'm waiting for Len to have a look at it which may take a few days more.

Ok, is it possible to queue the patch for 3.11 now ?

Actually, can you please separate adding kerneldoc comments from functional changes? That'd make the patch(es) easier to grasp.

Thanks,
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#5 lore raw
Quoted 28 lines · Rafael J. Wysocki
Quoted 27 lines · Daniel Lezcano
Quoted 26 lines · Rafael J. Wysocki
Quoted 25 lines · Daniel Lezcano
Quoted 14 lines · Daniel Lezcano

Commit bf4d1b5ddb78f86078ac6ae0415802d5f0c68f92 brought the multiple driver support. The code added a couple of new API to register the driver per cpu. That led to some code complexity to handle the kernel config options when the multiple driver support is enabled or not, which is not really necessary. The code has to be compatible when the multiple driver support is not enabled, and the multiple driver support has to be compatible with the old api.

This patch removes this API, which is not yet used by any driver but needed for the HMP cpuidle drivers which will come soon, and replaces its usage by a cpumask pointer in the cpuidle driver structure telling what cpus are handled by the driver. That let the API cpuidle_[un]register_driver to be used for the multipled driver support and also the cpuidle_[un]register functions, added recently in the cpuidle framework.

Quoted 8 lines

The current code, a bit poor in comments, has been commented and simplified.

---

[V2]:
- fixed bad refcount check
- inverted clockevent notify off order at unregister time

Hi Rafael,

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines

could you consider this patch for merging ? I took into account Francesco's comments.

I'm waiting for Len to have a look at it which may take a few days more.

Ok, is it possible to queue the patch for 3.11 now ?

Actually, can you please separate adding kerneldoc comments from functional changes? That'd make the patch(es) easier to grasp.

Sure.

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog