]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/cgroups.7
sched.7: Minor wording fix
[thirdparty/man-pages.git] / man7 / cgroups.7
CommitLineData
014cb63b 1.\" Copyright (C) 2015 Serge Hallyn <serge@hallyn.com>
43df1ab3 2.\" and Copyright (C) 2016 Michael Kerrisk <mtk.manpages@gmail.com>
014cb63b
MK
3.\"
4.\" %%%LICENSE_START(VERBATIM)
5.\" Permission is granted to make and distribute verbatim copies of this
6.\" manual provided the copyright notice and this permission notice are
7.\" preserved on all copies.
8.\"
9.\" Permission is granted to copy and distribute modified versions of this
10.\" manual under the conditions for verbatim copying, provided that the
11.\" entire resulting derived work is distributed under the terms of a
12.\" permission notice identical to this one.
13.\"
14.\" Since the Linux kernel and libraries are constantly changing, this
15.\" manual page may be incorrect or out-of-date. The author(s) assume no
16.\" responsibility for errors or omissions, or for damages resulting from
17.\" the use of the information contained herein. The author(s) may not
18.\" have taken the same level of care in the production of this manual,
19.\" which is licensed free of charge, as they might when working
20.\" professionally.
21.\"
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
24.\" %%%LICENSE_END
25.\"
3df541c0 26.TH CGROUPS 7 2016-07-17 "Linux" "Linux Programmer's Manual"
21f0d132
MK
27.SH NAME
28cgroups \- Linux control groups
29.SH DESCRIPTION
30Control cgroups, usually referred to as cgroups,
a15e0673 31are a Linux kernel feature which allow processes to
8bff7140
MK
32be organized into hierarchical groups whose usage of
33various types of resources can then be limited and monitored.
34The kernel's cgroup interface is provided through
21f0d132 35a pseudo-filesystem called cgroupfs.
6398ca15 36Grouping is implemented in the core cgroup kernel code,
21f0d132 37while resource tracking and limits are implemented in
8bff7140 38a set of per-resource-type subsystems (memory, CPU, and so on).
21f0d132 39.\"
176a4211
MK
40.SS Terminology
41A
42.I cgroup
43is a collection of processes that are bound to a set of
44limits or parameters defined via the cgroup filesystem.
45
46A
47.I subsystem
48is a kernel component that modifies the behavior of
49the processes in a cgroup.
50Various subsystems have been implemented, making it possible to do things
51such as limiting the amount of CPU time and memory available to a cgroup,
52accounting for the CPU time used by a cgroup,
53and freezing and resuming execution of the processes in a cgroup.
54Subsystems are sometimes also known as
55.IR "resource controllers"
56(or simply, controllers).
57
55f52de8 58The cgroups for a controller are arranged in a
176a4211
MK
59.IR hierarchy .
60This hierarchy is defined by creating, removing, and
61renaming subdirectories within the cgroup filesystem.
8fc9db1e
MK
62At each level of the hierarchy, attributes (e.g., limits) can be defined.
63The limits, control, and accounting provided by cgroups generally have
64effect throughout the subhierarchy underneath the cgroup where the
65attributes are defined.
8bff7140
MK
66Thus, for example, the limits placed on
67a cgroup at a higher level in the hierarchy cannot be exceeded
68by descendant cgroups.
176a4211 69.\"
43df1ab3
MK
70.SS Cgroups version 1 and version 2
71The initial release of the cgroups implementation was in Linux 2.6.24.
55f52de8 72Over time, various cgroup controllers have been added
43df1ab3 73to allow the management of various types of resources.
55f52de8
MK
74However, the development of these controllers was largely uncoordinated,
75with the result that many inconsistencies arose between controllers
43df1ab3
MK
76and management of the cgroup hierarchies became rather complex.
77(A longer description of these problems can be found in
78the kernel source file
0a837899 79.IR Documentation/cgroup\-v2.txt .)
43df1ab3 80
813d9220
MK
81Because of the problems with the initial cgroups implementation
82(cgroups version 1),
43df1ab3
MK
83starting in Linux 3.10, work began on a new,
84orthogonal implementation to remedy these problems.
85Initially marked experimental, and hidden behind the
86.I "\-o\ __DEVEL__sane_behavior"
87mount option, the new version (cgroups version 2)
88was eventually made official with the release of Linux 4.5.
89Differences between the two versions are described in the text below.
90
91Although cgroups v2 is intended as a replacement for cgroups v1,
92the older system continues to exist
93(and for compatibility reasons is unlikely to be removed).
94Currently, cgroups v2 implements only a subset of the controllers
95available in cgroups v1.
96The two systems are implemented so that both v1 controllers and
97v2 controllers can be mounted on the same system.
98Thus, for example, it is possible to use those controllers
99that are supported under version 2,
100while also using version 1 controllers
101where version 2 does not yet support those controllers.
1a90a85e
MK
102The only restriction here is that a controller can't be simultaneously
103employed in both a cgroups v1 hierarchy and in the cgroups v2 hierarchy.
43df1ab3 104.\"
8bff7140
MK
105.SS Cgroups version 1
106Under cgroups v1, each controller may be mounted against a separate
107cgroup filesystem that provides its own hierarchical organization of the
108processes on the system.
109It is also possible comount multiple (or even all) cgroups v1 controllers
110against the same cgroup filesystem, meaning that the comounted controllers
111manage the same hierarchical organization of processes.
112
113For each mounted hierarchy,
114the directory tree mirrors the control group hierarchy.
115Each control group is represented by a directory, with each of its child
116control cgroups represented as a child directory.
117For instance,
118.IR /user/joe/1.session
119represents control group
120.IR 1.session ,
121which is a child of cgroup
122.IR joe ,
123which is a child of
124.IR /user .
125Under each cgroup directory is a set of files which can be read or
126written to, reflecting resource limits and a few general cgroup
127properties.
128
129In addition, in cgroups v1,
55f52de8 130cgroups can be mounted with no bound controller, in which case
8bff7140 131they serve only to track processes.
59dabd75 132(See the discussion of release notification below.)
8bff7140
MK
133An example of this is the
134.I name=systemd
135cgroup which is used by
136.BR systemd (1)
137to track services and user sessions.
138.\"
6398ca15 139.SS Tasks (threads) versus processes
c775bca2
MK
140In cgroups v1, a distinction is drawn between
141.I processes
142and
143.IR tasks .
144In this view, a process can consist of multiple tasks
6398ca15
MK
145(more commonly called threads, from a user-space perspective,
146and called such in the remainder of this man page).
0ec74e08 147In cgroups v1, it is possible to independently manipulate
6398ca15 148the cgroup memberships of the threads in a process.
c775bca2
MK
149Because this ability caused certain problems,
150.\" FIXME Add some text describing why this was a problem.
151the ability to independently manipulate the cgroup memberships
6398ca15 152of the threads in a process has been removed in cgroups v2.
c775bca2
MK
153Cgroups v2 allows manipulation of cgroup membership only for processes
154(which has the effect of changing the cgroup membership of
6398ca15 155all threads in the process).
c775bca2 156.\"
77e0a626
MK
157.SS Mounting v1 controllers
158The use of cgroups requires a kernel built with the
159.BR CONFIG_CGROUP\option.
160In addition, each of the v1 controllers has an associated
161configuration option that must be set in order to employ that controller.
effa83ce 162
77e0a626
MK
163In order to use a v1 controller,
164it must be mounted against a cgroup filesystem.
4e07c70f
MK
165The usual place for such mounts is under a
166.BR tmpfs (5)
167filesystem mounted at
77e0a626
MK
168.IR /sys/fs/cgroup .
169Thus, one might mount the
170.I cpu
171controller as follows:
34d725f6 172
77e0a626
MK
173.nf
174.in +4n
175mount \-t cgroup \-o cpu none /sys/fs/cgroup/cpu
176.in
177.fi
effa83ce 178
77e0a626
MK
179It is possible to comount multiple controllers against the same hierarchy.
180For example, here the
181.IR cpu
21f0d132 182and
77e0a626
MK
183.IR cpuacct
184controllers are comounted against a single hierarchy:
21f0d132
MK
185
186.nf
187.in +4n
77e0a626 188mount \-t cgroup \-o cpu,cpuacct none /sys/fs/cgroup/cpu,cpuacct
21f0d132
MK
189.in
190.fi
effa83ce 191
55f52de8 192Comounting controllers has the effect that a process is in the same cgroup for
77e0a626 193all of the comounted controllers.
55f52de8 194Separately mounting controllers allows a process to
21f0d132
MK
195be in cgroup
196.I /foo1
55f52de8 197for one controller while being in
21f0d132
MK
198.I /foo2/foo3
199for another.
77e0a626
MK
200
201It is possible to comount all v1 controllers against the same hierarchy:
202
203.nf
204.in +4n
205mount \-t cgroup \-o all cgroup /sys/fs/cgroup
206.in
207.fi
208
209(One can achieve the same result by omitting
210.IR "\-o all" ,
211since it is the default if no controllers are explicitly specified.)
212
31ec2a5c
MK
213It is not possible to mount the same controller
214against multiple cgroup hierarchies.
215For example, it is not possible to mount both the
216.I cpu
217and
218.I cpuacct
219controllers against one hierarchy, and to mount the
220.I cpu
221controller alone against another hierarchy.
222It is possible to create multiple mount points with exactly
223the same set of comounted controllers.
224However, in this case all that results is multiple mount points
225providing a view of the same hierarchy.
226
77e0a626
MK
227Note that on many systems, the v1 controllers are automatically mounted under
228.IR /sys/fs/cgroup ;
229in particular,
230.BR systemd (1)
231automatically creates such mount points.
21f0d132 232.\"
860573ad
MK
233.SS Cgroups version 1 controllers
234Each of the cgroups version 1 controllers is governed
235by a kernel configuration option (listed below).
236Additionally, the availability of the cgroups feature is governed by the
237.BR CONFIG_CGROUPS
238kernel configuration option.
239.TP
240.IR cpu " (since Linux 2.6.24; " \fBCONFIG_CGROUP_SCHED\fP )
241Cgroups can be guaranteed a minimum number of "CPU shares"
242when a system is busy.
243This does not limit a cgroup's CPU usage if the CPUs are not busy.
4ad9a706
MK
244For further information, see
245.IR Documentation/scheduler/sched-design-CFS.txt .
860573ad 246
4ad9a706
MK
247In Linux 3.2,
248this controller was extended to provide CPU "bandwidth" control.
249If the kernel is configured with
250.BR COONFIG_CFS_BANDWIDTH ,
251then within each scheduling period
252(defined via a file in the cgroup directory), it is possible to define
253an upper limit on the CPU time allocated to the processes in a cgroup.
254This upper limit applies even if there is no other competition for the CPU.
860573ad
MK
255Further information can be found in the kernel source file
256.IR Documentation/scheduler/sched\-bwc.txt .
257.TP
258.IR cpuacct " (since Linux 2.6.24; " \fBCONFIG_CGROUP_CPUACCT\fP )
259This provides accounting for CPU usage by groups of processes.
260
261Further information can be found in the kernel source file
262.IR Documentation/cgroup\-v1/cpuacct.txt .
263.TP
264.IR cpuset " (since Linux 2.6.24; " \fBCONFIG_CPUSETS\fP )
265This cgroup can be used to bind the processes in a cgroup to
266a specified set of CPUs and NUMA nodes.
267
268Further information can be found in the kernel source file
269.IR Documentation/cgroup\-v1/cpusets.txt .
270.TP
271.IR memory " (since Linux 2.6.25; " \fBCONFIG_MEMCG\fP )
272The memory controller supports reporting and limiting of process memory, kernel
273memory, and swap used by cgroups.
274
275Further information can be found in the kernel source file
276.IR Documentation/cgroup\-v1/memory.txt .
277.TP
278.IR devices " (since Linux 2.6.26; " \fBCONFIG_CGROUP_DEVICE\fP )
279This supports controlling which processes may create (mknod) devices as
280well as open them for reading or writing.
281The policies may be specified as whitelists and blacklists.
282Hierarchy is enforced, so new rules must not
283violate existing rules for the target or ancestor cgroups.
284
285Further information can be found in the kernel source file
286.IR Documentation/cgroup-v1/devices.txt .
287.TP
288.IR freezer " (since Linux 2.6.28; " \fBCONFIG_CGROUP_FREEZER\fP )
289The
290.IR freezer
291cgroup can suspend and restore (resume) all processes in a cgroup.
292Freezing a cgroup
293.I /A
294also causes its children, for example, processes in
295.IR /A/B ,
296to be frozen.
297
298Further information can be found in the kernel source file
299.IR Documentation/cgroup-v1/freezer-subsystem.txt .
300.TP
301.IR net_cls " (since Linux 2.6.29; " \fBCONFIG_CGROUP_NET_CLASSID\fP )
302This places a classid, specified for the cgroup, on network packets
303created by a cgroup.
304These classids can then be used in firewall rules,
305as well as used to shape traffic using
306.BR tc (8).
307This applies only to packets
308leaving the cgroup, not to traffic arriving at the cgroup.
309
310Further information can be found in the kernel source file
311.IR Documentation/cgroup-v1/net_cls.txt .
312.TP
313.IR blkio " (since Linux 2.6.33; " \fBCONFIG_BLK_CGROUP\fP )
314The
315.I blkio
316cgroup controls and limits access to specified block devices by
317applying IO control in the form of throttling and upper limits against leaf
318nodes and intermediate nodes in the storage hierarchy.
319
320Two policies are available.
321The first is a proportional-weight time-based division
322of disk implemented with CFQ.
323This is in effect for leaf nodes using CFQ.
324The second is a throttling policy which specifies
325upper I/O rate limits on a device.
326
327Further information can be found in the kernel source file
328.IR Documentation/cgroup-v1/blkio-controller.txt .
329.TP
330.IR perf_event " (since Linux 2.6.39; " \fBCONFIG_CGROUP_PERF\fP )
331This controller allows
332.I perf
333monitoring of the set of processes grouped in a cgroup.
334
335Further information can be found in the kernel source file
c174eb6a 336.IR tools/perf/Documentation/perf-record.txt .
860573ad
MK
337.TP
338.IR net_prio " (since Linux 3.3; " \fBCONFIG_CGROUP_NET_PRIO\fP )
339This allows priorities to be specified, per network interface, for cgroups.
340
341Further information can be found in the kernel source file
342.IR Documentation/cgroup-v1/net_prio.txt .
343.TP
344.IR hugetlb " (since Linux 3.5; " \fBCONFIG_CGROUP_HUGETLB\fP )
345This supports limiting the use of huge pages by cgroups.
346
347Further information can be found in the kernel source file
348.IR Documentation/cgroup-v1/hugetlb.txt .
349.TP
350.IR pids " (since Linux 4.3; " \fBCONFIG_CGROUP_PIDS\fP )
351This controller permits limiting the number of process that may be created
352in a cgroup (and its descendants).
353
354Further information can be found in the kernel source file
355.IR Documentation/cgroup-v1/pids.txt .
356.\"
6398ca15 357.SS Creating cgroups and moving processes
9ed582ac 358A cgroup filesystem initially contains a single root cgroup, '/',
6398ca15 359which all processes belong to.
21f0d132
MK
360A new cgroup is created by creating a directory in the cgroup filesystem:
361
362 mkdir /sys/fs/cgroup/cpu/cg1
363
364This creates a new empty cgroup.
f524e7f8
MK
365
366A process may be moved to this cgroup by writing its PID into the cgroup's
21f0d132 367.I cgroup.procs
21f0d132
MK
368file:
369
370 echo $$ > /sys/fs/cgroup/cpu/cg1/cgroup.procs
371
f524e7f8
MK
372Only one PID at a time should be written to this file.
373
374Writing the value 0 to a
375.IR cgroup.procs
376file causes the writing process to be moved to the corresponding cgroup.
377
6398ca15
MK
378When writing a PID into the
379.IR cgroup.procs ,
87402a2e
MK
380all threads in the process are moved into the new cgroup at once.
381
f524e7f8
MK
382Within a hierarchy, a process can be a member of exactly one cgroup.
383Writing a process's PID to a
384.IR cgroup.procs
385file automatically removes it from the cgroup of
386which it was previously a member.
387
388The
389.I cgroup.procs
390file can be read to obtain a list of the processes that are
391members of a cgroup.
392The returned list of PIDs is not guaranteed to be in order.
393Nor is it guaranteed to be free of duplicates.
394(For example, a PID may be recycled while reading from the list.)
395
87402a2e
MK
396In cgroups v1 (but not cgroups v2), an individual thread can be moved to
397another cgroup by writing its thread ID
398(i.e., the kernel thread ID returned by
399.BR clone (2)
400and
401.BR gettid (2))
402to the
403.IR tasks
404file in a cgroup directory.
405This file can be read to discover the set of threads
406that are members of the cgroup.
407This file is not present in cgroup v2 directories.
b43be47e
MK
408.\"
409.SS Removing cgroups
410To remove a cgroup,
411it must first have no child cgroups and contain no (nonzombie) processes.
412So long as that is the case, one can simply
413remove the corresponding directory pathname.
414Note that files in a cgroup directory cannot and need not be
415removed.
416.\"
88afe701 417.SS Cgroups v1 release notification
23388d41
MK
418Two files can be used to determine whether the kernel provides
419notifications when a cgroup becomes empty.
420A cgroup is considered to be empty when it contains no child
421cgroups and no member processes.
422
423A special file in the root directory of each cgroup hierarchy,
88afe701 424.IR release_agent ,
23388d41
MK
425can be used to register the pathname of a program that may be invoked when
426a cgroup in the hierarchy becomes empty.
427The pathname of the newly empty cgroup (relative to the cgroup mount point)
428is provided as the sole command-line argument when the
429.IR release_agent
430program is invoked.
431The
432.IR release_agent
433program might remove the cgroup directory,
434or perhaps repopulate with a process.
435
436The default value of the
437.IR release_agent
438file is empty, meaning that no release agent is invoked.
439
440Whether or not the
441.IR release_agent
442program is invoked when a particular cgroup becomes empty is determined
443by the value in the
88afe701 444.IR notify_on_release
23388d41
MK
445file in the corresponding cgroup directory.
446If this file contains the value 0, then the
447.IR release_agent
448program is not invoked.
449If it contains the value 1, the
450.IR release_agent
451program is invoked.
452The default value for this file in the root cgroup is 0.
453At the time when a new cgroup is created,
454the value in this file is inherited from the corresponding file
455in the parent cgroup.
88afe701 456.\"
b43be47e
MK
457.SS Cgroups version 2
458In cgroups v2,
459all mounted controllers reside in a single unified hierarchy.
460While (different) controllers may be simultaneously
461mounted under the v1 and v2 hierarchies,
462it is not possible to mount the same controller simultaneously
463under both the v1 and the v2 hierarchies.
464
2befa495
MK
465The new behaviors in cgroups v2 are summarized here,
466and in some cases elaborated in the following subsections.
467.IP 1. 3
a15e0673 468Cgroups v2 provides a unified hierarchy against
dddb7ea1
MK
469which all controllers are mounted.
470.IP 2.
2befa495
MK
471"Internal" processes are not permitted.
472With the exception of the root cgroup, processes may reside
473only in leaf nodes (cgroups that do not themselves contain child cgroups).
dddb7ea1 474.IP 3.
2befa495
MK
475Active cgroups must be specified via the files
476.IR cgroup.controllers
477and
478.IR cgroup.subtree_control .
dddb7ea1 479.IP 4.
2befa495
MK
480The
481.I tasks
482file has been removed.
483In addition, the
484.I cgroup.clone_children
485file that is employed by the
486.I cpuset
487controller has been removed.
dddb7ea1 488.IP 5.
2befa495
MK
489An improved mechanism for notification of empty cgroups is provided by the
490.IR cgroup.events
491file.
492.PP
493For more changes, see the
494.I Documentation/cgroup-v2.txt
495file in the kernel source.
496.\"
dddb7ea1
MK
497.SS Cgroups v2 unified hierarchy
498In cgroups v1, the ability to mount different controllers
499against different hierarchies was intended to allow great flexibility
500for application design.
501In practice, though, the flexibility turned out to less useful than expected,
502and in many cases added complexity.
503Therefore, in cgroups v2,
504all available controllers are mounted against a single hierarchy.
505The available controllers are automatically mounted,
506meaning that it is not necessary (or possible) to specify the controllers
507when mounting the cgroup v2 filesystem using a command such as the following:
508
509 mount -t cgroup2 none /mnt/cgroup2
510
511A cgroup v2 controller is available only if it is not currently in use
512via a mount against a cgroup v1 hierarchy.
513Or, to put things another way, it is not possible to employ
514the same controller against both a v1 hierarchy and the unified v2 hierarchy.
515.\"
e4c759bc 516.SS Cgroups v2 """no internal processes""" rule
2befa495
MK
517With the exception of the root cgroup, processes may reside
518only in leaf nodes (cgroups that do not themselves contain child cgroups).
b43be47e
MK
519This avoids the need to decide how to partition resources between
520processes which are members of cgroup A and processes in child cgroups of A.
effa83ce 521
21f0d132
MK
522For instance, if cgroup
523.I /cg1/cg2
6398ca15 524exists, then a process may reside in
21f0d132
MK
525.IR /cg1/cg2 ,
526but not in
527.IR /cg1 .
5b38b21d 528This is to avoid an ambiguity in cgroups v1
3ddb25ac 529with respect to the delegation of resources between processes in
21f0d132
MK
530.I /cg1
531and its child cgroups.
3ddb25ac 532The recommended approach in cgroups v2 is to create a subdirectory called
21f0d132 533.I leaf
3ddb25ac
MK
534for any nonleaf cgroup which should contain processes, but no child cgroups.
535Thus, processes which previously would have gone into
21f0d132
MK
536.I /cg1
537would now go into
538.IR /cg1/leaf .
3ddb25ac
MK
539This has the advantage of making explicit
540the relationship between processes in
21f0d132
MK
541.I /cg1/leaf
542and
543.IR /cg1 's
544other children.
2befa495
MK
545.\"
546.SS Cgroups v2 subtree control
21f0d132
MK
547When a cgroup
548.I A/b
549is created, its
550.IR cgroup.controllers
effa83ce 551file contains the list of controllers which were active in its parent, A.
21f0d132
MK
552This is the list of controllers which are available to this cgroup.
553No controllers are active until they are enabled through the
554.IR cgroup.subtree_control
df6f53cc 555file, by writing the list of space-delimited names of the controllers,
0a837899 556each preceded by '+' (to enable) or '\-' (to disable).
21f0d132
MK
557If the
558.I freezer
559controller is not enabled in
560.IR /A/B ,
561then it cannot be enabled in
562.IR /A/B/C .
21f0d132 563.\"
754f4cf5
MK
564.SS Cgroups v2 cgroup.events file
565With cgroups v2, a new mechanism is provided to obtain notification
566about when a cgroup becomes empty.
567The cgroups v1
568.IR release_agent
569and
570.IR notify_on_release
571files are removed, and replaced by a new, more general-purpose file,
572.IR cgroup.events .
573This file contains key-value pairs
574(delimited by newline characters, with the key and value separated by spaces)
575that identify events or state for a cgroup.
576Currently, only one key appears in this file,
577.IR populated ,
578which has either the value 0,
579meaning that the cgroup (and its descendants)
580contain no (nonzombie) processes,
581or 1, meaning that the cgroup contains member processes.
582
583The
584.IR cgroup.events
585file can be monitored, in order to receive notification when a cgroup
586transitions between the populated and unpopulated states (or vice versa).
587When monitoring this file using
588.BR inotify (7),
589transitions generate
590.BR IN_MODIFY
591events, and when monitoring the file using
592.BR poll (2),
593transitions generate
594.B POLLPRI
595events.
596
597The cgroups v2
598.IR notify_on_release
599mechanism offers at least two advantages over the cgroups v1
600.IR release_agent
601mechanism.
602First, it allows for cheaper notification,
603since a single process can monitor multiple
604.IR cgroup.events
605files.
606By contrast, the cgroups v1 mechanism requires the creation
607of a process for each notification.
a15e0673 608Second, notification can be delegated to a process that lives inside
754f4cf5 609a container associated with the newly empty cgroup.
c91a9f8a 610.\"
5c2181ad
MK
611.SS /proc files
612.TP
34eb3340 613.IR /proc/cgroups " (since Linux 2.6.24)"
92bb6d36 614This file contains information about the controllers
1a4f7d59 615that are compiled into the kernel.
34eb3340
MK
616An example of the contents of this file (reformatted for readability)
617is the following:
618
619.nf
620.in +4n
4580c2f6
MK
621#subsys_name hierarchy num_cgroups enabled
622cpuset 4 1 1
623cpu 8 1 1
624cpuacct 8 1 1
625blkio 6 1 1
626memory 3 1 1
627devices 10 84 1
628freezer 7 1 1
629net_cls 9 1 1
630perf_event 5 1 1
631net_prio 9 1 1
632hugetlb 0 1 0
633pids 2 1 1
34eb3340
MK
634.in
635.fi
636
637The fields in this file are, from left to right:
638.RS
639.IP 1. 3
640The name of the controller.
641.IP 2.
92bb6d36 642The unique ID of the cgroup hierarchy on which this controller is mounted.
11c0797f 643If multiple cgroups v1 controllers are bound to the same hierarchy,
34eb3340 644then each will show the same hierarchy ID in this field.
92bb6d36
MK
645The value in this field will be 0 if:
646.RS 5
647.IP a) 3
648the controller is not mounted on a cgroups v1 hierarchy;
649.IP b)
650the controller is bound to the cgroups v2 single unified hierarchy; or
651.IP c)
652the controller is disabled (see below).
653.RE
34eb3340
MK
654.IP 3.
655The number of control groups in this hierarchy using this controller.
656.IP 4.
657This field contains the value 1 if this controller is enabled,
658or 0 if it has been disabled (via the
659.IR cgroup_disable
660kernel command-line boot parameter).
661.RE
662.TP
5c2181ad 663.IR /proc/[pid]/cgroup " (since Linux 2.6.24)"
f5faa016
MK
664This file describes control groups to which the process
665with the corresponding PID belongs.
5f8a7eb2 666The displayed information differs for
2c4fbe35 667cgroups version 1 and version 2 hierarchies.
5f8a7eb2
MK
668
669For each cgroup hierarchy of which the process is a member,
670there is one entry containing three
5c2181ad 671colon-separated fields of the form:
5f8a7eb2 672
55f52de8 673 hierarchy-ID:controller-list:cgroup-path
5f8a7eb2
MK
674
675For example:
5c2181ad
MK
676.nf
677.ft CW
678
679 5:cpuacct,cpu,cpuset:/daemons
680.ft
681.fi
682.IP
683The colon-separated fields are, from left to right:
5f8a7eb2 684.RS
5c2181ad 685.IP 1. 3
5f8a7eb2
MK
686For cgroups version 1 hierarchies,
687this field contains a unique hierarchy ID number
688that can be matched to a hierarchy ID in
689.IR /proc/cgroups .
690For the cgroups version 2 hierarchy, this field contains the value 0.
5c2181ad 691.IP 2.
5f8a7eb2 692For cgroups version 1 hierarchies,
55f52de8 693this field contains a comma-separated list of the controllers
5f8a7eb2
MK
694bound to the hierarchy.
695For the cgroups version 2 hierarchy, this field is empty.
5c2181ad 696.IP 3.
5f8a7eb2
MK
697This field contains the pathname of the control group in the hierarchy
698to which the process belongs.
699This pathname is relative to the mount point of the hierarchy.
5c2181ad 700.RE
2e23a9b2
MK
701.SH ERRORS
702The following errors can occur for
703.BR mount (2):
704.TP
705.B EBUSY
706An attempt to mount a cgroup version 1 filesystem specified neither the
707.I name=
708option (to mount a named hierarchy) nor a controller name (or
28bcfee9 709.IR all ).
15ce4b0c
MK
710.SH NOTES
711A child process created via
712.BR fork (2)
713inherits its parent's cgroup memberships.
714A process's cgroup memberships are preserved across
715.BR execve (2).
bbfdf727 716.SH SEE ALSO
ebbc83be 717.BR prlimit (1),
f60a5da2 718.BR systemd (1),
325b7eb0 719.BR clone (2),
ebbc83be
MK
720.BR ioprio_set (2),
721.BR perf_event_open (2),
722.BR setrlimit (2),
cff6de30 723.BR cgroup_namespaces (7),
69c47536 724.BR cpuset (7),
ebbc83be
MK
725.BR namespaces (7),
726.BR sched (7),
727.BR user_namespaces (7)