aboutsummaryrefslogtreecommitdiffstats
path: root/man7/cgroups.7
diff options
context:
space:
mode:
Diffstat (limited to 'man7/cgroups.7')
-rw-r--r--man7/cgroups.7106
1 files changed, 53 insertions, 53 deletions
diff --git a/man7/cgroups.7 b/man7/cgroups.7
index c2dbcec6b9..0ad417d097 100644
--- a/man7/cgroups.7
+++ b/man7/cgroups.7
@@ -42,7 +42,7 @@ A
.I cgroup
is a collection of processes that are bound to a set of
limits or parameters defined via the cgroup filesystem.
-
+.PP
A
.I subsystem
is a kernel component that modifies the behavior of
@@ -54,7 +54,7 @@ and freezing and resuming execution of the processes in a cgroup.
Subsystems are sometimes also known as
.IR "resource controllers"
(or simply, controllers).
-
+.PP
The cgroups for a controller are arranged in a
.IR hierarchy .
This hierarchy is defined by creating, removing, and
@@ -77,7 +77,7 @@ and management of the cgroup hierarchies became rather complex.
(A longer description of these problems can be found in
the kernel source file
.IR Documentation/cgroup\-v2.txt .)
-
+.PP
Because of the problems with the initial cgroups implementation
(cgroups version 1),
starting in Linux 3.10, work began on a new,
@@ -87,7 +87,7 @@ Initially marked experimental, and hidden behind the
mount option, the new version (cgroups version 2)
was eventually made official with the release of Linux 4.5.
Differences between the two versions are described in the text below.
-
+.PP
Although cgroups v2 is intended as a replacement for cgroups v1,
the older system continues to exist
(and for compatibility reasons is unlikely to be removed).
@@ -109,7 +109,7 @@ processes on the system.
It is also possible comount multiple (or even all) cgroups v1 controllers
against the same cgroup filesystem, meaning that the comounted controllers
manage the same hierarchical organization of processes.
-
+.PP
For each mounted hierarchy,
the directory tree mirrors the control group hierarchy.
Each control group is represented by a directory, with each of its child
@@ -125,7 +125,7 @@ which is a child of
Under each cgroup directory is a set of files which can be read or
written to, reflecting resource limits and a few general cgroup
properties.
-
+.PP
In addition, in cgroups v1,
cgroups can be mounted with no bound controller, in which case
they serve only to track processes.
@@ -160,7 +160,7 @@ The use of cgroups requires a kernel built with the
option.
In addition, each of the v1 controllers has an associated
configuration option that must be set in order to employ that controller.
-
+.PP
In order to use a v1 controller,
it must be mounted against a cgroup filesystem.
The usual place for such mounts is under a
@@ -170,26 +170,26 @@ filesystem mounted at
Thus, one might mount the
.I cpu
controller as follows:
-
+.PP
.nf
.in +4n
mount \-t cgroup \-o cpu none /sys/fs/cgroup/cpu
.in
.fi
-
+.PP
It is possible to comount multiple controllers against the same hierarchy.
For example, here the
.IR cpu
and
.IR cpuacct
controllers are comounted against a single hierarchy:
-
+.PP
.nf
.in +4n
mount \-t cgroup \-o cpu,cpuacct none /sys/fs/cgroup/cpu,cpuacct
.in
.fi
-
+.PP
Comounting controllers has the effect that a process is in the same cgroup for
all of the comounted controllers.
Separately mounting controllers allows a process to
@@ -198,19 +198,19 @@ be in cgroup
for one controller while being in
.I /foo2/foo3
for another.
-
+.PP
It is possible to comount all v1 controllers against the same hierarchy:
-
+.PP
.nf
.in +4n
mount \-t cgroup \-o all cgroup /sys/fs/cgroup
.in
.fi
-
+.PP
(One can achieve the same result by omitting
.IR "\-o all" ,
since it is the default if no controllers are explicitly specified.)
-
+.PP
It is not possible to mount the same controller
against multiple cgroup hierarchies.
For example, it is not possible to mount both the
@@ -224,7 +224,7 @@ It is possible to create multiple mount points with exactly
the same set of comounted controllers.
However, in this case all that results is multiple mount points
providing a view of the same hierarchy.
-
+.PP
Note that on many systems, the v1 controllers are automatically mounted under
.IR /sys/fs/cgroup ;
in particular,
@@ -244,7 +244,7 @@ when a system is busy.
This does not limit a cgroup's CPU usage if the CPUs are not busy.
For further information, see
.IR Documentation/scheduler/sched-design-CFS.txt .
-
+.IP
In Linux 3.2,
this controller was extended to provide CPU "bandwidth" control.
If the kernel is configured with
@@ -258,21 +258,21 @@ Further information can be found in the kernel source file
.TP
.IR cpuacct " (since Linux 2.6.24; " \fBCONFIG_CGROUP_CPUACCT\fP )
This provides accounting for CPU usage by groups of processes.
-
+.IP
Further information can be found in the kernel source file
.IR Documentation/cgroup\-v1/cpuacct.txt .
.TP
.IR cpuset " (since Linux 2.6.24; " \fBCONFIG_CPUSETS\fP )
This cgroup can be used to bind the processes in a cgroup to
a specified set of CPUs and NUMA nodes.
-
+.IP
Further information can be found in the kernel source file
.IR Documentation/cgroup\-v1/cpusets.txt .
.TP
.IR memory " (since Linux 2.6.25; " \fBCONFIG_MEMCG\fP )
The memory controller supports reporting and limiting of process memory, kernel
memory, and swap used by cgroups.
-
+.IP
Further information can be found in the kernel source file
.IR Documentation/cgroup\-v1/memory.txt .
.TP
@@ -282,7 +282,7 @@ well as open them for reading or writing.
The policies may be specified as whitelists and blacklists.
Hierarchy is enforced, so new rules must not
violate existing rules for the target or ancestor cgroups.
-
+.IP
Further information can be found in the kernel source file
.IR Documentation/cgroup-v1/devices.txt .
.TP
@@ -295,7 +295,7 @@ Freezing a cgroup
also causes its children, for example, processes in
.IR /A/B ,
to be frozen.
-
+.IP
Further information can be found in the kernel source file
.IR Documentation/cgroup-v1/freezer-subsystem.txt .
.TP
@@ -307,7 +307,7 @@ as well as used to shape traffic using
.BR tc (8).
This applies only to packets
leaving the cgroup, not to traffic arriving at the cgroup.
-
+.IP
Further information can be found in the kernel source file
.IR Documentation/cgroup-v1/net_cls.txt .
.TP
@@ -317,14 +317,14 @@ The
cgroup controls and limits access to specified block devices by
applying IO control in the form of throttling and upper limits against leaf
nodes and intermediate nodes in the storage hierarchy.
-
+.IP
Two policies are available.
The first is a proportional-weight time-based division
of disk implemented with CFQ.
This is in effect for leaf nodes using CFQ.
The second is a throttling policy which specifies
upper I/O rate limits on a device.
-
+.IP
Further information can be found in the kernel source file
.IR Documentation/cgroup-v1/blkio-controller.txt .
.TP
@@ -332,26 +332,26 @@ Further information can be found in the kernel source file
This controller allows
.I perf
monitoring of the set of processes grouped in a cgroup.
-
+.IP
Further information can be found in the kernel source file
.IR tools/perf/Documentation/perf-record.txt .
.TP
.IR net_prio " (since Linux 3.3; " \fBCONFIG_CGROUP_NET_PRIO\fP )
This allows priorities to be specified, per network interface, for cgroups.
-
+.IP
Further information can be found in the kernel source file
.IR Documentation/cgroup-v1/net_prio.txt .
.TP
.IR hugetlb " (since Linux 3.5; " \fBCONFIG_CGROUP_HUGETLB\fP )
This supports limiting the use of huge pages by cgroups.
-
+.IP
Further information can be found in the kernel source file
.IR Documentation/cgroup-v1/hugetlb.txt .
.TP
.IR pids " (since Linux 4.3; " \fBCONFIG_CGROUP_PIDS\fP )
This controller permits limiting the number of process that may be created
in a cgroup (and its descendants).
-
+.IP
Further information can be found in the kernel source file
.IR Documentation/cgroup-v1/pids.txt .
.\"
@@ -359,33 +359,33 @@ Further information can be found in the kernel source file
A cgroup filesystem initially contains a single root cgroup, '/',
which all processes belong to.
A new cgroup is created by creating a directory in the cgroup filesystem:
-
+.PP
mkdir /sys/fs/cgroup/cpu/cg1
-
+.PP
This creates a new empty cgroup.
-
+.PP
A process may be moved to this cgroup by writing its PID into the cgroup's
.I cgroup.procs
file:
-
+.PP
echo $$ > /sys/fs/cgroup/cpu/cg1/cgroup.procs
-
+.PP
Only one PID at a time should be written to this file.
-
+.PP
Writing the value 0 to a
.IR cgroup.procs
file causes the writing process to be moved to the corresponding cgroup.
-
+.PP
When writing a PID into the
.IR cgroup.procs ,
all threads in the process are moved into the new cgroup at once.
-
+.PP
Within a hierarchy, a process can be a member of exactly one cgroup.
Writing a process's PID to a
.IR cgroup.procs
file automatically removes it from the cgroup of
which it was previously a member.
-
+.PP
The
.I cgroup.procs
file can be read to obtain a list of the processes that are
@@ -393,7 +393,7 @@ members of a cgroup.
The returned list of PIDs is not guaranteed to be in order.
Nor is it guaranteed to be free of duplicates.
(For example, a PID may be recycled while reading from the list.)
-
+.PP
In cgroups v1 (but not cgroups v2), an individual thread can be moved to
another cgroup by writing its thread ID
(i.e., the kernel thread ID returned by
@@ -420,7 +420,7 @@ Two files can be used to determine whether the kernel provides
notifications when a cgroup becomes empty.
A cgroup is considered to be empty when it contains no child
cgroups and no member processes.
-
+.PP
A special file in the root directory of each cgroup hierarchy,
.IR release_agent ,
can be used to register the pathname of a program that may be invoked when
@@ -433,11 +433,11 @@ The
.IR release_agent
program might remove the cgroup directory,
or perhaps repopulate with a process.
-
+.PP
The default value of the
.IR release_agent
file is empty, meaning that no release agent is invoked.
-
+.PP
Whether or not the
.IR release_agent
program is invoked when a particular cgroup becomes empty is determined
@@ -462,7 +462,7 @@ While (different) controllers may be simultaneously
mounted under the v1 and v2 hierarchies,
it is not possible to mount the same controller simultaneously
under both the v1 and the v2 hierarchies.
-
+.PP
The new behaviors in cgroups v2 are summarized here,
and in some cases elaborated in the following subsections.
.IP 1. 3
@@ -506,9 +506,9 @@ all available controllers are mounted against a single hierarchy.
The available controllers are automatically mounted,
meaning that it is not necessary (or possible) to specify the controllers
when mounting the cgroup v2 filesystem using a command such as the following:
-
+.PP
mount -t cgroup2 none /mnt/cgroup2
-
+.PP
A cgroup v2 controller is available only if it is not currently in use
via a mount against a cgroup v1 hierarchy.
Or, to put things another way, it is not possible to employ
@@ -519,7 +519,7 @@ With the exception of the root cgroup, processes may reside
only in leaf nodes (cgroups that do not themselves contain child cgroups).
This avoids the need to decide how to partition resources between
processes which are members of cgroup A and processes in child cgroups of A.
-
+.PP
For instance, if cgroup
.I /cg1/cg2
exists, then a process may reside in
@@ -580,7 +580,7 @@ which has either the value 0,
meaning that the cgroup (and its descendants)
contain no (nonzombie) processes,
or 1, meaning that the cgroup contains member processes.
-
+.PP
The
.IR cgroup.events
file can be monitored, in order to receive notification when a cgroup
@@ -594,7 +594,7 @@ events, and when monitoring the file using
transitions generate
.B POLLPRI
events.
-
+.PP
The cgroups v2
.IR notify_on_release
mechanism offers at least two advantages over the cgroups v1
@@ -616,7 +616,7 @@ This file contains information about the controllers
that are compiled into the kernel.
An example of the contents of this file (reformatted for readability)
is the following:
-
+.IP
.nf
.in +4n
#subsys_name hierarchy num_cgroups enabled
@@ -634,7 +634,7 @@ hugetlb 0 1 0
pids 2 1 1
.in
.fi
-
+.IP
The fields in this file are, from left to right:
.RS
.IP 1. 3
@@ -666,13 +666,13 @@ This file describes control groups to which the process
with the corresponding PID belongs.
The displayed information differs for
cgroups version 1 and version 2 hierarchies.
-
+.IP
For each cgroup hierarchy of which the process is a member,
there is one entry containing three
colon-separated fields of the form:
-
+.IP
hierarchy-ID:controller-list:cgroup-path
-
+.IP
For example:
.IP
.in +4n