Este contenido no está disponible en el idioma seleccionado.
2.2. Creating a Hierarchy and Attaching Subsystems
Warning
The following instructions, which cover creating a new hierarchy and attaching subsystems to it, assume that cgroups are not already configured on your system. In this case, these instructions will not affect the operation of the system. Changing the tunable parameters in a cgroup with tasks, however, can immediately affect those tasks. This guide alerts you the first time it illustrates changing a tunable cgroup parameter that can affect one or more tasks.
On a system on which cgroups are already configured (either manually, or by the
cgconfig
service) these commands fail unless you first unmount existing hierarchies, which affects the operation of the system. Do not experiment with these instructions on production systems.
To create a hierarchy and attach subsystems to it, edit the
mount
section of the /etc/cgconfig.conf
file as root. Entries in the mount
section have the following format:
subsystem = /cgroup/hierarchy;
When
cgconfig
next starts, it will create the hierarchy and attach the subsystems to it.
The following example creates a hierarchy called
cpu_and_mem
and attaches the cpu
, cpuset
, cpuacct
, and memory
subsystems to it.
mount { cpuset = /cgroup/cpu_and_mem; cpu = /cgroup/cpu_and_mem; cpuacct = /cgroup/cpu_and_mem; memory = /cgroup/cpu_and_mem; }
Alternative method
You can also use shell commands and utilities to create hierarchies and attach subsystems to them.
Create a mount point for the hierarchy as root. Include the name of the cgroup in the mount point:
~]# mkdir /cgroup/name
For example:
~]# mkdir /cgroup/cpu_and_mem
Next, use the
mount
command to mount the hierarchy and simultaneously attach one or more subsystems. For example:
~]# mount -t cgroup -o subsystems name /cgroup/name
Where subsystems is a comma‑separated list of subsystems and name is the name of the hierarchy. Brief descriptions of all available subsystems are listed in Available Subsystems in Red Hat Enterprise Linux, and Chapter 3, Subsystems and Tunable Parameters provides a detailed reference.
Example 2.3. Using the mount command to attach subsystems
In this example, a directory named
/cgroup/cpu_and_mem
already exists and will serve as the mount point for the hierarchy that you create. Attach the cpu
, cpuset
, and memory
subsystems to a hierarchy named cpu_and_mem
, and mount
the cpu_and_mem
hierarchy on /cgroup/cpu_and_mem
:
~]# mount -t cgroup -o cpu,cpuset,memory cpu_and_mem /cgroup/cpu_and_mem
You can list all available subsystems along with their current mount points (i.e. where the hierarchy they are attached to is mounted) with the
lssubsys
[3] command:
~]# lssubsys -am
cpu,cpuset,memory /cgroup/cpu_and_mem
net_cls
ns
cpuacct
devices
freezer
blkio
This output indicates that:
- the
cpu
,cpuset
, andmemory
subsystems are attached to a hierarchy mounted on/cgroup/cpu_and_mem
, and - the
net_cls
,ns
,cpuacct
,devices
,freezer
, andblkio
subsystems are as yet unattached to any hierarchy, as illustrated by the lack of a corresponding mount point.
[3]
The
lssubsys
command is one of the utilities provided by the libcgroup package. You have to install libcgroup to use it: refer to Chapter 2, Using Control Groups if you are unable to run lssubsys
.