3
4
I am looking for a mechanism to dynamically disable cores in Linux in order to minimize power consumption.
Unfortunately, disabling cores using the following simple approach actually increases power, based on readings from a Watts Up? Pro measuring total system power:
echo 0 > /sys/devices/system/cpu/cpu7/online
My experience seems to be confirmed by others (although this bug has been marked "CLOSED PATCH_ALREADY_AVAILABLE"): https://bugzilla.kernel.org/show_bug.cgi?id=5471
Since the machine is unloaded, I want all but one of the cores (or perhaps two "cores", since the CPU is hyper-threaded) to be in the deepest possible sleep state. This does not seem to be happening on its own, based on the output of acpitool:
Processor ID : 7
Bus mastering control : no
Power management : yes
Throttling control : no
Limit interface : no
Active C-state : C0
C-states (incl. C0) : 3
Usage of state C1 : 899 (99.3 %)
Usage of state C2 : 6 (0.7 %)
BTW, one point of confusion for me is that acpitool and /proc/acpi seem to disagree about the available C-states, or perhaps they use different naming schemes.
$ cat /proc/acpi/processor/CPU7/power
active state: C0
max_cstate: C8
maximum allowed latency: 2000000000 usec
states:
C1: type[C1] promotion[--] demotion[--] latency[001] usage[00000000] duration[00000000000000000000]
C2: type[C2] promotion[--] demotion[--] latency[017] usage[00001248] duration[00000000001877531423]
C3: type[C3] promotion[--] demotion[--] latency[017] usage[00000006] duration[00000000000012580727]
This seems to indicate that there are 4 C-states (C0-C3), but acpitool only reports 3 C-states.
Really this boils down to two questions:
- Is there a (safe) way to force individual cores into a specific sleep state (C-state), and force them to remain there until I explicitly wake them up?
- Alternatively, how can I improve the ability of the OS to automatically put cores into deeper sleep states more consistently?
Note that the latency of waking up from deeper sleep states is not a concern. FWIW, I am running Ubuntu 10.04.3 (kernel 2.6.32-38) on an Intel i7 920.
Have you tried powertop? What suggestions did it make? On my systems, it reduced idle power by about 15W. I don't know whether offlining individual cores is something it does directly, or leaves it up to the scheduler, but the power savings are tangible. It has significantly reduced the number of wake-ups per minute substantially, so disabling cores is much more likely now. – Supercilious – 2012-03-02T03:37:48.670
Thanks for the suggestion. I had heard of powertop but never tried it out; I didn't realize it provided suggestions! I'll try those out when I get a chance and see what impact they have. For the record, I'm still interested in finding a way to guarantee that certain cores will enter (and remain in) a specific sleep state. – Michael Boyer – 2012-03-05T22:41:41.110