Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In Linux you can shut down CPU cores (or physical CPU's) with echo 0 > /sys/devices/system/cpu/cpu1/online Assuming that the hardware fully turn off the CPU and cuts power to it would it not be better to disabled the cores entirely instead of relying on the various sleep states of a processor?

To illustrate the principle I was thinking something along these lines (pseudocode) for a system with four CPU's:

if(loadavg > 3.00) echo 1 > /sys/devices/system/cpu/cpu3/online
if(loadavg < 3.00) echo 0 > /sys/devices/system/cpu/cpu3/online

if(loadavg > 2.00) echo 1 > /sys/devices/system/cpu/cpu2/online
if(loadavg < 2.00) echo 0 > /sys/devices/system/cpu/cpu2/online

if(loadavg > 1.00) echo 1 > /sys/devices/system/cpu/cpu1/online
if(loadavg < 1.00) echo 0 > /sys/devices/system/cpu/cpu1/online
share|improve this question
5  
+1. I had no idea you could do that. –  Camilo Martin Dec 12 '11 at 1:31

1 Answer 1

Setting the online status of the CPU core just tells the process scheduler to not use that core for any processes. On a hardware level, the core is simply sitting idle (doing NOPs), but still powered. While this will save power, it won't save nearly as much power as putting the computer to sleep. Why?

Well, your motherboard, CPU, and GPU are all still running! When you put the computer to sleep, all of these components are literally unpowered, and just enough power to keep your RAM alive is used (on the order of a couple watts).

Again, while I agree it will save power, even shutting off half of your CPU cores may halve the power consumption of the processor (although in reality, you may only save 30-40% since those cores still need to sit idle), but this is far from the only component in the system using power. Even if you save 50W by doing this, you're entire computer is still drawing far more power than mere watts in sleep mode.


Final thoughts: While I agree this is a great idea in practice, this is also why many CPU manufacturers include dynamic frequency scaling (Intel's "Speed Step"), with support for Linux. You may yield better overall performance, as well as power efficiency, by setting these frequencies more appropriately for your needs. This can be done in both hardware (BIOS settings), as well as software (the Linux kernel allows you to modify some CPU parameters, see the link I posted above or this website for details).

This works, because the following is the generic equation for power consumption of a CMOS circuit:

P = CV2f, where C = capacitance (assume fixed), V = voltage, and f = frequency.

Thus, dividing the frequency by 2 will half the original power consumption. Dividing the voltage by 2 will reduce power consumption to 1/4 the original.

share|improve this answer
    
At least on x86/amd64 compatible processors I would assume that if possible a HLT instruction would be more easy on the CPU than a NOP. I was also referring to the various sleep states (or correctly processor states C0-C3 (ACPI)). Also I was thinking more about systems that run always where the entire system can't be put to sleep. In that case I am curious to if the the hardware will actually cut the power to the cpu and if that is implemented at all in some configurations. Thanks for your answer but I'll let the question remain open a bit longer. –  Waxhead Dec 16 '11 at 22:24
    
@Waxhead once you cut power to the CPU, the entire computer is logically "off" (and can only be turned back on via external interrupt), even if other hardware is still powered. Also, you might be right about using HLT instead of NOP, but that ties back into the use of interrupts (which is how to bring a processor out of the halted state). Instead of cut power, most processors dynamically change clock speed and voltage (added equation to my answer). –  Breakthrough Apr 14 '12 at 12:32
    
I did some more research on this. It turns out that Linux actually supports hotplug of a CPU. In that case IF the BIOS/Motherboard supports it you can actually shut down CPU(s) and replace them e.g. rip the CPU out of it's socket while the system is running and replace it. Ref: cyberciti.biz/faq/debian-rhel-centos-redhat-suse-hotplug-cpu if I am not mistaking this would cut power to a cpu IF the BIOS/Motherboard support it. –  Waxhead May 20 '12 at 23:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.