rockorequin
May 21st, 2010, 02:32 AM
This thread describes how to build a 2.6.34 kernel with load-balancing to cut down the number of load balancing wakeups. Running powertop on my amd64 PC shows that this kernel cuts down the number of wakeups by around 30%. See https://bugs.launchpad.net/ubuntu/+source/linux/+bug/524281/ for more details.
1. Open a gnome-terminal and get root privileges:
sudo -s
2. Install required packages for building the kernel:
apt-get install build-essential bin86 kernel-package libqt3-headers libqt3-mt-dev wget libncurses5 libncurses5-dev
3. Download the 2.6.34 kernel source file:
cd /usr/src
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.34.tar.bz2
4a. Download the diff file for the patch from http://lkml.org/lkml/diff/2010/5/21/435/1 and save as (eg) patch-load-balancing.diff. Move it to /usr/src once you have downloaded it.
5. Untar the source file:
cd /usr/src
tar xjf linux-2.6.34.tar.bz2
6. Link /usr/src/linux to the resulting folder:
cd /usr/src
# the folder linux may exist as a symlink from previously; if so, remove it
if [ -e linux ]; then rm linux; fi
ln -s linux-2.6.34 linux
7. Copy a configuration file to /usr/src/linux/.config (see attached for my 2.6.34 amd64 one or you can copy one of the ones in /boot/config* - but if you use eg the 2.6.32 file, you'll need to answer lots of questions when you start building because there are many new options in 2.6.34).
You can also get a valid configuration file by downloading deb files from http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.34-lucid/ for your configuration (amd64 or x86), installing them, and copying the /boot/config-2.6.34-02630* file it creates to /usr/src/linux/.config. (This is how I created the attached one.)
8. Optional: Edit configuration file
cd /usr/src/linux
make menuconfig
and edit it to desired settings, eg 32 bit, turn debug on or off.
NOTE: for Lucid, you must have these settings in .config or it won't boot:
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
9a. Apply the load-balancing patch:
cd /usr/src/linux
patch -p1 < ../patch-load-balance.diff
Two hunks of the patch fail if you're patching against 2.6.34, so you have to manually edit the affected files. It patches against 2.6.35-rc1 just fine (although note that one of the hunks in the ureadahead trace patch below fails in 2.6.35-rc1.)
9b. (Optional) I also recommend installing the trace patch (attached) so ureadahead can configure itself to boot faster. Assuming it is in /usr/src:
cd /usr/src/linux
patch -p1 < ../0001-trace-add-trace-events-for-open-exec-an.patch
See http://swiss.ubuntuforums.org/showthread.php?t=1434502 for more details.
10. Build kernel
cd /usr/src/linux
make-kpkg clean
fakeroot make-kpkg --initrd --append-to-version=-generic kernel_image kernel_headers
11. Install kernel and headers
cd /usr/src
dpkg -i *linux-2.6.34-*deb
12. Special last checks before rebooting:
a) I've noticed that make-kpkg/dpkg -i does not always create the /boot/initrd* file in Lucid. This will stop the kernel from booting. Try:
ls /boot/config-2.6.34-generic
If it shows nothing, create one with:
update-initramfs -c -k linux-2.6.34-generic
update-grub
If it didn't create it, you are probably missing a symlink in the /etc/kernel/postinst.d folder. To make dpkg create the initramfs file next time, do:
sudo ln -s /usr/share/doc/kernel-package/examples/etc/kernel/postinst.d/initramfs /etc/kernel/postinst.d/initramfs
b) If you're running nvidia proprietary drivers, run:
dkms status
and check that nvidia is listed as installed for the 2.6.34 kernel. If not, you'll need to install them separately.
13. Reboot and good luck... if the new kernel fails to boot, you should still be able to boot into the stock 2.6.32 kernel to try and figure out what went wrong, uninstall the 2.6.34 kernel, etc.
There are lots of web references on building the kernel, eg refer to http://blog.avirtualhome.com/2010/05/05/how-to-compile-a-ubuntu-lucid-kernel.
1. Open a gnome-terminal and get root privileges:
sudo -s
2. Install required packages for building the kernel:
apt-get install build-essential bin86 kernel-package libqt3-headers libqt3-mt-dev wget libncurses5 libncurses5-dev
3. Download the 2.6.34 kernel source file:
cd /usr/src
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.34.tar.bz2
4a. Download the diff file for the patch from http://lkml.org/lkml/diff/2010/5/21/435/1 and save as (eg) patch-load-balancing.diff. Move it to /usr/src once you have downloaded it.
5. Untar the source file:
cd /usr/src
tar xjf linux-2.6.34.tar.bz2
6. Link /usr/src/linux to the resulting folder:
cd /usr/src
# the folder linux may exist as a symlink from previously; if so, remove it
if [ -e linux ]; then rm linux; fi
ln -s linux-2.6.34 linux
7. Copy a configuration file to /usr/src/linux/.config (see attached for my 2.6.34 amd64 one or you can copy one of the ones in /boot/config* - but if you use eg the 2.6.32 file, you'll need to answer lots of questions when you start building because there are many new options in 2.6.34).
You can also get a valid configuration file by downloading deb files from http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.34-lucid/ for your configuration (amd64 or x86), installing them, and copying the /boot/config-2.6.34-02630* file it creates to /usr/src/linux/.config. (This is how I created the attached one.)
8. Optional: Edit configuration file
cd /usr/src/linux
make menuconfig
and edit it to desired settings, eg 32 bit, turn debug on or off.
NOTE: for Lucid, you must have these settings in .config or it won't boot:
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
9a. Apply the load-balancing patch:
cd /usr/src/linux
patch -p1 < ../patch-load-balance.diff
Two hunks of the patch fail if you're patching against 2.6.34, so you have to manually edit the affected files. It patches against 2.6.35-rc1 just fine (although note that one of the hunks in the ureadahead trace patch below fails in 2.6.35-rc1.)
9b. (Optional) I also recommend installing the trace patch (attached) so ureadahead can configure itself to boot faster. Assuming it is in /usr/src:
cd /usr/src/linux
patch -p1 < ../0001-trace-add-trace-events-for-open-exec-an.patch
See http://swiss.ubuntuforums.org/showthread.php?t=1434502 for more details.
10. Build kernel
cd /usr/src/linux
make-kpkg clean
fakeroot make-kpkg --initrd --append-to-version=-generic kernel_image kernel_headers
11. Install kernel and headers
cd /usr/src
dpkg -i *linux-2.6.34-*deb
12. Special last checks before rebooting:
a) I've noticed that make-kpkg/dpkg -i does not always create the /boot/initrd* file in Lucid. This will stop the kernel from booting. Try:
ls /boot/config-2.6.34-generic
If it shows nothing, create one with:
update-initramfs -c -k linux-2.6.34-generic
update-grub
If it didn't create it, you are probably missing a symlink in the /etc/kernel/postinst.d folder. To make dpkg create the initramfs file next time, do:
sudo ln -s /usr/share/doc/kernel-package/examples/etc/kernel/postinst.d/initramfs /etc/kernel/postinst.d/initramfs
b) If you're running nvidia proprietary drivers, run:
dkms status
and check that nvidia is listed as installed for the 2.6.34 kernel. If not, you'll need to install them separately.
13. Reboot and good luck... if the new kernel fails to boot, you should still be able to boot into the stock 2.6.32 kernel to try and figure out what went wrong, uninstall the 2.6.34 kernel, etc.
There are lots of web references on building the kernel, eg refer to http://blog.avirtualhome.com/2010/05/05/how-to-compile-a-ubuntu-lucid-kernel.