Chapter 2. Using Control Groups
2.1. The cgconfig Service
The cgconfig service installed with the libcgroup package provides a convenient way to create hierarchies, attach subsystems to hierarchies, and manage cgroups within those hierarchies. We recommend that you use cgconfig to manage hierarchies and cgroups on your system.
The cgconfig service is not started by default on Red Hat Enterprise Linux 6. When you start the service with chkconfig
, it reads the control group configuration file — /etc/cgconfig.conf
. Control groups are therefore recreated from session to session and become persistent. Depending on the contents of the configuration file, cgconfig can create hierarchies, mount necessary file systems, create control groups, and set subsystem parameters for each group.
The default cgconfig.conf
file installed with the libcgroup package creates and mounts an individual hierarchy for each subsystem, and attaches the subsystems to these hierarchies.
If you stop the cgconfig service (with service cgconfig stop
), it unmounts all the hierarchies that it mounted.
2.1.1. The cgconfig.conf File
The cgconfig.conf
file contains two major types of entry — mount and group. Mount entries create and mount hierarchies as virtual filesystems, and attach subsystems to those hierarchies. For example:
mount {
cpuset = /cgroup/cpuset;
}
creates a hierarchy for the cpuset
subsystem, the equivalent of the shell commands:
mkdir /cgroup/cpuset
mount -t cgroup -o cpuset cpuset /cgroup/cpuset
Group entries create control groups and set subsystem parameters. For example:
group daemons/sql {
perm {
task {
uid = root;
gid = sqladmin;
} admin {
uid = root;
gid = root;
}
} cpuset {
cpuset.cpus = 0-3;
}
}
creates a control group for sql daemons, with permissions for users in the sqladmin
group to add tasks to the control group and the root
user to modify subsystem parameters. When combined with the example of the mount entry above, the equivalent shell commands are:
mkdir -p /cgroup/cpu/daemons/sql
chown root:root /cgroup/cpu/daemons/sql/*
chown root:sqladmin /cgroup/cpu/daemons/sql/tasks
echo 0-3 > /cgroup/cpu/daemons/sql/cpuset.cpus
When you install cgroups, a sample config file is written to /etc/cgconfig.conf
. The #
symbols at the start of each line comment that line out and make it invisible to the cgconfig service.