cgroups (aka control groups) is a Linux kernel feature to limit, police and account the resource usage of certain processes (actually process groups). For example, cgroups are used by the Linux Containers virtualization solution for resource limiting. Compared to other approaches like the 'nice' command or /etc/security/limits.conf, cgroups are infinitely more flexible.
Unfortunately this feature is often underappreciated due to lack of easy "how-to" style documentation. This is an attempt of fixing the problem. :)
Note: I'm only learning to use cgroups as I type this, so don't take everything I say here as pure gold.
First, install the utilities for managing cgroups; you need the libcgroup package from AUR. makepkg and install it as usual.
Next, you need to define where to mount the cgroup controller virtual file systems. Let's start with the 'cpu' and 'memory' controllers:
Template:File Then run the following to create these directories and mount the controller file systems:
Now when you list the directory, you should see some files in it:
ls -l /mnt/cgroups/memory
One of the powers of croups is that you can create "ad-hoc" groups on the fly. In fact, you can even grant the privileges to create custom groups to regular users. Run this as root (replace $USER with your user name):
sudo cgcreate -a $USER -g memory,cpu:me
That's it! Now all the tunables in the group "me" are writable by your user:
ls -l /mnt/cgroups/memory/me