Skip to contentSkip to conversation

cpuidle : multiple drivers support

PATCH In review Daniel Lezcano 5 participants 8 messages Oct 31, 2012 – Nov 7, 2012 1 message not in the archive CPU idle time management framework

lore
Share & tools
lore
#0 lore raw

v3 cover cpuidle : multiple drivers support

The discussion about having different cpus on the system with different latencies bring us to a first attemp by adding a pointer in the cpuidle_device to the states array.

But as Rafael suggested, it would make more sense to create a driver per cpu [1].

This patch adds support for multiple cpuidle drivers.

It creates a per cpu cpuidle driver pointer.

In order to not break the different drivers, the function cpuidle_register_driver assign for each cpu, the driver.

The multiple driver support is optional and if it is not set, the cpuide driver core code remains the same (except some code reorganisation).

I did the following tests compiled, booted, tested without/with CONFIG_CPU_IDLE, with/without CONFIG_CPU_IDLE_MULTIPLE_DRIVERS.

Tested on Core2 Duo T9500 with acpi_idle [and intel_idle] Tested on ARM Dual Cortex-A9 U8500 (aka Snowball)

V1 tested on Tegra3 and Vexpress TC2

[1] http://www.spinics.net/lists/linux-acpi/msg37921.html

Changelog:

V2:
* fixed sysfs output : /sys/devices/system/cpu/cpu[0-9]/driver/name
* fixed ifdefs in driver.c
* fixed register_driver function loop when unregistering
* removed WARN under spinlock
* fixed changelog for patch [2/4]
* changed cpuidle_get_cpu_driver function parameter
* removed cpuidle_for_each_driver function
* replaced smp_processor_id() by get_cpu/put_cpu

V3:
* refreshed patchset

Daniel Lezcano (4):
cpuidle: move driver's refcount to cpuidle
cpuidle: move driver checking within the lock section
cpuidle: prepare the driver core to be multi drivers aware
cpuidle: support multiple drivers

 drivers/cpuidle/Kconfig   |    9 ++
 drivers/cpuidle/cpuidle.c |   36 +++++---
 drivers/cpuidle/cpuidle.h |    4 +-
 drivers/cpuidle/driver.c  |  209 ++++++++++++++++++++++++++++++++++++++------
 drivers/cpuidle/sysfs.c   |  174 ++++++++++++++++++++++++++++++++++++--
 include/linux/cpuidle.h   |    8 ++-
 6 files changed, 388 insertions(+), 52 deletions(-)
Signature · 1 line
1.7.5.4

A message that is not in the archive (sent off-list or not yet received): 1351701888-19963-1-git-send-email-daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org

#2 lore raw

PATCH v3 3/4 cpuidle: prepare the driver core to be multi drivers aware

This patch is a preparation for the multiple drivers support.

As the next patch will introduce the multiple drivers with the Kconfig option and we want to keep the code clean and understandable, this patch defines a set of functions for encapsulating some common parts and split what should be done in a lock context or not.

---
 drivers/cpuidle/driver.c |   60 ++++++++++++++++++++++++++++++++-------------
 1 files changed, 42 insertions(+), 18 deletions(-)
drivers/cpuidle/driver.c +42 -18
index 3e59075..8246662 100644
@@ -39,11 +39,20 @@ static void set_power_states(struct cpuidle_driver *drv)
 		drv->states[i].power_usage = -1 - i;
 }
 
-/**
- * cpuidle_register_driver - registers a driver
- * @drv: the driver
- */
-int cpuidle_register_driver(struct cpuidle_driver *drv)
+static void __cpuidle_driver_init(struct cpuidle_driver *drv)
+{
+	drv->refcnt = 0;
+
+	if (!drv->power_specified)
+		set_power_states(drv);
+}
+
+static void cpuidle_set_driver(struct cpuidle_driver *drv)
+{
+	cpuidle_curr_driver = drv;
+}
+
+static int __cpuidle_register_driver(struct cpuidle_driver *drv)
 {
 	if (!drv || !drv->state_count)
 		return -EINVAL;
@@ -51,22 +60,38 @@ int cpuidle_register_driver(struct cpuidle_driver *drv)
 	if (cpuidle_disabled())
 		return -ENODEV;
 
-	spin_lock(&cpuidle_driver_lock);
-	if (cpuidle_curr_driver) {
-		spin_unlock(&cpuidle_driver_lock);
+	if (cpuidle_get_driver())
 		return -EBUSY;
-	}
 
-	if (!drv->power_specified)
-		set_power_states(drv);
+	__cpuidle_driver_init(drv);
 
-	drv->refcnt = 0;
+	cpuidle_set_driver(drv);
 
-	cpuidle_curr_driver = drv;
+	return 0;
+}
+
+static void __cpuidle_unregister_driver(struct cpuidle_driver *drv)
+{
+	if (drv != cpuidle_get_driver())
+		return;
+
+	if (!WARN_ON(drv->refcnt > 0))
+		cpuidle_set_driver(NULL);
+}
 
+/**
+ * cpuidle_register_driver - registers a driver
+ * @drv: the driver
+ */
+int cpuidle_register_driver(struct cpuidle_driver *drv)
+{
+	int ret;
+
+	spin_lock(&cpuidle_driver_lock);
+	ret = __cpuidle_register_driver(drv);
 	spin_unlock(&cpuidle_driver_lock);
 
-	return 0;
+	return ret;
 }
 EXPORT_SYMBOL_GPL(cpuidle_register_driver);
 
@@ -86,8 +111,7 @@ EXPORT_SYMBOL_GPL(cpuidle_get_driver);
 void cpuidle_unregister_driver(struct cpuidle_driver *drv)
 {
 	spin_lock(&cpuidle_driver_lock);
-	if (drv == cpuidle_curr_driver && !WARN_ON(drv->refcnt > 0))
-		cpuidle_curr_driver = NULL;
+	__cpuidle_unregister_driver(drv);
 	spin_unlock(&cpuidle_driver_lock);
 }
 EXPORT_SYMBOL_GPL(cpuidle_unregister_driver);
@@ -98,7 +122,7 @@ struct cpuidle_driver *cpuidle_driver_ref(void)
 
 	spin_lock(&cpuidle_driver_lock);
 
-	drv = cpuidle_curr_driver;
+	drv = cpuidle_get_driver();
 	drv->refcnt++;
 
 	spin_unlock(&cpuidle_driver_lock);
@@ -107,7 +131,7 @@ struct cpuidle_driver *cpuidle_driver_ref(void)
 
 void cpuidle_driver_unref(void)
 {
-	struct cpuidle_driver *drv = cpuidle_curr_driver;
+	struct cpuidle_driver *drv = cpuidle_get_driver();
 
 	spin_lock(&cpuidle_driver_lock);
 
Signature · 1 line
1.7.5.4
#3 lore raw

PATCH v3 4/4 cpuidle: support multiple drivers

In reply to a message not in the archive

With the tegra3 and the big.LITTLE [1] new architectures, several cpus with different characteristics (latencies and states) can co-exists on the system.

The cpuidle framework has the limitation of handling only identical cpus.

This patch removes this limitation by introducing the multiple driver support for cpuidle.

This option is configurable at compile time and should be enabled for the architectures mentioned above. So there is no impact for the other platforms if the option is disabled. The option defaults to 'n'. Note the multiple drivers support is also compatible with the existing drivers, even if just one driver is needed, all the cpu will be tied to this driver using an extra small chunk of processor memory.

The multiple driver support use a per-cpu driver pointer instead of a global variable and the accessor to this variable are done from a cpu context.

In order to keep the compatibility with the existing drivers, the function 'cpuidle_register_driver' and 'cpuidle_unregister_driver' will register the specified driver for all the cpus.

The semantic for the output of /sys/devices/system/cpu/cpuidle/current_driver remains the same except the driver name will be related to the current cpu.

The /sys/devices/system/cpu/cpu[0-9]/cpuidle/driver/name files are added allowing to read the per cpu driver name.

[1] http://lwn.net/Articles/481055/

---
 drivers/cpuidle/Kconfig   |    9 +++
 drivers/cpuidle/cpuidle.c |   36 ++++++----
 drivers/cpuidle/cpuidle.h |    4 +-
 drivers/cpuidle/driver.c  |  166 ++++++++++++++++++++++++++++++++++++++-----
 drivers/cpuidle/sysfs.c   |  174 +++++++++++++++++++++++++++++++++++++++++++--
 include/linux/cpuidle.h   |    7 ++-
 6 files changed, 356 insertions(+), 40 deletions(-)
drivers/cpuidle/Kconfig +9 -0
index a76b689..234ae65 100644
@@ -9,6 +9,15 @@ config CPU_IDLE
 
 	  If you're using an ACPI-enabled platform, you should say Y here.
 
+config CPU_IDLE_MULTIPLE_DRIVERS
+        bool "Support multiple cpuidle drivers"
+        depends on CPU_IDLE
+        default n
+        help
+         Allows the cpuidle framework to use different drivers for each CPU.
+         This is useful if you have a system with different CPU latencies and
+         states. If unsure say N.
+
 config CPU_IDLE_GOV_LADDER
 	bool
 	depends on CPU_IDLE
drivers/cpuidle/cpuidle.c +23 -13
index ce4cac7..711dd83 100644
@@ -68,7 +68,7 @@ static cpuidle_enter_t cpuidle_enter_ops;
 int cpuidle_play_dead(void)
 {
 	struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices);
-	struct cpuidle_driver *drv = cpuidle_get_driver();
+	struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
 	int i, dead_state = -1;
 	int power_usage = -1;
 
@@ -128,7 +128,7 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
 int cpuidle_idle_call(void)
 {
 	struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices);
-	struct cpuidle_driver *drv = cpuidle_get_driver();
+	struct cpuidle_driver *drv;
 	int next_state, entered_state;
 
 	if (off)
@@ -141,6 +141,8 @@ int cpuidle_idle_call(void)
 	if (!dev || !dev->enabled)
 		return -EBUSY;
 
+	drv = cpuidle_get_cpu_driver(dev);
+
 	/* ask the governor for the next state */
 	next_state = cpuidle_curr_governor->select(drv, dev);
 	if (need_resched()) {
@@ -312,15 +314,19 @@ static void poll_idle_init(struct cpuidle_driver *drv) {}
 int cpuidle_enable_device(struct cpuidle_device *dev)
 {
 	int ret, i;
-	struct cpuidle_driver *drv = cpuidle_get_driver();
+	struct cpuidle_driver *drv;
 
 	if (!dev)
 		return -EINVAL;
 
 	if (dev->enabled)
 		return 0;
+
+	drv = cpuidle_get_cpu_driver(dev);
+
 	if (!drv || !cpuidle_curr_governor)
 		return -EIO;
+
 	if (!dev->state_count)
 		dev->state_count = drv->state_count;
 
@@ -335,7 +341,8 @@ int cpuidle_enable_device(struct cpuidle_device *dev)
 
 	poll_idle_init(drv);
 
-	if ((ret = cpuidle_add_state_sysfs(dev)))
+	ret = cpuidle_add_device_sysfs(dev);
+	if (ret)
 		return ret;
 
 	if (cpuidle_curr_governor->enable &&
@@ -356,7 +363,7 @@ int cpuidle_enable_device(struct cpuidle_device *dev)
 	return 0;
 
 fail_sysfs:
-	cpuidle_remove_state_sysfs(dev);
+	cpuidle_remove_device_sysfs(dev);
 
 	return ret;
 }
@@ -372,17 +379,20 @@ EXPORT_SYMBOL_GPL(cpuidle_enable_device);
  */
 void cpuidle_disable_device(struct cpuidle_device *dev)
 {
+	struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
+
 	if (!dev || !dev->enabled)
 		return;
-	if (!cpuidle_get_driver() || !cpuidle_curr_governor)
+
+	if (!drv || !cpuidle_curr_governor)
 		return;
 
 	dev->enabled = 0;
 
 	if (cpuidle_curr_governor->disable)
-		cpuidle_curr_governor->disable(cpuidle_get_driver(), dev);
+		cpuidle_curr_governor->disable(drv, dev);
 
-	cpuidle_remove_state_sysfs(dev);
+	cpuidle_remove_device_sysfs(dev);
 	enabled_devices--;
 }
 
@@ -398,9 +408,9 @@ EXPORT_SYMBOL_GPL(cpuidle_disable_device);
 static int __cpuidle_register_device(struct cpuidle_device *dev)
 {
 	int ret;
-	struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver();
+	struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
 
-	if (!try_module_get(cpuidle_driver->owner))
+	if (!try_module_get(drv->owner))
 		return -EINVAL;
 
 	per_cpu(cpuidle_devices, dev->cpu) = dev;
@@ -421,7 +431,7 @@ err_coupled:
 err_sysfs:
 	list_del(&dev->device_list);
 	per_cpu(cpuidle_devices, dev->cpu) = NULL;
-	module_put(cpuidle_driver->owner);
+	module_put(drv->owner);
 	return ret;
 }
 
@@ -460,7 +470,7 @@ EXPORT_SYMBOL_GPL(cpuidle_register_device);
  */
 void cpuidle_unregister_device(struct cpuidle_device *dev)
 {
-	struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver();
+	struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
 
 	if (dev->registered == 0)
 		return;
@@ -477,7 +487,7 @@ void cpuidle_unregister_device(struct cpuidle_device *dev)
 
 	cpuidle_resume_and_unlock();
 
-	module_put(cpuidle_driver->owner);
+	module_put(drv->owner);
 }
 
 EXPORT_SYMBOL_GPL(cpuidle_unregister_device);
drivers/cpuidle/cpuidle.h +2 -2
index f6b0923..ee97e96 100644
@@ -28,8 +28,8 @@ struct device;
 
 extern int cpuidle_add_interface(struct device *dev);
 extern void cpuidle_remove_interface(struct device *dev);
-extern int cpuidle_add_state_sysfs(struct cpuidle_device *device);
-extern void cpuidle_remove_state_sysfs(struct cpuidle_device *device);
+extern int cpuidle_add_device_sysfs(struct cpuidle_device *device);
+extern void cpuidle_remove_device_sysfs(struct cpuidle_device *device);
 extern int cpuidle_add_sysfs(struct cpuidle_device *dev);
 extern void cpuidle_remove_sysfs(struct cpuidle_device *dev);
 
drivers/cpuidle/driver.c +149 -17

224 lines not on this page · raw message

drivers/cpuidle/sysfs.c +168 -6

201 lines not on this page · raw message

include/linux/cpuidle.h +5 -2
index d08e1af..3711b34 100644
@@ -91,7 +91,7 @@ struct cpuidle_device {
 	int			state_count;
 	struct cpuidle_state_usage	states_usage[CPUIDLE_STATE_MAX];
 	struct cpuidle_state_kobj *kobjs[CPUIDLE_STATE_MAX];
-
+	struct cpuidle_driver_kobj *kobj_driver;
 	struct list_head 	device_list;
 	struct kobject		kobj;
 	struct completion	kobj_unregister;
@@ -157,6 +157,10 @@ extern int cpuidle_wrap_enter(struct cpuidle_device *dev,
 					struct cpuidle_driver *drv, int index));
 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; }
@@ -183,7 +187,6 @@ static inline int cpuidle_wrap_enter(struct cpuidle_device *dev,
 					struct cpuidle_driver *drv, int index))
 { return -ENODEV; }
 static inline int cpuidle_play_dead(void) {return -ENODEV; }
-
 #endif
 
 #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
Signature · 1 line
1.7.5.4
#4 lore raw

PATCH v3 1/4 cpuidle: move driver's refcount to cpuidle

In reply to Daniel Lezcano

We want to support different cpuidle drivers co-existing together. In this case we should move the refcount to the cpuidle_driver structure to handle several drivers at a time.

---
 drivers/cpuidle/driver.c |   13 ++++++++-----
 include/linux/cpuidle.h  |    1 +
 2 files changed, 9 insertions(+), 5 deletions(-)
drivers/cpuidle/driver.c +8 -5
index 87db387..39ba8e1 100644
@@ -16,7 +16,6 @@
 
 static struct cpuidle_driver *cpuidle_curr_driver;
 DEFINE_SPINLOCK(cpuidle_driver_lock);
-int cpuidle_driver_refcount;
 
 static void set_power_states(struct cpuidle_driver *drv)
 {
@@ -61,6 +60,8 @@ int cpuidle_register_driver(struct cpuidle_driver *drv)
 	if (!drv->power_specified)
 		set_power_states(drv);
 
+	drv->refcnt = 0;
+
 	cpuidle_curr_driver = drv;
 
 	spin_unlock(&cpuidle_driver_lock);
@@ -92,7 +93,7 @@ void cpuidle_unregister_driver(struct cpuidle_driver *drv)
 
 	spin_lock(&cpuidle_driver_lock);
 
-	if (!WARN_ON(cpuidle_driver_refcount > 0))
+	if (!WARN_ON(drv->refcnt > 0))
 		cpuidle_curr_driver = NULL;
 
 	spin_unlock(&cpuidle_driver_lock);
@@ -106,7 +107,7 @@ struct cpuidle_driver *cpuidle_driver_ref(void)
 	spin_lock(&cpuidle_driver_lock);
 
 	drv = cpuidle_curr_driver;
-	cpuidle_driver_refcount++;
+	drv->refcnt++;
 
 	spin_unlock(&cpuidle_driver_lock);
 	return drv;
@@ -114,10 +115,12 @@ struct cpuidle_driver *cpuidle_driver_ref(void)
 
 void cpuidle_driver_unref(void)
 {
+	struct cpuidle_driver *drv = cpuidle_curr_driver;
+
 	spin_lock(&cpuidle_driver_lock);
 
-	if (!WARN_ON(cpuidle_driver_refcount <= 0))
-		cpuidle_driver_refcount--;
+	if (drv && !WARN_ON(drv->refcnt <= 0))
+		drv->refcnt--;
 
 	spin_unlock(&cpuidle_driver_lock);
 }
include/linux/cpuidle.h +1 -0
index 7daf0e3..d08e1af 100644
@@ -124,6 +124,7 @@ static inline int cpuidle_get_last_residency(struct cpuidle_device *dev)
 struct cpuidle_driver {
 	const char		*name;
 	struct module 		*owner;
+	int                     refcnt;
 
 	unsigned int		power_specified:1;
 	/* set to 1 to use the core cpuidle time keeping (for all states). */
Signature · 1 line
1.7.5.4
#5 lore raw

PATCH v3 2/4 cpuidle: move driver checking within the lock section

In reply to Daniel Lezcano

The code is racy and the check with cpuidle_curr_driver should be done under the lock.

I don't find a path in the different drivers where that could happen because the arch specific drivers are written in such way it is not possible to register a driver while it is unregistered, except maybe in a very improbable case when "intel_idle" and "processor_idle" are competing. One could unregister a driver, while the other one is registering.

---
 drivers/cpuidle/driver.c |   10 +---------
 1 files changed, 1 insertions(+), 9 deletions(-)
drivers/cpuidle/driver.c +1 -9
index 39ba8e1..3e59075 100644
@@ -85,17 +85,9 @@ EXPORT_SYMBOL_GPL(cpuidle_get_driver);
  */
 void cpuidle_unregister_driver(struct cpuidle_driver *drv)
 {
-	if (drv != cpuidle_curr_driver) {
-		WARN(1, "invalid cpuidle_unregister_driver(%s)\n",
-			drv->name);
-		return;
-	}
-
 	spin_lock(&cpuidle_driver_lock);
-
-	if (!WARN_ON(drv->refcnt > 0))
+	if (drv == cpuidle_curr_driver && !WARN_ON(drv->refcnt > 0))
 		cpuidle_curr_driver = NULL;
-
 	spin_unlock(&cpuidle_driver_lock);
 }
 EXPORT_SYMBOL_GPL(cpuidle_unregister_driver);
Signature · 1 line
1.7.5.4
#6 lore raw
In reply to Daniel Lezcano
Quoted 48 lines · Daniel Lezcano

The discussion about having different cpus on the system with different latencies bring us to a first attemp by adding a pointer in the cpuidle_device to the states array.

But as Rafael suggested, it would make more sense to create a driver per cpu [1].

This patch adds support for multiple cpuidle drivers.

It creates a per cpu cpuidle driver pointer.

In order to not break the different drivers, the function cpuidle_register_driver assign for each cpu, the driver.

The multiple driver support is optional and if it is not set, the cpuide driver core code remains the same (except some code reorganisation).

I did the following tests compiled, booted, tested without/with CONFIG_CPU_IDLE, with/without CONFIG_CPU_IDLE_MULTIPLE_DRIVERS.

Tested on Core2 Duo T9500 with acpi_idle [and intel_idle] Tested on ARM Dual Cortex-A9 U8500 (aka Snowball)

V1 tested on Tegra3 and Vexpress TC2

[1] http://www.spinics.net/lists/linux-acpi/msg37921.html

Changelog:

V2:
* fixed sysfs output : /sys/devices/system/cpu/cpu[0-9]/driver/name
* fixed ifdefs in driver.c
* fixed register_driver function loop when unregistering
* removed WARN under spinlock
* fixed changelog for patch [2/4]
* changed cpuidle_get_cpu_driver function parameter
* removed cpuidle_for_each_driver function
* replaced smp_processor_id() by get_cpu/put_cpu

V3:
* refreshed patchset

Daniel Lezcano (4):
cpuidle: move driver's refcount to cpuidle
cpuidle: move driver checking within the lock section
cpuidle: prepare the driver core to be multi drivers aware
cpuidle: support multiple drivers

Quoted 7 lines
 drivers/cpuidle/Kconfig   |    9 ++
 drivers/cpuidle/cpuidle.c |   36 +++++---
 drivers/cpuidle/cpuidle.h |    4 +-
 drivers/cpuidle/driver.c  |  209 ++++++++++++++++++++++++++++++++++++++------
 drivers/cpuidle/sysfs.c   |  174 ++++++++++++++++++++++++++++++++++++--
 include/linux/cpuidle.h   |    8 ++-
 6 files changed, 388 insertions(+), 52 deletions(-)

All patches in the series applied to the linux-next branch of the linux-pm.git tree as v3.8 material.

Thanks,
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
Tested-by on the v3 series
#7 lore raw
In reply to Daniel Lezcano
Quoted 17 lines · Daniel Lezcano

The discussion about having different cpus on the system with different latencies bring us to a first attemp by adding a pointer in the cpuidle_device to the states array.

But as Rafael suggested, it would make more sense to create a driver per cpu [1].

This patch adds support for multiple cpuidle drivers.

It creates a per cpu cpuidle driver pointer.

In order to not break the different drivers, the function cpuidle_register_driver assign for each cpu, the driver.

The multiple driver support is optional and if it is not set, the cpuide driver core code remains the same (except some code reorganisation).

Quoted 7 lines

I did the following tests compiled, booted, tested without/with CONFIG_CPU_IDLE, with/without CONFIG_CPU_IDLE_MULTIPLE_DRIVERS.

Tested on Core2 Duo T9500 with acpi_idle [and intel_idle] Tested on ARM Dual Cortex-A9 U8500 (aka Snowball)

V1 tested on Tegra3 and Vexpress TC2

V3 tested on TC2, hence, on the whole series

Quoted 36 lines

[1] http://www.spinics.net/lists/linux-acpi/msg37921.html

Changelog:

V2:
* fixed sysfs output : /sys/devices/system/cpu/cpu[0-9]/driver/name
* fixed ifdefs in driver.c
* fixed register_driver function loop when unregistering
* removed WARN under spinlock
* fixed changelog for patch [2/4]
* changed cpuidle_get_cpu_driver function parameter
* removed cpuidle_for_each_driver function
* replaced smp_processor_id() by get_cpu/put_cpu

V3:
* refreshed patchset

Daniel Lezcano (4):
cpuidle: move driver's refcount to cpuidle
cpuidle: move driver checking within the lock section
cpuidle: prepare the driver core to be multi drivers aware
cpuidle: support multiple drivers

 drivers/cpuidle/Kconfig   |    9 ++
 drivers/cpuidle/cpuidle.c |   36 +++++---
 drivers/cpuidle/cpuidle.h |    4 +-
 drivers/cpuidle/driver.c  |  209 ++++++++++++++++++++++++++++++++++++++------
 drivers/cpuidle/sysfs.c   |  174 ++++++++++++++++++++++++++++++++++++--
 include/linux/cpuidle.h   |    8 ++-
 6 files changed, 388 insertions(+), 52 deletions(-)
Signature · 1 line
1.7.5.4
#8 lore raw
Quoted 21 lines · Lorenzo Pieralisi
Quoted 20 lines · Daniel Lezcano

The discussion about having different cpus on the system with different latencies bring us to a first attemp by adding a pointer in the cpuidle_device to the states array.

But as Rafael suggested, it would make more sense to create a driver per cpu [1].

This patch adds support for multiple cpuidle drivers.

It creates a per cpu cpuidle driver pointer.

In order to not break the different drivers, the function cpuidle_register_driver assign for each cpu, the driver.

The multiple driver support is optional and if it is not set, the cpuide driver core code remains the same (except some code reorganisation).

I did the following tests compiled, booted, tested without/with CONFIG_CPU_IDLE, with/without CONFIG_CPU_IDLE_MULTIPLE_DRIVERS.

Quoted 9 lines
Quoted 4 lines

Tested on Core2 Duo T9500 with acpi_idle [and intel_idle] Tested on ARM Dual Cortex-A9 U8500 (aka Snowball)

V1 tested on Tegra3 and Vexpress TC2

V3 tested on TC2, hence, on the whole series

V3 tested on Tegra3, so: