add lowpower_idle sysctl
Subsystems (2)
On ia64, we need runtime control to manage CPU power state in the idle loop. Logically it means a sysctl entry in /proc/sys/kernel. Even though this sysctl entry doesn't exist today, lots of arch already has some sort of API to dynamically enable/disable low power idle state. Looking at linux-2.6.4, arm, arm26, cris, i386, parisc, sh, um, x86-64 all has very much the same code in each arch. So instead of replicate another set under arch/ia64, we are proposing these API to be abstracted out in the generic code. And also add a sysctl entry under /proc/sys/kernel.
Would this be useful to all architecture who wants this features? It would be a lot less code duplication.
- Ken
include/linux/sysctl.h +1 -0
@@ -131,6 +131,7 @@ KERN_PRINTK_RATELIMIT_BURSTa,/* int: tune printk ratelimiting */ KERN_PTYb,/* dir: pty driver */ KERN_NGROUPS_MAXc,/* int: NGROUPS_MAX */ + KERN_LOWPOWER_IDLEd, /* int: low power idle */ };
kernel/cpu.c +12 -0
@@ -64,3 +64,15 @@up (&cpucontrol);return ret; } + +atomic_t halt_counter; +void enable_halt (void ) +{ +atomic_dec (&halt_counter); +} +void disable_halt (void ) +{ +atomic_inc (&halt_counter); +} +EXPORT_SYMBOL (enable_halt); +EXPORT_SYMBOL (disable_halt);
kernel/sysctl.c +9 -0
@@ -64,6 +64,7 @@extern int min_free_kbytes;extern int printk_ratelimit_jiffies;extern int printk_ratelimit_burst; +extern atomic_t halt_counter;/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ static int maxolduid =65535 ;
@@ -615,6 +616,14 @@ .mode = 0444, .proc_handler = &proc_dointvec, }, + { + .ctl_name = KERN_LOWPOWER_IDLE, + .procname = "lowpower_idle", + .data = &halt_counter, + .maxlen = sizeof (int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, { .ctl_name = 0 } };
Quoted 3 lines · Kenneth Chen
On ia64, we need runtime control to manage CPU power state in the idle loop.
Can you expand on this? Does this mean that the admin can select different idle-loop algorithms? If so, what alternative algorithms exist?
On x86 I'd like to be able to turn idle=poll on when performing oprofile run, so the numbers come out right. Will this let me do that?
Quoted 1 line
Logically it means a sysctl entry in
/proc/sys/kernel.
Yes, but the *meanings* of the different values of that sysctl need to be defined, and documented. If lowpower_idleB has a totally different meaning on different architectures then that's unfortunate but understandable. But we should at least enumerate the different values and try to get different architectures to honour `42' in the same way.
Quoted 1 line
+atomic_t
halt_counter;
Needs to be initialised - atomic_t's may have spinlocks inside them or anything else.
Quoted 1 line
+extern
atomic_thalt_counter;
Needs to be in a header, not in .c
Quoted 6 lines
/* this is needed for the
proc_dointvec_minmaxfor [fs_]overflow UID and GID */ static int maxolduid = 65535;kernel/sysctl.c +0
-0@@ -615,6 +616,14 @@ .mode = 0444, .proc_handler = &proc_dointvec, },
kernel/sysctl.c line 628
Quoted 10 lines
kernel/sysctl.c +8
-0+ { + .ctl_name = KERN_LOWPOWER_IDLE, + .procname = "lowpower_idle", + .data = &halt_counter, + .maxlen = sizeof (int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, { .ctl_name = 0 } };
You cannot treat an int* as an atomic_t*!
Why do we want to inc and dec a user-specified tunable anyway? I think I don't understand what you're trying to do with this patch.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Andrew Morton on Wednesday, March 17, 2004 5:05 PM
On ia64, we need runtime control to manage CPU power state in the idle loop.
Can you expand on this?
If architecture provides a facility for low power state, we would like to turn that on in the idle loop to conserve power. However, in some specific situation like for performance, it is desired to be off at least during that period of time. A runtime control would allow power state to be managed dynamically to accommodate both.
That's what we are trying to do: to have a sysctl to control whether CPU goes into low power state or not in the default_idle() loop. In the generic code, kernel provides a mechanism to set/clear a flag, and in each arch, we can then test the flag before entering into low power state.
Quoted 2 lines
Does this mean that the admin can select
different idle-loop algorithms? If so, what alternative algorithms exist?
This patch isn't that fancy, nice feature but maybe next step :-)
Quoted 7 lines
Quoted 1 line
Logically it means a sysctl entry in
/proc/sys/kernel.Yes, but the *meanings* of the different values of that sysctl need to be defined, and documented. If
lowpower_idleBhas a totally different meaning on different architectures then that's unfortunate but understandable. But we should at least enumerate the different values and try to get different architectures to honour `42' in the same way.
Writing to sysctl should be a bool, reading the value can be number of module currently disabled low power idle. I think the original intent is to use ref count for enabling/disabling. (granted, we copied the code from other arch).
Quoted 6 lines
Needs to be initialised - atomic_t's may have spinlocks inside them or anything else.
Needs to be in a header, not in .c
You cannot treat an int* as an atomic_t*!
My monkey work, must be not having enough coffee today :-P
- Ken
Quoted 9 lines · Kenneth Chen
Quoted 8 lines
Quoted 2 lines
Logically it means a sysctl entry in
/proc/sys/kernel.Yes, but the *meanings* of the different values of that sysctl need to be defined, and documented. If lowpower_idle=42 has a totally different meaning on different architectures then that's unfortunate but understandable. But we should at least enumerate the different values and try to get different architectures to honour `42' in the same way.
Quoted 4 lines
Writing to sysctl should be a bool, reading the value can be number of module currently disabled low power idle. I think the original intent is to use ref count for enabling/disabling. (granted, we copied the code from other arch).
OK, so why not give us:
#define IDLE_HALT 0
#define IDLE_POLL 1
#define IDLE_SUPER_LOW_POWER_HALT 2
and so forth (are there any others?).
Set some system-wide integer via a sysctl and let the particular architecture decide how best to implement the currently-selected idle mode?
Quoted 17 lines · Andrew Morton
Quoted 9 lines · Kenneth Chen
Quoted 8 lines
Quoted 2 lines
Logically it means a sysctl entry in
/proc/sys/kernel.Yes, but the *meanings* of the different values of that sysctl need to be defined, and documented. If lowpower_idle=42 has a totally different meaning on different architectures then that's unfortunate but understandable. But we should at least enumerate the different values and try to get different architectures to honour `42' in the same way.
Quoted 4 lines
Writing to sysctl should be a bool, reading the value can be number of module currently disabled low power idle. I think the original intent is to use ref count for enabling/disabling. (granted, we copied the code from other arch).
OK, so why not give us:
Quoted 8 lines
#define
IDLE_HALT0
#defineIDLE_POLL1
#defineIDLE_SUPER_LOW_POWER_HALT2and so forth (are there any others?).
Set some system-wide integer via a sysctl and let the particular architecture decide how best to implement the currently-selected idle mode?
I'm wondering whether the setting of these magic numbers can't be done using cpufreq infrastructure.
Quoted 12 lines · Zwane Mwaikambo
Quoted 10 lines · Andrew Morton
Quoted 9 lines · Kenneth Chen
Quoted 8 lines
Quoted 2 lines
Logically it means a sysctl entry in
/proc/sys/kernel.Yes, but the *meanings* of the different values of that sysctl need to be defined, and documented. If lowpower_idle=42 has a totally different meaning on different architectures then that's unfortunate but understandable. But we should at least enumerate the different values and try to get different architectures to honour `42' in the same way.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Writing to sysctl should be a bool, reading the value can be number of module currently disabled low power idle. I think the original intent is to use ref count for enabling/disabling. (granted, we copied the code from other arch).
I assume ia64 does idling using the ACPI processor.c driver? If so, couldn't writing to /proc/acpi/processor/./power be an option?
Quoted 6 lines
Quoted 6 lines
OK, so why not give us:
#define
IDLE_HALT0
#defineIDLE_POLL1
#defineIDLE_SUPER_LOW_POWER_HALT2
Quoted 7 lines
Quoted 4 lines
and so forth (are there any others?).
Set some system-wide integer via a sysctl and let the particular architecture decide how best to implement the currently-selected idle mode?
I'm wondering whether the setting of these magic numbers can't be done using cpufreq infrastructure.
I doubt it -- there's no ia64 cpufreq driver anyway, and cpufreq is about frequency scaling and (sometimes) throttling, but not "idling". And "idling" is a too different implementation anyways.
Dominik
* Andrew Morton <[email protected]>:
Quoted 7 lines
Quoted 3 lines · Kenneth Chen
On ia64, we need runtime control to manage CPU power state in the idle loop.
Can you expand on this? Does this mean that the admin can select different idle-loop algorithms? If so, what alternative algorithms exist?
At least on 760MPX chipset, when Athlon is pushed into powersaving mode (disconnected from PCI bus) great deal of graphical distortions are introduced into bttv -based card's picture.
I've dealt with this by rmmod:ing amd76x_pm -module (this action disables powersaving mode), but some sane API for disabling these disturbancies would be much better.
Signature · 1 line
Psi -- <http://www.iki.fi/pasi.savolainen>
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Dominik Brodowski wrote on Thu, March 18, 2004 1:05 AM
I assume ia64 does idling using the ACPI
processor.cdriver?
No, not really.
Quoted 2 lines
If so, couldn't writing to
/proc/acpi/processor/./powerbe an option?
Not all platform has ACPI support, so going through ACPI isn't generic enough.
Quoted 14 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Andrew Morton wrote on Wed, March 17, 2004 7:28 PM
"Kenneth Chen" <[email protected]> wrote:
Writing to sysctl should be a bool, reading the value can be number of module currently disabled low power idle. I think the original intent is to use ref count for enabling/disabling. (granted, we copied the code from other arch).
OK, so why not give us:
#define
IDLE_HALT0
#defineIDLE_POLL1
#defineIDLE_SUPER_LOW_POWER_HALT2
Quoted 5 lines
and so forth (are there any others?).
Set some system-wide integer via a sysctl and let the particular architecture decide how best to implement the currently-selected idle mode?
Sounds good, Thanks for the suggestion. I just coded it up:
include/linux/cpu.h +6 -0
@@ -52,6 +52,12 @@#endif /* CONFIG_SMP */ extern struct sysdev_class cpu_sysdev_class; +extern int idle_mode; + +#define IDLE_NOOP 0 +#define IDLE_HALT 1 +#define IDLE_POLL 2 +#define IDLE_ACPI 3#ifdef CONFIG_HOTPLUG_CPU /* Stop CPUs going up and down. */
include/linux/sysctl.h +1 -0
@@ -131,6 +131,7 @@ KERN_PRINTK_RATELIMIT_BURSTa,/* int: tune printk ratelimiting */ KERN_PTYb,/* dir: pty driver */ KERN_NGROUPS_MAXc,/* int: NGROUPS_MAX */ + KERN_IDLE_MODEd, /* int: arch specific cpu idle mode */ };
kernel/cpu.c +2 -0
@@ -64,3 +64,5 @@up (&cpucontrol);return ret; } + +int idle_mode =IDLE_HALT ;
kernel/sysctl.c +9 -0
@@ -39,6 +39,7 @@#include <linux/initrd.h> #include <linux/times.h> #include <linux/limits.h> +#include <linux/cpu.h> #include <asm/uaccess.h> #ifdef CONFIG_ROOT_NFS
@@ -615,6 +616,14 @@ .mode = 0444, .proc_handler = &proc_dointvec, }, + { + .ctl_name = KERN_IDLE_MODE, + .procname = "idle_mode", + .data = &idle_mode, + .maxlen = sizeof (int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, { .ctl_name = 0 } };
Quoted 15 lines · Kenneth Chen
Quoted 15 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Andrew Morton wrote on Wed, March 17, 2004 7:28 PM
"Kenneth Chen" <[email protected]> wrote:
Writing to sysctl should be a bool, reading the value can be number of module currently disabled low power idle. I think the original intent is to use ref count for enabling/disabling. (granted, we copied the code from other arch).
OK, so why not give us:
#define
IDLE_HALT0
#defineIDLE_POLL1
#defineIDLE_SUPER_LOW_POWER_HALT2
Quoted 9 lines
Quoted 5 lines
and so forth (are there any others?).
Set some system-wide integer via a sysctl and let the particular architecture decide how best to implement the currently-selected idle mode?
Sounds good, Thanks for the suggestion. I just coded it up:
Looks fine, thanks. I'll queue that up pending some code which actually uses it. And the obligatory update to Documentation/kernel-parameters.txt ;)
Quoted 5 lines · Zwane Mwaikambo
Quoted 2 lines
Set some system-wide integer via a sysctl and let the particular architecture decide how best to implement the currently-selected idle mode?
I'm wondering whether the setting of these magic numbers can't be done using cpufreq infrastructure.
I'd vote for using Patrick Mochel's PM subsystem and use a standard set of identifiers that are mapped to a platform-specific idle behavior, in much the same way as platform suspend modes are handled today. For example, strings echoed to /sys/power/idle could be an interface. If folks are amenable to this I'd be happy to supply a (generic) patch for it.
Signature · 2 lines
Todd Poynor MontaVista Software
Quoted 6 lines · Todd Poynor
Quoted 3 lines · Zwane Mwaikambo
Quoted 2 lines
Set some system-wide integer via a sysctl and let the particular architecture decide how best to implement the currently-selected idle mode?
Quoted 8 lines
Quoted 2 lines
I'm wondering whether the setting of these magic numbers can't be done using cpufreq infrastructure.
I'd vote for using Patrick Mochel's PM subsystem and use a standard set of identifiers that are mapped to a platform-specific idle behavior, in much the same way as platform suspend modes are handled today. For example, strings echoed to
/sys/power/idlecould be an interface. If folks are amenable to this I'd be happy to supply a (generic) patch for it.
That sounds suitable, thanks.
Quoted 5 lines · Todd Poynor
Quoted 3 lines · Zwane Mwaikambo
Quoted 2 lines
Set some system-wide integer via a sysctl and let the particular architecture decide how best to implement the currently-selected idle mode?
Quoted 8 lines
Quoted 2 lines
I'm wondering whether the setting of these magic numbers can't be done using cpufreq infrastructure.
I'd vote for using Patrick Mochel's PM subsystem and use a standard set of identifiers that are mapped to a platform-specific idle behavior, in much the same way as platform suspend modes are handled today. For example, strings echoed to
/sys/power/idlecould be an interface. If folks are amenable to this I'd be happy to supply a (generic) patch for it.
Ta, sounds good, give us a look.
Hi!
Quoted 4 lines
On ia64, we need runtime control to manage CPU power state in the idle loop. Logically it means a sysctl entry in
/proc/sys/kernel. Even though this sysctl entry doesn't exist today, lots of arch already has some sort of API to dynamically enable/disable low power idle state.
If you make it "max Cx state to allow", it will be usefull for ACPI people, too...
Pavel
Signature · 1 line
64 bytes from 195.113.31.123: icmp_seq( ttlQ timeD8769.1 ms
Hi!
Quoted 7 lines
Sounds good, Thanks for the suggestion. I just coded it up:
diff -Nur
linux-2.6.4/include/linux/cpu.hlinux-2.6.4.halt/include/linux/cpu.h
include/linux/cpu.h line 61
Quoted 10 lines
include/linux/cpu.h +6
-0@@ -52,6 +52,12 @@#endif /* CONFIG_SMP */ extern struct sysdev_class cpu_sysdev_class; +extern int idle_mode; + +#define IDLE_NOOP 0 +#define IDLE_HALT 1 +#define IDLE_POLL 2 +#define IDLE_ACPI 3
How is idle_noop different from idle_poll?
idle_halt is equivalent to idle_acpi_C1. But acpi supports also C2 (deeper sleep), and C3 (sleep without coherent caches) and newer machines support even more. You might want to talk to Len Brown.
[And yes, limiting to C2 (for example) *is* usefull; some machines (nforce2 iirc) have bugs, and die if you do C3 at wrong time].
Pavel
Signature · 2 lines
When do you have a heart between your knees? [Johanka's followup: and *two* hearts?]
Quoted 10 lines
include/linux/cpu.h line 60
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Pavel Machek wrote on Wed, March 24, 2004 1:54 AM
include/linux/cpu.h +6
-0+extern int idle_mode; + +#define IDLE_NOOP 0 +#define IDLE_HALT 1 +#define IDLE_POLL 2 +#define IDLE_ACPI 3How is
idle_noopdifferent fromidle_poll?
I was thinking idle_noop truly does nothing at all, versus idle_poll which optimize cross cpu wakeup.
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Todd Poynor wrote on Thu, March 18, 2004 3:00 PM
I'd vote for using Patrick Mochel's PM subsystem and use a standard set of identifiers that are mapped to a platform-specific idle behavior, in much the same way as platform suspend modes are handled today. For example, strings echoed to
/sys/power/idlecould be an interface. If folks are amenable to this I'd be happy to supply a (generic) patch for it.
Just wondering what is the state of development for this new PM scheme? I don't check LKML that frequently, sorry if I miss any posting on LKML.
- Ken