10

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
0

1 Answer 1

6

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.

5
  • 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
    Commented Dec 16, 2011 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). Commented Apr 14, 2012 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
    Commented May 20, 2012 at 23:27
  • @Breakthrough Thanks for your nice post. Can you provide some reference docs on details of how can we put cpu in low power state (with out rebooting system) and can get it back when required
    – iDebD_gh
    Commented Sep 1, 2016 at 14:01
  • @Breakthrough "the core is simply sitting idle (doing NOPs), " When we do offline on a particular cpu core, it disappers from "/proc/interrupts". How you can say the Core is processing NOP operation?
    – iDebD_gh
    Commented Sep 6, 2016 at 8:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .