Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Apparently, there is a comparable alternative to the 200-line kernel patch that involves no kernel upgrade.

It is presented here and discussed here.

However, I am not sure if webupd8's solution (under the section "Use it in Ubuntu") on Ubuntu actually works or not. In particular, one commenter on ./ is saying he's getting an error message. Could anyone post the "correct" method that actually works?

Suggested solution:

Based on the comments I've read so far, the following seems to work.

(1) In /etc/rc.local, add the following lines to above exit 0:

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

(2) Create a file named /usr/local/sbin/cgroup_clean with the following content:

#!/bin/sh
rmdir /dev/cgroup/cpu/$1

(3) In your ~/.bashrc, add:

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

(4) (To make sure the execution bit is on) execute

sudo chmod +x /usr/local/sbin/cgroup_clean /etc/rc.local

(5) Reboot.

share|improve this question
    
Can you split this off into an answer and accept it? I started reading the accepted answer and got totally confused. –  Jorge Castro Jan 9 '11 at 0:57

3 Answers 3

up vote 2 down vote accepted

The answer above should indeed fix the terminal error message. Gödel, I'm not sure that I understood your point. I'll try to explain the change:

Since the default value of notify_on_release at creation of other cgroups is the current value of their parents notify_on_release setting, setting the value of /dev/cgroup/cpu/user/notify_on_release to 1 would make sure that every child cgroup had notify_on_release enabled and thus the release_agent would be ran. Unfortunately, when the last child cgroup of "user" was removed (by the release_agent), that folder would also be removed, leading to the error messages reported. A simple workaround is to enable notify_on_release for each cgroup individually at creation, keeping the parents setting disabled.

Hope that was easy to follow!

Edit: I'd have posted this as a comment to the actual answer, though it's seems I don't have enough reputation to do so (yet).

share|improve this answer
    
Thanks for the clarification. On my system (Ubuntu Lucid with Kernel 2.6.32-25), the error message upon opening a gnome-terminal doesn't even appear, which led me to wonder if the proposed fix was necessary at all. –  Gödel Nov 19 '10 at 5:17

I applied this patch using the automated script on Web UPD8 to an Asus eee 1000H. I noticed a considerable performance increase in Google chrome with Flash applications running. Videos were smoother and less frame dropping.Gnome UI also is snappier and windows redraw faster. Very cool. link text

share|improve this answer
    
This script worked like a charm :) –  Patryk Jul 12 '12 at 8:24

Updated instructions from Ricardo Ferreira

Start by editing your rc.local file, running sudo -H gedit /etc/rc.local and add the following lines above exit 0:

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

Save and exit gedit. Now, make it executable:

sudo chmod +x /etc/rc.local

After doing this, edit the .bashrc file found in your home directory (gedit ~/.bashrc) and, at the end of this file, add:

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

One last thing. To make sure that cgroups are deleted whenever the last task leaves, run:

sudo -H gedit /usr/local/sbin/cgroup_clean

And copy-paste this:

#!/bin/sh
rmdir /dev/cgroup/cpu/$*

Once again, save the file, exit gedit and make it executable:

sudo chmod +x /usr/local/sbin/cgroup_clean

Done! Restart your computer to apply the changes.

share|improve this answer
    
But this only takes out the echo "1" > /dev/cgroup/cpu/user/$$/notify_on_release line and puts it into .bashrc. Isn't this necessary only when you get an error when executing bash .bashrc? Depending on the kernel version you are using, you may or may not get the error. –  Gödel Nov 19 '10 at 1:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.