Home Home Server Undervolting your CPU
 
Undervolting your CPU
Saturday, 13 June 2009 14:21

3298 Getting an energy-efficient CPU is the first step when you´re trying to build a low-power file server, NAS or whatever you might call it. A good choice for that task is an Intel Atom. Unfortunately there is no real choice about a good mainboard for the Atom. You can either get one of those old Intel chipsets where the chipset wastes more energy than the Atom or you get one of those nifty Boards with nVidia ION platform. They´re impressive, fast and... cost a lot of money. So you better have a look at AMD.

They offer some quiet impressive CPUs like the Athlon x2 EE models or (for this task) even better the Sempron CPUs. I got me one of those Sempron LE-1250. Although they are single core CPUs they offer enough power to drive our little server. Be sure to get one with G2 stepping so you can undervolt the CPU even more.

The Semprons come with 45W TDP. When running with Cool'n'Quiet at the lowest possible frequency of 1GHz they consume very little power, but I wanted it lower. To achieve that you have to undervolt the Sempron. There are 2 ways undervolting: do it via the BIOS setup of your mainboard or by software. Using the BIOS has 2 big disadvantages: you always have to restart the box to change a setting and you need a board that allows you to set different voltages for the different Cool'n'Quiet stages. The better choice is undervolting by software. And when you´re running a linux-based box the most comfortable tool I found is cpupowerd by Markus Strobl. The downloadable package contains a README-file and the sources, so this means we need to compile the program at our box. Don´t be scared, it´s pretty easy and straight forward.

There are a few prerequisites you need to prepare. Enable Cool'n'Quiet inyour BIOS and don´t set a fixed cpu voltage (if your BIOS should offer that option). You need to load the kernel modules powernow-k8, msr and cpufreq-userspace. You can either load them by hand with modprobe msr [ENTER], modprobe cpufreq-userspace [ENTER] and modprobe powernow-k8[ENTER] or you load them at startup. To do so edit the file /etc/modules and enter the modules name one per line. I hope you know how to edit a file at the shell, if not type nano /etc/modules [ENTER], edit the file, save with CTRL-O [ENTER] and exit with CTRL-X [ENTER]. Check if the modules are loaded with lsmod | grep 'msr\|powernow\|cpufreq' [ENTER]. You should be prompted with the exact names of the modules. After loading the modules check if Cool'n'Quiet works. Type cpufreq-info [ENTER] to check it. cpufreq-info should list all available frequencies of your cpu and the current one. With the Sempron LE-1250 you should see 1000 MHz, 1800 MHz, 2000 MHz and 2200MHz. You will also see the current frequency, so when your box isn´t doing anything right now it should output 1000MHz. Frequencies will vary with other processors. If you haven´t done yet install a C/C++ compiler. Check with apt-cache search gcc [ENTER] for the GNU C Compiler. At the time of writing this article gcc-4.2 was the most recent one. Install it by apt-get install gcc-4.2. That´s all, now we start with cpupowerd.

Download the package from here: DIRECT LINK. Transfer the downloaded archive to your linux box. When done, at the shell change to the directory where you have stored the archive and decompress it via tar -xzf cpupowerd-x.x.x.tar.gz [ENTER]. Instead of the x use the real filename of course. Change to directory with the source files with cd cpupowerd-x.x.x/src [ENTER]. Start compiling with make [ENTER]. With root priviledges install the program with su make install [ENTER]. You´ll be prompted for the root password.

Now we really start undervolting. For everything that follows you need root priviledges. Generally speaking we will generate a standard config file, set the frequency to all previous listed ones and adjust the voltage for each of them. Your box might freeze when you set the voltage too low. You would have to reboot the box than and use the last voltage that worked. We start by generating the standard config file with cpupowerd -a cpupowerd.conf [ENTER]. Now we´re setting the first frequency. Type cpupowerd -F "0|1000" [ENTER]. Option -F means we set the frequency. 0 means the first core of your processor. If you have a dual- or quad-core CPU you have to execute the command for every core manually by increasing 0 (0, 1, 2, ... you get the idea). 1000 means the frequency in MHz. Only use frequencies your CPU supports! after you executed the command check with cpupowerd -s [ENTER] if the frequency is set correctly. You will see the frequency and the current voltage. Now we will lower the voltage by typing cpupowerd -V "0|1.1000" [ENTER]. -V means we change the voltage, 0 again refers to the core and 1.1000 is the voltage we select. Be carefull and go step by step. If your standard voltage ist 1.2000 V the first step you should try is 1.1750 V. Decrease the voltage only by 0.0250 V per step! Once you executed the command check with cpupowerd -s [ENTER] if the voltage has been lowered. If it has and your box didn´t freeze go down another 0.0250 V. Don´t forget you other cores (if you have any). Go down until your box freezes. Restart it and set voltage to the last value that worked. To be sure add one step above that (+0.0250 V). Write down the voltage and off we go to the next available frequency. Again type cpupowerd -F "0|1800" [ENTER] and check the current frequency and voltage with cpupowerd -s [ENTER]. Now start lowering the voltage again. You have to do this for all available frequencies and cores your processor offers. Once you have set and noted all possible voltages you should test your system if it still is stable. You could use something like mprime. Let it run a few hours. If your box freezes somewhere during the testing increase the voltage for the appropriate frequency one or two steps and repeat testing. Once you finally have a stable box we take care of applying those changes to the box at startup.

Open the cpupowerd.conf you previously created with nano cpupowerd.conf [ENTER] and edit the voltage values. The first column of this file stands for the available frequencies, the second one for the appropriate voltages. Save the file and copy it to /etc with cp cpupowerd.conf /etc/cpupowerd.conf [ENTER]. Edit the script cpupowerd with nano cpupowerd.sh [ENTER], find the line CPUPOWERD_STARTPARAMETERS and verify that it points to the correct location for the cpupowerd.conf. Save the file and copy it to /etc/init.d with cp cpupowerd.sh /etc/init.d/cpupowerd [ENTER]. We now need to make sure that the script starts at the appropriate runlevel and stops when shutting down. So the (in my opinion) best runlevel for starting the daemon is runlevel 2. To start the daemon there create a symlink to the script at the /etc/rc2.d with ln -s /etc/init.d/cpupowerd /etc/rc2.d/S20cpupowerd [ENTER]. As for the name of the symlink: S means it´s a startscript and 20 means the order of when the script is started. A script with 10 is started before a script with 20 which is started before a script with 30... you get the idea. We also need to stop the daemon when shutting down, so we create a symlink as a stopscript at every runlevel. Type ln -s /etc/cpupowerd /etc/rc0.d/K00cpupowerd [ENTER]. Repeat that for every runlevel directory rc1.d up to rc6.d. K stands for kill (stoping the daemon), 00 again means it´s stopped as the first process in it´s runlevel. This was the last step to undervolt the processor. Remember, if you need to readjust the voltages later first stop the daemon with /etc/init.d/cpupowerd stop, edit the conf file and afterwards start it with /etc/init.d/cpupowerd start.

Currently I´m running the Sempron LE-1250 at the following voltages:

1000 MHz  at  0.7250 V
1800 MHz  at  0.8000 V
2000 MHz  at  0.8750 V
2200 MHz  at  0.9250 V

This way the box runs with around 21-22W power consumption.
For more info on undervolting with cpupowerd check the README file included in the downloadable package.

Comments (0)
Write comment
Your Contact Details:
Comment:
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
Security
Please input the anti-spam code that you can read in the image.