Skip to content
July 10, 2012 / jpeg729

Kernel compiling to add phc support – lowlatency kernel

DISCLAIMER: I am *not* an expert. I just read docs and try to figure out something that works, and I really don’t know how or why it works.

Get the sources and everything else needed, I’m doing this for the lowlatency kernel that comes with UbuntuStudio 12.04.

apt-get source linux-image-3.2.0-23-lowlatency
apt-get build-dep linux-image-3.2.0-23-lowlatency
apt-get install libncurses5-dev

Do that in the directory you want the kernel source to land up in.

Move into the source directory

cd linux-lowlatency-3.2.0

Copy over the current lowlatency config into a new config.

cp /boot/config-3.2.0-23-lowlatency debian.lowlatency/config/amd64/config.flavour.lowlatency-phc

In the following the debian/rules commands ought to be run using fakeroot, e.g. fakeroot debian/rules updateconfigs but I am lazy and I am doing everything as root anyway.

debian/rules updateconfigs

It got stuck twice saying there was a permissions problem on some script. I did the following each time and re-ran it.

chmod +x the-script-path-and-name

Now we edit the config.

debian/rules editconfigs

It will ask you whether you want to modify various configuration files. Given that I have an intel Core2Duo P8400 I said I’d modify the amd64/lowlatency-phc configuration. The options that need to be changed are the following. These things need to be compiled as modules rather than included in the kernel. That way the phc module can replace them.

Power management and ACPI options --->
  CPU Frequency scaling --->
    x86 CPU frequency scaling drivers --->
      <M> ACPI Processor P-States driver
      <M> AMD Opteron/Athlon64 PowerNow!
      <M> Intel Enhanced SpeedStep (deprecated)

Given that we have created a new config there are a few files to create/edit so that it will work.

First edit debian.lowlatency/etc/getabis adding lowlatency-phc to the line that reads getall amd64 lowlatency. Given that we will use skipabis later on, this might not be necessary.

Next edit debian.lowlatency/rules.d/ adding lowlatency-phc to the line that reads

flavours = lowlatency

Create a description file for this flavour. You can modify it if you like.

cp debian.lowlatency/control.d/vars.lowlatency debian.master/control.d/vars.lowlatency-phc

Had to edit debian/control aussi.
Found these lines and modified the first to read linux-image-3.2.0-23-lowlatency-phc

Package: linux-image-3.2.0-23-lowlatency
Architecture: i386 amd64
Section: universe/admin

Likewise here to read linux-headers-3.2.0-23-lowlatency-phc

Package: linux-headers-3.2.0-23-lowlatency
Architecture: i386 amd64
Section: universe/devel

Cheating really ‘coz now the plain lowlatency flavour won’t build. I ought to have copied the entire sections.

Finally let’s compile it.

debian/rules binary-lowlatency-phc

Last but not least, install it. Don’t use sudo if you are already root.

cd ..
sudo dpkg -i linux-headers-3.2.0-23-lowlatency-phc_3.2.0-23.36~precise1_amd64.deb
sudo dpkg -i linux-image-3.2.0-23-lowlatency-phc_3.2.0-23.36~precise1_amd64.deb

The phc-intel module was automatically built and installed by the dkms system. Nice.

Rebooted and it works!!!

Now I have added the following lines to /etc/rc.local to make the undervolting changes stick. You will need to experiment as described here to find the values right for your CPU.

# Undervolt the cpu cores.
echo '22 19 18 17' > /sys/devices/system/cpu/cpu0/cpufreq/phc_vids
echo '22 19 18 17' > /sys/devices/system/cpu/cpu1/cpufreq/phc_vids

Adapted from


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: