--- layout: post status: publish published: true title: ! 'Userspace responsiveness .bashrc alternative (Ubuntu 10.10: Working)' wordpress_id: 437 wordpress_url: http://www.martineve.com/?p=437 date: !binary |- MjAxMC0xMS0xOSAxOTo0OTowMyArMDEwMA== date_gmt: !binary |- MjAxMC0xMS0xOSAxOTo0OTowMyArMDEwMA== categories: - Technology - Linux tags: - Technology - Ubuntu comments: - id: 3982 author: Alex Filonov author_email: muddlin@gmail.com author_url: '' date: !binary |- MjAxMC0xMi0wOCAwMjozOTo1NiArMDEwMA== date_gmt: !binary |- MjAxMC0xMi0wOCAwMjozOTo1NiArMDEwMA== content: ! "Maybe working on 10.10. But on 8.04 I'm getting:\r\n\r\n\r\nalex@gazelle:~$ mkdir -p -m 0700 /dev/cgroup/cpu/user/$$ \r\nmkdir: cannot create directory `/dev/cgroup/cpu/user/6806': Invalid argument" - id: 6172 author: foobar author_email: totolepabo@yahoo.fr author_url: http://yahoo.fr date: !binary |- MjAxMS0wMi0wOCAyMjoyNToxNSArMDEwMA== date_gmt: !binary |- MjAxMS0wMi0wOCAyMjoyNToxNSArMDEwMA== content: ! "Please, can we stop this ? This \"incredible tuning\" is nothing but a pile of shit. It will ONLY work if you start ALL your processes from a terminal, or anything having a PS1 prompt.\r\n\r\nfoo@bar:~$ for PID in `cat /dev/cgroup/cpu/user/*/tasks`;do cut -f1 -d' ' /proc/$PID/cmdline;done\r\n\r\nbash\r\nbash\r\nscreen-Sfoo\r\nSCREEN-Sfoo\r\n/bin/bash\r\nrtorrent\r\nbash\r\nssh\r\nssh\r\n\r\nWOOOO i'm SO HAPPY my shells are more responsive now !!\r\n\r\nPlease learn a little bit people." - id: 6173 author: Martin Paul Eve author_email: martin@martineve.com author_url: '' date: !binary |- MjAxMS0wMi0wOSAwOTozODowNCArMDEwMA== date_gmt: !binary |- MjAxMS0wMi0wOSAwOTozODowNCArMDEwMA== content: ! "The only reason I approved this comment was so that your rudeness and unhelpful manner can be made visible. How on earth do you think that adopting such a condescending, sarcastic tone is likely to help anyone?\r\n\r\nIn response to your \"argument\" (not quite sure why I'm bothering) I never claimed otherwise. As is quite clearly discussed in the Slashdot comment thread, this patch mostly benefits those who run large compile jobs in the background. As I fall into that group (mostly compiling AOSP), I thought I would share the userspace solution to a patch that was accepted for kernel merge. Just because you have nothing better to do on the command line than run rtorrent doesn't mean the situation is the same for all of us." - id: 6174 author: foobar author_email: totolepabo@yahoo.fr author_url: http://yahoo.fr date: !binary |- MjAxMS0wMi0wOSAyMTo0NDo1NSArMDEwMA== date_gmt: !binary |- MjAxMS0wMi0wOSAyMTo0NDo1NSArMDEwMA== content: ! "I am really grateful you did your highness :)\r\n\r\nThe only reason i'm being so rude on this comment is that there's a BUNCH of blogs fapping to this while they don't have a clue of what it really does.\r\n\r\nNow, you _are_ right, this will effectively boost up shell jobs (or anything having its parent given a PS1), but unfortunately, not everyone catch this, and you can read pretty much everywhere \"WOW THIS IS INCREDIBLE, FIREFOX IS NOW SO MUCH RESPONSIVE ON UBUNTU !!1!\". That's called a \"placebo effect\".\r\n\r\nNevertheless, thank you for your reply (and no, i'm not being sarcastic here), it feels good to read some common sense.\r\n\r\nKeep up the good work !" - id: 6175 author: Martin Paul Eve author_email: martin@martineve.com author_url: '' date: !binary |- MjAxMS0wMi0xMCAwODoyNjo0OSArMDEwMA== date_gmt: !binary |- MjAxMS0wMi0xMCAwODoyNjo0OSArMDEwMA== content: Thanks for this reply; I'm sorry if my tone was also rude in the reply. I agree, there is a certain amount of misinformation circulating as to where this will benefit users -- many have also pointed out, though, that this mostly benefits... Linus and his usage model! ---

Recent discussion on the lkm has lead to Linus giving the go-ahead to a large kernel patch that massively increases responsiveness when multi-tasking on Linux desktop. A slashdot article today also points out that the same result can be achieved by modifications userspace and that this is, indeed, how the patch was tested.

The original instructions can be found at webupd8, but, for Ubuntu systems, they are incomplete.

Here's the correct information.

/etc/rc.local should contain:

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

and should be executable (sudo chmod +x /etc/rc.local).

Your ~/.bashrc should contain:

if [ "$PS1" ] ; then
mkdir -p -m 0700 /dev/cgroup/cpu/user/$$ > /dev/null 2>&1
echo $$ > /dev/cgroup/cpu/user/$$/tasks
echo "1" > /dev/cgroup/cpu/user/$$/notify_on_release
fi

directly at the top.

Finally (and this is where the original instructions were incomplete), /usr/local/sbin/cgroup_clean should contain:

#!/bin/sh
if [ "$1" != "/user" ]; then
rmdir /dev/cgroup/cpu/$1
fi

as suggested by an anonymous comment on the original. Finally, ensure the cgroup cleanup script is executable: sudo chmod +x /usr/local/sbin/cgroup_clean

Reboot your system and you too can have an ultra-responsive desktop!