Page 1 of 1

mini-guide: undervolting ubuntu feisty/gutsy with linux-phc

Posted: Tue Oct 30, 2007 11:14 pm
by tarvoke
(updated to reflect development has moved to http://phc.athousandnights.de)
(updated with how to check centrino-speedstep vs acpi-cpufreq)
(updated with note for 64bit os)
(updated about initscripts)
(updated some stupid typos and errors)
(updated slightly more intelligent way to get correct linux source)

this works wonderfully on my x31, with kubuntu 7.10 aka gutsy; and x61t with kubuntu 7.10 64bit. these steps should work fine on any pentium-M, core duo or c2d thinkpad; the only difference will be tuning exact voltages per your particular cpu.

(as for dynamic frequency, ubuntu seems to have automagically installed all the necessary modules and sysfs bits; I added kpowersave applet to my kde panel/tray and set its policy to 'dynamic' and that was it)

CAREFUL! while the latest phc is designed to prevent ever EVER over-volting your cpu at each discrete frequency step, you still should make sure you know what the heck you are doing when setting voltages manually (or in the initscript config)

VORSICHT! if your dog runs away or you burn your toast or your truck won't start, this guide denies any liability whatsoever.

info and many of the steps come from the following, I've just combined and streamlined a bit. for more in-depth explanations, check 'em out:
https://www.dedigentoo.org/trac/linux-p ... ubuntu_001
http://phc.athousandnights.de/files
https://wiki.ubuntu.com/UndervoltingHowto

let's go!

Code: Select all

## install essential compiler tools, svn source control tool
sudo apt-get install build-essential subversion 

## see which module it is you need (so choose accordingly in some steps further below)
lsmod | grep speedstep_centrino
lsmod | grep acpi_cpufreq


## check out latest phc development code; I found this necessary to get it working properly on my machine 
mkdir ~/build
cd ~/build
## check out latest phc code
svn co http://phcpatches.googlecode.com/svn/trunk/ phcpatches

###***
## note: if you already checked out the code and want to see if there are any updates to check out, instead of "svn co blah/blah/blah" just:
cd ~/build/phcpatches
## and then:
svn update
###***

## change to root, enter kernel source directory and extract linux source code 
su - 
cd /usr/src 
apt-get source linux-image-$(uname -r)

#(may vary based on kernel version installed) 
cd linux-source-2.6.22-2.6.22

## copy the module patch from your regular user home directory i.e. /home/YOU
#(may vary based on phc version and kernel version installed) 
## for speedstep-centrino
cp /home/YOU/build/phcpatches/speedstep/patches/linux-phc-0.3.1-kernel-vanilla-2.6.22.patch . 
### OR ###
## for acpi-cpufreq
cp /home/YOU/build/phcpatches/cpufreq/patches/linux-phc-kernel-vanilla-2.6.22.patch . 

#(again, may vary based on phc version and kernel version installed) 
## for speedstep-centrino
patch -p1 < linux-phc-0.3.1-kernel-vanilla-2.6.22.patch 
### OR ###
## for acpi-cpufreq
patch -p1 < linux-phc-kernel-vanilla-2.6.22.patch 


## build a new kernel module using current kernel settings 
## you will see some questions when the old .config is parsed. according to the phc wiki:
### There will be some questions (all SHOULD have something to do with frequency/voltage), answer them with YES. ###
cp /boot/config-$(uname -r) .config
make oldconfig 
make prepare 
make scripts 
make M=./arch/i386/kernel/cpu/cpufreq 

## backup the existing kernel module and copy the new one over it 
## for speedstep-centrino
cp /lib/modules/$(uname -r)/kernel/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.ko ~/ 
cp arch/i386/kernel/cpu/cpufreq/speedstep-centrino.ko /lib/modules/$(uname -r)/kernel/arch/i386/kernel/cpu/cpufreq 
### OR ###
## for acpi-cpufreq
cp /lib/modules/$(uname -r)/kernel/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.ko ~/ 
cp arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.ko /lib/modules/$(uname -r)/kernel/arch/i386/kernel/cpu/cpufreq 
### !!!OR FOR 64bit systems!!! ###
cp /lib/modules/$(uname -r)/kernel/arch/x86_64/kernel/cpufreq/acpi-cpufreq.ko ~/ 
cp arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.ko /lib/modules/$(uname -r)/kernel/arch/x86_64/kernel/cpufreq/
## (I know this LOOKS WEIRD AND DODGY, but if you check the Makefile for arch/x86_64/kernel/cpufreq you will see that it simply references the code from arch/i386. all I can say is that it works for me on 64bit kubuntu 7.10...)

exit 


## unload and reload 
## for speedstep-centrino
sudo rmmod speedstep-centrino
sudo depmod -a
sudo modprobe speedstep-centrino
### OR###
## for acpi-cpufreq (it may not let you rmmod it, in which case simply reboot your machine)
sudo rmmod acpi-cpufreq
sudo depmod -a
sudo modprobe acpi-cpufreq



## see if it worked! 
## this is a list of your machine's default voltages (per frequency step)
cat /sys/devices/system/cpu/cpu0/cpufreq/phc_default_vids
## and this is a list of your current voltages (right now it should be exactly the same as the default ones)
cat /sys/devices/system/cpu/cpu0/cpufreq/phc_vids

## set up initscript for undervolting (if you get it working right, you'll need to add it to your multiuser runlevels -- runlevel 2 at the very least)
sudo mkdir /etc/phc-config 
sudo cp ~/build/phcpatches/tools/init-scripts/ubuntu/etc/phc-config/undervolt /etc/phc-config 
sudo cp ~/build/phcpatches/tools/init-scripts/ubuntu/etc/init.d/undervolt /etc/init.d/

then set up the initscript config...

the default VIDs on my x31 1.4 are:
49 46 38 30 16
aka
1484mV 1436mV 1308mV 1180mV 956mV

pretty brutal huh?

so far I've been doing ok with
32 22 16 10 6
aka
1212mV 1052mV 956mV 860mV 796mV

better, eh? and although the low end is about as low as I can get at max load when at 600MHz, I really have not spent any time testing how much lower I can bring the top end. it can vary from each person's machine, so don't take my VIDs for granted even if you also have a 1.4GHz p-M.

Code: Select all

sudo nano /etc/phc-config/undervolt
to carefully! change to suit your particular cpu.

e.g. in my case:

Code: Select all

SWITCH_BACK="yes" 

DEFAULT_VTABLE="49 46 38 30 16" 

CUSTOM_VTABLE="32 22 16 10 6"

IS_CONFIGURED="yes"
finding the best set of voltages for you may take some work... (not to mention more of that caution)

Posted: Thu Nov 01, 2007 11:10 am
by jamesqf
Interesting, but I'm curious as to why do the frequency steps? The people who do Powertop (www.lesswatts.org) seem to think it's more efficient to use an on-demand governor: wake the CPU up, do whatever work needs doing as fast as possible (at full CPU speed), then go back to sleep.

Posted: Thu Nov 01, 2007 1:44 pm
by schmolch
If you have any Intel Core CPU don't waste your time trying this.
They are hardware locked and cannot be undervolted (below the standard voltage of the lowest standard frequency).

Posted: Sat Nov 03, 2007 10:48 am
by aaa
jamesqf wrote:Interesting, but I'm curious as to why do the frequency steps? The people who do Powertop (www.lesswatts.org) seem to think it's more efficient to use an on-demand governor: wake the CPU up, do whatever work needs doing as fast as possible (at full CPU speed), then go back to sleep.
Ondemand is default, it jumps to highest then slows down step by step (thus it needs those steps to work). Many things that keep the cpu busy also interrupt it alot, keeping it from going to sleep at all. So it would be better to play that video at 1ghz instead of 1.5ghz, because video playing seems to completely prevent sleep.

In my case, I find the opposite works best for me for some reason, I use the "conservative" governor to stay at the lowest speed longer. I'm not seeing the sleep times go up with ondemand, just the time spent at higher speeds (and thus higher voltage).

Posted: Sun Nov 04, 2007 12:05 am
by jamesqf
Maybe I used the wrong name for the governor, but that's what I get from the lesswatts site. I suppose it could depend on what you're doing. I mostly edit & compile code, so most of the time my system just needs to wake up on each key press. Playing videos is something I never do - on purpose, anyway.

Posted: Sun Nov 25, 2007 1:16 pm
by r1ckchard
Sorry for bringing back this topic, but I've been trying to figure out a way to undervolt my T42 and this guide has been pretty helpful. First off, let me say I just installed Ubuntu 7.10 yesterday and have been using Windows prior, so this is my first experience with Linux. Now on to the problem. For some reason, I can't unload and reload speedstep-centrino. I get this error:

Code: Select all

ERROR: Module speedstep_centrino does not exist in /proc/modules
I followed everything in the guide up to that point, so I'm not sure what's wrong. If anyone could push me in the right direction, I'd appreciate it much. Thanks.

Posted: Sun Nov 25, 2007 6:11 pm
by aaa
r1ckchard wrote:Sorry for bringing back this topic, but I've been trying to figure out a way to undervolt my T42 and this guide has been pretty helpful. First off, let me say I just installed Ubuntu 7.10 yesterday and have been using Windows prior, so this is my first experience with Linux. Now on to the problem. For some reason, I can't unload and reload speedstep-centrino. I get this error:

Code: Select all

ERROR: Module speedstep_centrino does not exist in /proc/modules
I followed everything in the guide up to that point, so I'm not sure what's wrong. If anyone could push me in the right direction, I'd appreciate it much. Thanks.
There are two drivers, speedstep-centrino and acpi-cpufreq. acpi-cpufreq is the default most of the time, since it works with most processors other than just the Pentium M. So I'm guessing you are running this instead of speedstep-centrino, Try running "lsmod | grep cpufreq", and check if acpi-cpufreq is in the list.

Posted: Sun Nov 25, 2007 7:43 pm
by tarvoke
r1ckchard -- are you sure the speedstep-centrino.ko file successfully copied to the right place? if you do something like:

Code: Select all

ls -l /lib/modules/$(uname -r)/kernel/arch/i386/kernel/cpu/cpufreq
you should see it listed (among some other things)

Code: Select all

-rw-r--r-- 1 root root 116499 2007-10-21 23:56 speedstep-centrino.ko
and aaa is right, sometimes it is acpi-cpufreq instead of speedstep-centrino. on my x61t it is acpi-cpufreq.
If you have any Intel Core CPU don't waste your time trying this.
They are hardware locked and cannot be undervolted (below the standard voltage of the lowest standard frequency).
this is true. but at higher frequencies you can still benefit from the lowered voltage. just not at the lowest frequency. works ok on my x61t.

Re: mini-guide: undervolting ubuntu feisty/gutsy with linux-phc

Posted: Fri Nov 27, 2009 12:36 pm
by p78
If anybody is interested there is a gentoo overlay for phc and phctool : http://bugs.gentoo.org/show_bug.cgi?id=283472
The phctool has a nice user interface ...