Regarding the Howto, a few important additions that I felt compelled to add, to save others from having to go through so much trouble like I did (such as recompiling the kernel two or three times in a row):
1. Do not compile the kernel as root, this is a common mistake and will only give you grief later
If you extracted and compiled the kernel in /usr/src/linux-source-x.x.x as root, once your newly created debs are installed (linux-image and linux-headers), you'll notice you have a symlink in /lib/modules/x.x.x/build that points to /usr/src/linux-source-x.x.x instead of /usr/src/linux-headers-x.x.x as it should, which means that if your /usr/src/linux-source ever gets touched, you will be very screwed, cuz you'll have older modules built against a linux-source that has been tampered with, and newly compiled modules will either fail to load (after being compiled) or fail to compile at all...
So do it the proper "debian" way
1a. Add your user account to the "src" group
Code: Select all
$ sudo usermod -a -G src yourusername
That gives yourusername account priviliges to write files in /usr/src directory (the recommended way from debian manual, and what linux kernel developers recommend)
1b. Logout and login again to be recognized in the src group you just been added to
1c. As user,
not as root, extract the sources, and make menuconfig (or xconfig if you so choose)
Code: Select all
$ cd /usr/src
$ tar xzf linux-source-x.x.x
$ cd linux-source-x.x.x
$ make menuconfig
See note #2 further below for notes on what needs to be built as modules!!! <-
IMPORTANT
1d. Once you're done configuring your kernel, make the deb package with fakeroot make-kpkg (as your username,
NOT ROOT) as follows:
Code: Select all
$ fakeroot make-kpkg --initrd --append-to-version=-phc1 --revision=1.0 kernel-image kernel-headers
After that's done, you'll see two files created in the top directory (/usr/src/) like so:
Code: Select all
jas@lappy:/usr/src/linux-source-2.6.30$ cd ..
jas@lappy:/usr/src$ ls *.deb
linux-headers-2.6.30-phc1_1.0_i386.deb linux-image-2.6.30-phc1_1.0_i386.deb
1e. Out of precaution, I just DELETE OR RENAME /usr/src/linux-source-x.x.x just to MAKE SURE when I install/reinstall the debs, /lib/modules/x.x.x/build WILL NOT point to /usr/src/linux-source-x.x.x instead of /usr/src/linux-headers-x.x.x
example:
Code: Select all
jas@lappy:/usr/src/linux-source-2.6.30$ cd ..
jas@lappy:/usr/src$ mv linux-source-2.6.30 kernel-src-2.6.30
jas@lappy:/usr/src$ dpkg -i linux-*-2.6.30-phc1_1.0_i386.deb
That will install both linux-headers-2.6.30-phc1_1.0_i386.deb linux-image-2.6.30-phc1_1.0_i386.deb
And your /lib/modules/2.6.30-phc1/build symlink will automatically point CORRECTLY to /usr/src/linux-headers-2.6.30-phc1 and will save you a lot of headaches with compiling third-party modules later (such as nvidia, alsa-driver, madwifi-ng, etc..)
Code: Select all
jas@lappy:/usr/src$ ls -l /lib/modules/2.6.30-phc1/build
lrwxrwxrwx 1 root root 34 2009-08-02 21:59 /lib/modules/2.6.30-phc1/build -> /usr/src/linux-headers-2.6.30-phc1
2. In `make menuconfig` (or xconfig if you so chose) MAKE SURE you choose "CPU frequency translation statistics" as a MODULE... by default ubuntu generic kernel, it's compiled IN the kernel (=y) rather than a module... Also enable its sub-option "CPU frequency translation statistics details", so in menuconfig it should look like this:
<M> CPU frequency translation statistics
[ * ] CPU frequency translation statistics details
and in your /boot/config-`uname -r` it should look like this:
Code: Select all
CONFIG_CPU_FREQ_STAT=m
CONFIG_CPU_FREQ_STAT_DETAILS=y
This is really necessay because when you install phc-k8 or phc-intel (via `make dkms_install`), it adds the following lines in your /etc/modules.conf file - in my case this is for phc-k8:
Code: Select all
install powernow-k8 /sbin/modprobe phc-k8 || { /sbin/modprobe --ignore-install powernow-k8; }
remove powernow-k8 /sbin/modprobe -r cpufreq_stats && { /sbin/modprobe --ignore-remove -r powernow-k8 ; }
remove phc-k8 /sbin/modprobe -r cpufreq_stats && { /sbin/modprobe --ignore-remove -r phc-k8 ; }
Which means that to remove phc-k8, you need to remove cpufreq-status module, which won't happen if you have it compiled in the kernel..
I also compiled everything else as modules, just in case (after 2 or 3 kernel compiles, stripped down config of kernel-2.6.30 from Ubuntu Kernel PPA, on Jaunty 9.04):
$ grep -i freq /boot/config-2.6.30-phc1
# CPU Frequency scaling
CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_TABLE=m
# CONFIG_CPU_FREQ_DEBUG is not set
CONFIG_CPU_FREQ_STAT=m
CONFIG_CPU_FREQ_STAT_DETAILS=y
CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=m
CONFIG_CPU_FREQ_GOV_USERSPACE=m
CONFIG_CPU_FREQ_GOV_ONDEMAND=m
CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
# CPUFreq processor drivers
CONFIG_X86_ACPI_CPUFREQ=m
# CONFIG_X86_CPUFREQ_NFORCE2 is not set
I didn't really need to add "CONFIG_X86_ACPI_CPUFREQ" built because it's for intel processors, and as I only have an AMD K8, but I added it to the list just to give a more complete example that should work for both AMD & Intel users, but you only need one of them.
For AMD users, you add "powernow-k8" to /etc/modules
For Intel users, you add "acpi-cpufreq" to /etc/modules
That way, the appropriate module for your CPU will load on boot automatically, and if you have installed phc-k8 or phc-intel (`make dkms_install`), the module "install" option that it added automatically for you in /etc/modules.conf should load your phc-k8 or phc-intel module automatically instead, and if you uninstalled phc-k8 or phc-intel (for whatever reason), your normal powernow-k8 or acpi-cpufreq will still start automatically on boot, so you wont forget it...
If you built cpufreqstats as a module as recommended, and built all frequency governers as modules like me (I also compiled msr as a module, and also k8temp), you'll additionally need to add the following to your
/etc/modules file so that they are loaded automatically for you at boot:
# Chip drivers
k8temp
# CPU Frequency Management
msr
cpufreq_userspace
cpufreq_ondemand
cpufreq_conservative
cpufreq_powersave
cpufreq_stats
powernow-k8
Of course if there are certain cpufreq governors that you never need to use, you can just ommit them from the list and save a few kilobytes of memory...
Hope this helps anyone
Cheers