Am 25.11.2010 12:21, schrieb Adam Carter:
> 
>     Would you share?
> 
> +1
> 
> I only have an empty /sys/fs/cgroup with the following config on 2.6.36,
> so please share the kernel config as well.
> 

I guess you have to mount your cgroup there, first. The original link
describes, how.

I don't have a /sys/fs/cgroup at all. So I don't think my kernel config
will help you.

My solution isn't that great, anyway. I thought about writing an init
script but I haven't done that yet and don't think I'll do it soon.

Anyway, if you want my solution, here it is, although it's mostly
copy'n'paste from the original link:

1. Create '/usr/local/sbin/cgroup_start' with the following content:

#!/bin/bash
mkdir -p /dev/cgroup/cpu
mount -t cgroup cgroup /dev/cgroup/cpu -o cpu
mkdir -m 0777 /dev/cgroup/cpu/user
/bin/echo '/usr/local/sbin/cgroup_clean' > /dev/cgroup/cpu/release_agent

(Execution right for root, only)

## Please note ##
Since I had no /sys/fs/cgroup directory to start with and I didn't want
to fiddle with /proc or /sys, I create a new directory /dev/cgroup to
work with. If you have a better directory, you have to adjust all
following code snippets to work on that directory.

Please also note that I use /bin/echo instead of the shell built-in
echo. There is supposed to be a difference in write error detection
between the both which is important to detect problems when you
configure cgroups.
#################

2. Create '/usr/local/sbin/cgroup_clean'

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

(Execution right for root, only)

3.a If you use OpenRC / Baselayout-2, edit /etc/conf.d/local

local_start() {
        /usr/local/sbin/cgroup_start

        # We should always return 0
        return 0
}

3.b If you use Baselayout-1, edit /etc/conf.d/local.start and add

/usr/local/sbin/cgroup_start

## Please note ##
It would be great to know what to do in order to stop using cgroups
again. Then we could create a proper init script for this. Does anyone know?
Can you just unmount it? Do you need to delete its content, first?
#################

4. Create a file /etc/bash/local/cgrouprc

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

5. Edit your own ~/.bashrc file and /root/.bashrc and add the following
line:

source /etc/bash/local/cgrouprc

## Please note ##
The last two steps can be varied as you wish. The creation of a
/etc/bash/local directory is my own policy. It is useful for collecting
common bashrc code that all users can include as they wish.
#################

Then call `/etc/init.d/local restart` and type `source ~/.bashrc` in all
your open shells and you are done.

Hope this helps,
Florian Philipp

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to