Friday, November 19, 2010

Alternative to the 200 lines kernel hack

You may be aware of the recent debate around a 200 lines kernel hack which makes Linux 10% faster. Andrew from WebUPD8 just posted this alternative. It really does seem to work. I've reposted the relevant part for Ubuntu, but I seriously suggest you take a look at the original posting first.

To use Lennart's solution in Ubuntu (not tested - thanks to Lsh for this), you have to replace "/sys/fs" with "/dev". So you would have to add the following commands in your /etc/rc.local (open it with: sudo gedit /etc/rc.local) file, above the "exit 0" line:

mkdir -p /dev/cgroup/cpu
mount -t cgroup cgroup /dev/cgroup/cpu -o cpu
mkdir -m 0777 /dev/cgroup/cpu/user
echo "1" > /dev/cgroup/cpu/user/notify_on_release
echo "/usr/local/sbin/cgroup_clean" > /dev/cgroup/cpu/release_agent

and make it executable:
sudo chmod +x /etc/rc.local

And then add the following to your ~/.bashrc file (to open it: gedit ~/.bashrc):
if [ "$PS1" ] ; then
mkdir -m 0700 /dev/cgroup/cpu/user/$$
echo $$ > /dev/cgroup/cpu/user/$$/tasks
fi

Run the following command:
sudo gedit /usr/local/sbin/cgroup_clean

And paste this:
#!/bin/sh
rmdir /dev/cgroup/cpu/$1

then save the file and make it executable:
sudo chmod +x /usr/local/sbin/cgroup_clean

And finally, restart the computer.
Update: The above instructions have been updated automatically remove empty cgroups (thank to Ricardo Ferreira - see his comment below).

Update 2: 64bit kernels (Warning: use these at your own risk!!!) for Ubuntu 10.10:
If you want to go even further and install a patched Kernel, you can download a "200 lines" patched Kernel from HERE (thanks to accumulator @ Phoronix forums).

Also, WebUpd8 reader Scott Franke shared a patch he patched with bfs with which he says he gets better performance then with the "200 lines patch". Download from HEREand HERE.

Both of the above 2 Kernels are for 64bit Ubuntu 10.10 only! Use them at your own risk!

Read the discussion @ http://lkml.org/lkml/2010/11/16/392 | via Habrahabr.ru(thanks to Lsh)

No comments:

Post a Comment