Skip to contentSkip to conversation

Introducing cpuidle: core cpuidle infrastructure

PATCH In review Venkatesh Pallipadi 4 participants 5 messages Feb 12, 2007 – Feb 14, 2007 CPU idle time management framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Introducing cpuidle: core cpuidle infrastructure

Introducing 'cpuidle', a new CPU power management infrastructure to manage idle CPUs in a clean and efficient manner.
cpuidle separates out the drivers that can provide support for multiple types of idle states and policy governors that decide on what idle state to use at run time.
A cpuidle driver can support multiple idle states based on parameters like varying power consumption, wakeup latency, etc (ACPI C-states for example). A cpuidle governor can be usage model specific (laptop, server, laptop on battery etc).
Main advantage of the infrastructure being, it allows independent development of drivers and governors and allows for better CPU power management.

A huge thanks to Adam Belay and Shaohua Li who were part of this mini-project since its beginning and are greatly responsible for this patchset.

This patch:

Core cpuidle infrastructure.
Introduces a new abstraction layer for cpuidle:
* which manages drivers that can support multiple idles states. Drivers can be generic or particular to specific hardware/platform
* allows addition of multiple policy governors that can take idle state policy decision
* The core also has a set of sysfs interfaces with which administrato can know about supported drivers and governors and switch them at run time.

Index: idle20/arch/i386/Kconfig
===================================================================

arch/i386/Kconfig +2 -0
Index: linux-2.6.21-rc-mm/arch/i386/Kconfig
===================================================================
@@ -1038,6 +1038,8 @@ endmenu
 
 source "arch/i386/kernel/cpu/cpufreq/Kconfig"
 
+source "drivers/cpuidle/Kconfig"
+
 endmenu
 
 menu "Bus options (PCI, PCMCIA, EISA, MCA, ISA)"
arch/x86_64/Kconfig +2 -0
Index: linux-2.6.21-rc-mm/arch/x86_64/Kconfig
===================================================================
@@ -652,6 +652,8 @@ source "drivers/acpi/Kconfig"
 
 source "arch/x86_64/kernel/cpufreq/Kconfig"
 
+source "drivers/cpuidle/Kconfig"
+
 endmenu
 
 menu "Bus options (PCI etc.)"
drivers/Makefile +1 -0
Index: linux-2.6.21-rc-mm/drivers/Makefile
===================================================================
@@ -68,6 +68,7 @@ obj-$(CONFIG_EDAC)		+= edac/
 obj-$(CONFIG_MCA)		+= mca/
 obj-$(CONFIG_EISA)		+= eisa/
 obj-$(CONFIG_CPU_FREQ)		+= cpufreq/
+obj-$(CONFIG_CPU_IDLE)		+= cpuidle/
 obj-$(CONFIG_MMC)		+= mmc/
 obj-$(CONFIG_NEW_LEDS)		+= leds/
 obj-$(CONFIG_INFINIBAND)	+= infiniband/
drivers/cpuidle/cpuidle.c new file +287 -0

287 lines not on this page · raw message

drivers/cpuidle/cpuidle.h new file +51 -0

51 lines not on this page · raw message

drivers/cpuidle/driver.c new file +207 -0

207 lines not on this page · raw message

drivers/cpuidle/governor.c new file +160 -0

160 lines not on this page · raw message

drivers/cpuidle/governors/ladder.c new file +229 -0

229 lines not on this page · raw message

drivers/cpuidle/governors/Makefile new file +5 -0
Index: linux-2.6.21-rc-mm/drivers/cpuidle/governors/Makefile
===================================================================
@@ -0,0 +1,5 @@
+#
+# Makefile for cpuidle governors.
+#
+
+obj-$(CONFIG_CPU_IDLE_GOV_LADDER) += ladder.o
drivers/cpuidle/Kconfig new file +28 -0
Index: linux-2.6.21-rc-mm/drivers/cpuidle/Kconfig
===================================================================
@@ -0,0 +1,28 @@
+menu "CPU idle PM support"
+
+config CPU_IDLE
+	bool "CPU idle PM support"
+	help
+	  CPU idle is a generic framework for supporting software-controlled
+	  idle processor power management.  It includes modular cross-platform
+	  governors that can be swapped during runtime.
+
+	  If you're using a mobile platform that supports CPU idle PM (e.g.
+	  an ACPI-capable notebook), you should say Y here.
+
+if CPU_IDLE
+
+comment "Governors"
+
+config CPU_IDLE_GOV_LADDER
+	tristate "'ladder' governor"
+	depends on CPU_IDLE
+	default y
+	help
+	  This cpuidle governor promotes and demotes through the supported idle
+	  states using residency time and bus master activity as metrics.  This
+	  algorithm was originally introduced in the old ACPI processor driver.
+
+endif	# CPU_IDLE
+
+endmenu
drivers/cpuidle/Makefile new file +5 -0
Index: linux-2.6.21-rc-mm/drivers/cpuidle/Makefile
===================================================================
@@ -0,0 +1,5 @@
+#
+# Makefile for cpuidle.
+#
+
+obj-y += cpuidle.o driver.o governor.o sysfs.o governors/
drivers/cpuidle/sysfs.c new file +340 -0

340 lines not on this page · raw message

include/linux/cpuidle.h new file +172 -0

172 lines not on this page · raw message

#1 lore raw
Quoted 13 lines · Venkatesh Pallipadi

Introducing 'cpuidle', a new CPU power management infrastructure to manage idle CPUs in a clean and efficient manner.
cpuidle separates out the drivers that can provide support for multiple types of idle states and policy governors that decide on what idle state to use at run time.
A cpuidle driver can support multiple idle states based on parameters like varying power consumption, wakeup latency, etc (ACPI C-states for example). A cpuidle governor can be usage model specific (laptop, server, laptop on battery etc).
Main advantage of the infrastructure being, it allows independent development of drivers and governors and allows for better CPU power management.

Quoted 2 lines

A huge thanks to Adam Belay and Shaohua Li who were part of this mini-project since its beginning and are greatly responsible for this patchset.

interesting. Though I wonder about giving admins _more_ knobs to twiddle. It took cpufreq a long time to settle down in this area, and typically
'ondemand' was the answer in the end for 99.9% of people. I question the usefulness
for the whole multiple governors interface, because in the case of cpuidle there shouldn't be any real trade-off between one algorithm and another afaics? So why can't we just have one, that just 'does the right thing' ? The only differentiator that I can think of would be latency, but that seems to be a) covered in a different tunable, and b) probably wouldn't affect most people enough where it matters.

I'll do a proper code review later, but one thing stuck out like a sore thumb on a quick skim..

Quoted 1 line

+EXPORT_SYMBOL_GPL(current_driver);

That's a horribly generic name for an exported global.

current_cpuidle_driver maybe?

Signature · 1 line
http://www.codemonkey.org.uk
#2 lore raw
Quoted 5 lines

The only differentiator that I can think of would be latency, but that seems to be a) covered in a different tunable, and b) probably wouldn't affect most people enough where it matters.

and for latency the kernel already has a policy thing that tracks the maximum latency allowed.... if we need to give the user a knob to shoot himself into the foot with that one should probably be exported instead (although I'm still convinced it's a mistake since our beloved userspace WILL abuse it in the most unimaginable ways)

#3 lore raw
In reply to Dave Jones
Quoted 17 lines · Dave Jones
Quoted 13 lines · Venkatesh Pallipadi

Introducing 'cpuidle', a new CPU power management infrastructure to manage idle CPUs in a clean and efficient manner.
cpuidle separates out the drivers that can provide support for multiple types of idle states and policy governors that decide on what idle state to use at run time.
A cpuidle driver can support multiple idle states based on parameters like varying power consumption, wakeup latency, etc (ACPI C-states for example). A cpuidle governor can be usage model specific (laptop, server, laptop on battery etc).
Main advantage of the infrastructure being, it allows independent development of drivers and governors and allows for better CPU power management.

Quoted 2 lines

A huge thanks to Adam Belay and Shaohua Li who were part of this mini-project since its beginning and are greatly responsible for this patchset.

Quoted 10 lines

interesting. Though I wonder about giving admins _more_ knobs to twiddle. It took cpufreq a long time to settle down in this area, and typically
'ondemand' was the answer in the end for 99.9% of people. I question the usefulness
for the whole multiple governors interface, because in the case of cpuidle there shouldn't be any real trade-off between one algorithm and another afaics? So why can't we just have one, that just 'does the right thing' ? The only differentiator that I can think of would be latency, but that seems to be a) covered in a different tunable, and b) probably wouldn't affect most people enough where it matters.

Agreed. In long term, I think cpuidle will also have one governor that will be used in most of the cases. But, we have to go through the process of experimenting with different governors, just like cpufreq and let the best governor win. I think this interface helps to experiment with new governors in a non-disruptive way. I mean, any new experiments will not have side effects on people already using currently established drivers in distributions.

Also, one of the things we are looking at is to have ratings for different drivers and governors (similar to time subsystem), with which we can control best driver and best governor for a platform from inside the kernel, instead of depending on admin/init script to do the right thing.

Having said that, I do feel we may need a different governor for things like handhelds. I heard them saying there idle routines has more than one dimension of low power-high latency idle states. But, that do not suggest the need for runtime switch in sysfs, as it will still be one proper governor for a platform.

Quoted 9 lines

I'll do a proper code review later, but one thing stuck out like a sore thumb on a quick skim..

Quoted 1 line

+EXPORT_SYMBOL_GPL(current_driver);

That's a horribly generic name for an exported global.

current_cpuidle_driver maybe?

oops. I don't think we need to export here.
Though, name should change to current_cpuidle_driver as it is non-static. Will fix it in next rev.

Thanks,
Venki

#4 lore raw
Quoted 42 lines · Venkatesh Pallipadi
Quoted 17 lines · Dave Jones
Quoted 13 lines · Venkatesh Pallipadi

Introducing 'cpuidle', a new CPU power management infrastructure to manage idle CPUs in a clean and efficient manner.
cpuidle separates out the drivers that can provide support for multiple types of idle states and policy governors that decide on what idle state to use at run time.
A cpuidle driver can support multiple idle states based on parameters like varying power consumption, wakeup latency, etc (ACPI C-states for example). A cpuidle governor can be usage model specific (laptop, server, laptop on battery etc).
Main advantage of the infrastructure being, it allows independent development of drivers and governors and allows for better CPU power management.

Quoted 2 lines

A huge thanks to Adam Belay and Shaohua Li who were part of this mini-project since its beginning and are greatly responsible for this patchset.

Quoted 10 lines

interesting. Though I wonder about giving admins _more_ knobs to twiddle. It took cpufreq a long time to settle down in this area, and typically
'ondemand' was the answer in the end for 99.9% of people. I question the usefulness
for the whole multiple governors interface, because in the case of cpuidle there shouldn't be any real trade-off between one algorithm and another afaics? So why can't we just have one, that just 'does the right thing' ? The only differentiator that I can think of would be latency, but that seems to be a) covered in a different tunable, and b) probably wouldn't affect most people enough where it matters.

Agreed. In long term, I think cpuidle will also have one governor that will be used in most of the cases. But, we have to go through the process of experimenting with different governors, just like cpufreq and let the best governor win. I think this interface helps to experiment with new governors in a non-disruptive way. I mean, any new experiments will not have side effects on people already using currently established drivers in distributions.

Also, one of the things we are looking at is to have ratings for different drivers and governors (similar to time subsystem), with which we can control best driver and best governor for a platform from inside the kernel, instead of depending on admin/init script to do the right thing.

Quoted 5 lines

Having said that, I do feel we may need a different governor for things like handhelds. I heard them saying there idle routines has more than one dimension of low power-high latency idle states. But, that do not suggest the need for runtime switch in sysfs, as it will still be one proper governor for a platform.

Learning from the past, I think a good comparison would be the support for several block IO schedulers (e.g. deadline, cfq, anticipatory, etc). The added flexibility of a pluggable architecture allowed for a lot of innovation and experimentation that might not have happened otherwise. There even is a "noop" scheduler that makes sense for some hardware devices but not others. In short, Linux processor idle power management support needs some growing room to find its "ondemand" equivalent.

In my opinion, the best sort of a tunable would be a variable that indicates userspace's intentions to the cpuidle governor. Maybe something to the effect of the following...
- Maximum Performance
- Balanced (attempt to do well in both)
- Maximum Battery-life

Of course governors can have their own specific tunables, but it would probably be best to not touch them in the typical use-case.

Thanks,
Adam