tld wrote:For anyone interested, I've implementing the .bashrc version of this under the current stable gentoo-sources-2.6.35-r12, and in my case the improvement for a lot of things I do is very noticeable. I do a lot of things from urxvt prompts. I also haven't used a login manager in a long time. I log in to a console and use startx. One thing I'm unclear on is whether or not that means that everything I run out of X that isn't via another console uses the cgroup of that original login(??).
You can check that easily looking at the list of PIDs in the
tasks file of your session's cgroup (that is, /cgroup/user/[your_console_session_id]/tasks in your case) and comparing it with the list of running processes (be it an output of "ps" or "top" or any X-frontend). Generally, what gets into the cgroup of the session where you've run startx depends on how you run your .xinitrc and whether, inside your .xinitrc, you run your window manager using the
exec call.
For instance, I use my own little script that, upon login, checks whether I am under a real tty and if so, presents me with a dialog where I can choose either to start one of my DEs, or just the console. The important part is, this script gets sourced from /etc/profile
if I am both non-root and under a real tty - and
then, since my .bashrc wouldn't get sourced while stating X in this way, do the cgroup-magic, as in any normal .bashrc.
tld wrote:One thing I found very confusing is all the instructions that specify mounting cgroup to /sys/fs/cgroup/cpu which (at least in the kernel I'm running) doesn't exist no matter what kernel options I use. I've seen other instructions specifying /dev/cgroup etc.
That is because you use a <2.6.36 kernel. the /sys/fs/cgroup mountpoint was introduced later. And the "cpu" sub-directory needs to be created manually (this is optional anyway).
tld wrote:
This is in my .bashrc:
Code: Select all
if [ "$PS1" ] ; then
mkdir -m 0700 /cgroup/user/$$
echo 1 > /cgroup/user/$$/notify_on_release
echo $$ > /cgroup/user/$$/tasks
fi
That might produce a problem in some shells, as did in one of my environments - where you have file overwriting protection enabled for non-root users. In such case using
>> instead of
> solves the problem.
tld wrote:
Code: Select all
mount -t cgroup cgroup /cgroup -o cpu,release_agent=/usr/local/bin/rmcgroup
mkdir -m 0777 /cgroup/user
Oh, that's nice they have a "release_agent" mount option! I didn't know that and used to echo /usr/local/bin/rmcgroup > /sys/fs/cgroup/cpu/release_agent
