]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/cgroups.7
standards.7: POSIX.1-2016 (POSIX.1-2008 TC2) has now been released
[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.
165The usual place for such mounts is under a tmpfs filesystem mounted at
166.IR /sys/fs/cgroup .
167Thus, one might mount the
168.I cpu
169controller as follows:
34d725f6 170
77e0a626
MK
171.nf
172.in +4n
173mount \-t cgroup \-o cpu none /sys/fs/cgroup/cpu
174.in
175.fi
effa83ce 176
77e0a626
MK
177It is possible to comount multiple controllers against the same hierarchy.
178For example, here the
179.IR cpu
21f0d132 180and
77e0a626
MK
181.IR cpuacct
182controllers are comounted against a single hierarchy:
21f0d132
MK
183
184.nf
185.in +4n
77e0a626 186mount \-t cgroup \-o cpu,cpuacct none /sys/fs/cgroup/cpu,cpuacct
21f0d132
MK
187.in
188.fi
effa83ce 189
55f52de8 190Comounting controllers has the effect that a process is in the same cgroup for
77e0a626 191all of the comounted controllers.
55f52de8 192Separately mounting controllers allows a process to
21f0d132
MK
193be in cgroup
194.I /foo1
55f52de8 195for one controller while being in
21f0d132
MK
196.I /foo2/foo3
197for another.
77e0a626
MK
198
199It is possible to comount all v1 controllers against the same hierarchy:
200
201.nf
202.in +4n
203mount \-t cgroup \-o all cgroup /sys/fs/cgroup
204.in
205.fi
206
207(One can achieve the same result by omitting
208.IR "\-o all" ,
209since it is the default if no controllers are explicitly specified.)
210
31ec2a5c
MK
211It is not possible to mount the same controller
212against multiple cgroup hierarchies.
213For example, it is not possible to mount both the
214.I cpu
215and
216.I cpuacct
217controllers against one hierarchy, and to mount the
218.I cpu
219controller alone against another hierarchy.
220It is possible to create multiple mount points with exactly
221the same set of comounted controllers.
222However, in this case all that results is multiple mount points
223providing a view of the same hierarchy.
224
77e0a626
MK
225Note that on many systems, the v1 controllers are automatically mounted under
226.IR /sys/fs/cgroup ;
227in particular,
228.BR systemd (1)
229automatically creates such mount points.
21f0d132 230.\"
860573ad
MK
231.SS Cgroups version 1 controllers
232Each of the cgroups version 1 controllers is governed
233by a kernel configuration option (listed below).
234Additionally, the availability of the cgroups feature is governed by the
235.BR CONFIG_CGROUPS
236kernel configuration option.
237.TP
238.IR cpu " (since Linux 2.6.24; " \fBCONFIG_CGROUP_SCHED\fP )
239Cgroups can be guaranteed a minimum number of "CPU shares"
240when a system is busy.
241This does not limit a cgroup's CPU usage if the CPUs are not busy.
242
243Further information can be found in the kernel source file
244.IR Documentation/scheduler/sched\-bwc.txt .
245.TP
246.IR cpuacct " (since Linux 2.6.24; " \fBCONFIG_CGROUP_CPUACCT\fP )
247This provides accounting for CPU usage by groups of processes.
248
249Further information can be found in the kernel source file
250.IR Documentation/cgroup\-v1/cpuacct.txt .
251.TP
252.IR cpuset " (since Linux 2.6.24; " \fBCONFIG_CPUSETS\fP )
253This cgroup can be used to bind the processes in a cgroup to
254a specified set of CPUs and NUMA nodes.
255
256Further information can be found in the kernel source file
257.IR Documentation/cgroup\-v1/cpusets.txt .
258.TP
259.IR memory " (since Linux 2.6.25; " \fBCONFIG_MEMCG\fP )
260The memory controller supports reporting and limiting of process memory, kernel
261memory, and swap used by cgroups.
262
263Further information can be found in the kernel source file
264.IR Documentation/cgroup\-v1/memory.txt .
265.TP
266.IR devices " (since Linux 2.6.26; " \fBCONFIG_CGROUP_DEVICE\fP )
267This supports controlling which processes may create (mknod) devices as
268well as open them for reading or writing.
269The policies may be specified as whitelists and blacklists.
270Hierarchy is enforced, so new rules must not
271violate existing rules for the target or ancestor cgroups.
272
273Further information can be found in the kernel source file
274.IR Documentation/cgroup-v1/devices.txt .
275.TP
276.IR freezer " (since Linux 2.6.28; " \fBCONFIG_CGROUP_FREEZER\fP )
277The
278.IR freezer
279cgroup can suspend and restore (resume) all processes in a cgroup.
280Freezing a cgroup
281.I /A
282also causes its children, for example, processes in
283.IR /A/B ,
284to be frozen.
285
286Further information can be found in the kernel source file
287.IR Documentation/cgroup-v1/freezer-subsystem.txt .
288.TP
289.IR net_cls " (since Linux 2.6.29; " \fBCONFIG_CGROUP_NET_CLASSID\fP )
290This places a classid, specified for the cgroup, on network packets
291created by a cgroup.
292These classids can then be used in firewall rules,
293as well as used to shape traffic using
294.BR tc (8).
295This applies only to packets
296leaving the cgroup, not to traffic arriving at the cgroup.
297
298Further information can be found in the kernel source file
299.IR Documentation/cgroup-v1/net_cls.txt .
300.TP
301.IR blkio " (since Linux 2.6.33; " \fBCONFIG_BLK_CGROUP\fP )
302The
303.I blkio
304cgroup controls and limits access to specified block devices by
305applying IO control in the form of throttling and upper limits against leaf
306nodes and intermediate nodes in the storage hierarchy.
307
308Two policies are available.
309The first is a proportional-weight time-based division
310of disk implemented with CFQ.
311This is in effect for leaf nodes using CFQ.
312The second is a throttling policy which specifies
313upper I/O rate limits on a device.
314
315Further information can be found in the kernel source file
316.IR Documentation/cgroup-v1/blkio-controller.txt .
317.TP
318.IR perf_event " (since Linux 2.6.39; " \fBCONFIG_CGROUP_PERF\fP )
319This controller allows
320.I perf
321monitoring of the set of processes grouped in a cgroup.
322
323Further information can be found in the kernel source file
c174eb6a 324.IR tools/perf/Documentation/perf-record.txt .
860573ad
MK
325.TP
326.IR net_prio " (since Linux 3.3; " \fBCONFIG_CGROUP_NET_PRIO\fP )
327This allows priorities to be specified, per network interface, for cgroups.
328
329Further information can be found in the kernel source file
330.IR Documentation/cgroup-v1/net_prio.txt .
331.TP
332.IR hugetlb " (since Linux 3.5; " \fBCONFIG_CGROUP_HUGETLB\fP )
333This supports limiting the use of huge pages by cgroups.
334
335Further information can be found in the kernel source file
336.IR Documentation/cgroup-v1/hugetlb.txt .
337.TP
338.IR pids " (since Linux 4.3; " \fBCONFIG_CGROUP_PIDS\fP )
339This controller permits limiting the number of process that may be created
340in a cgroup (and its descendants).
341
342Further information can be found in the kernel source file
343.IR Documentation/cgroup-v1/pids.txt .
344.\"
6398ca15 345.SS Creating cgroups and moving processes
9ed582ac 346A cgroup filesystem initially contains a single root cgroup, '/',
6398ca15 347which all processes belong to.
21f0d132
MK
348A new cgroup is created by creating a directory in the cgroup filesystem:
349
350 mkdir /sys/fs/cgroup/cpu/cg1
351
352This creates a new empty cgroup.
f524e7f8
MK
353
354A process may be moved to this cgroup by writing its PID into the cgroup's
21f0d132 355.I cgroup.procs
21f0d132
MK
356file:
357
358 echo $$ > /sys/fs/cgroup/cpu/cg1/cgroup.procs
359
f524e7f8
MK
360Only one PID at a time should be written to this file.
361
362Writing the value 0 to a
363.IR cgroup.procs
364file causes the writing process to be moved to the corresponding cgroup.
365
6398ca15
MK
366When writing a PID into the
367.IR cgroup.procs ,
87402a2e
MK
368all threads in the process are moved into the new cgroup at once.
369
f524e7f8
MK
370Within a hierarchy, a process can be a member of exactly one cgroup.
371Writing a process's PID to a
372.IR cgroup.procs
373file automatically removes it from the cgroup of
374which it was previously a member.
375
376The
377.I cgroup.procs
378file can be read to obtain a list of the processes that are
379members of a cgroup.
380The returned list of PIDs is not guaranteed to be in order.
381Nor is it guaranteed to be free of duplicates.
382(For example, a PID may be recycled while reading from the list.)
383
87402a2e
MK
384In cgroups v1 (but not cgroups v2), an individual thread can be moved to
385another cgroup by writing its thread ID
386(i.e., the kernel thread ID returned by
387.BR clone (2)
388and
389.BR gettid (2))
390to the
391.IR tasks
392file in a cgroup directory.
393This file can be read to discover the set of threads
394that are members of the cgroup.
395This file is not present in cgroup v2 directories.
b43be47e
MK
396.\"
397.SS Removing cgroups
398To remove a cgroup,
399it must first have no child cgroups and contain no (nonzombie) processes.
400So long as that is the case, one can simply
401remove the corresponding directory pathname.
402Note that files in a cgroup directory cannot and need not be
403removed.
404.\"
88afe701 405.SS Cgroups v1 release notification
23388d41
MK
406Two files can be used to determine whether the kernel provides
407notifications when a cgroup becomes empty.
408A cgroup is considered to be empty when it contains no child
409cgroups and no member processes.
410
411A special file in the root directory of each cgroup hierarchy,
88afe701 412.IR release_agent ,
23388d41
MK
413can be used to register the pathname of a program that may be invoked when
414a cgroup in the hierarchy becomes empty.
415The pathname of the newly empty cgroup (relative to the cgroup mount point)
416is provided as the sole command-line argument when the
417.IR release_agent
418program is invoked.
419The
420.IR release_agent
421program might remove the cgroup directory,
422or perhaps repopulate with a process.
423
424The default value of the
425.IR release_agent
426file is empty, meaning that no release agent is invoked.
427
428Whether or not the
429.IR release_agent
430program is invoked when a particular cgroup becomes empty is determined
431by the value in the
88afe701 432.IR notify_on_release
23388d41
MK
433file in the corresponding cgroup directory.
434If this file contains the value 0, then the
435.IR release_agent
436program is not invoked.
437If it contains the value 1, the
438.IR release_agent
439program is invoked.
440The default value for this file in the root cgroup is 0.
441At the time when a new cgroup is created,
442the value in this file is inherited from the corresponding file
443in the parent cgroup.
88afe701 444.\"
b43be47e
MK
445.SS Cgroups version 2
446In cgroups v2,
447all mounted controllers reside in a single unified hierarchy.
448While (different) controllers may be simultaneously
449mounted under the v1 and v2 hierarchies,
450it is not possible to mount the same controller simultaneously
451under both the v1 and the v2 hierarchies.
452
2befa495
MK
453The new behaviors in cgroups v2 are summarized here,
454and in some cases elaborated in the following subsections.
455.IP 1. 3
a15e0673 456Cgroups v2 provides a unified hierarchy against
dddb7ea1
MK
457which all controllers are mounted.
458.IP 2.
2befa495
MK
459"Internal" processes are not permitted.
460With the exception of the root cgroup, processes may reside
461only in leaf nodes (cgroups that do not themselves contain child cgroups).
dddb7ea1 462.IP 3.
2befa495
MK
463Active cgroups must be specified via the files
464.IR cgroup.controllers
465and
466.IR cgroup.subtree_control .
dddb7ea1 467.IP 4.
2befa495
MK
468The
469.I tasks
470file has been removed.
471In addition, the
472.I cgroup.clone_children
473file that is employed by the
474.I cpuset
475controller has been removed.
dddb7ea1 476.IP 5.
2befa495
MK
477An improved mechanism for notification of empty cgroups is provided by the
478.IR cgroup.events
479file.
480.PP
481For more changes, see the
482.I Documentation/cgroup-v2.txt
483file in the kernel source.
484.\"
dddb7ea1
MK
485.SS Cgroups v2 unified hierarchy
486In cgroups v1, the ability to mount different controllers
487against different hierarchies was intended to allow great flexibility
488for application design.
489In practice, though, the flexibility turned out to less useful than expected,
490and in many cases added complexity.
491Therefore, in cgroups v2,
492all available controllers are mounted against a single hierarchy.
493The available controllers are automatically mounted,
494meaning that it is not necessary (or possible) to specify the controllers
495when mounting the cgroup v2 filesystem using a command such as the following:
496
497 mount -t cgroup2 none /mnt/cgroup2
498
499A cgroup v2 controller is available only if it is not currently in use
500via a mount against a cgroup v1 hierarchy.
501Or, to put things another way, it is not possible to employ
502the same controller against both a v1 hierarchy and the unified v2 hierarchy.
503.\"
e4c759bc 504.SS Cgroups v2 """no internal processes""" rule
2befa495
MK
505With the exception of the root cgroup, processes may reside
506only in leaf nodes (cgroups that do not themselves contain child cgroups).
b43be47e
MK
507This avoids the need to decide how to partition resources between
508processes which are members of cgroup A and processes in child cgroups of A.
effa83ce 509
21f0d132
MK
510For instance, if cgroup
511.I /cg1/cg2
6398ca15 512exists, then a process may reside in
21f0d132
MK
513.IR /cg1/cg2 ,
514but not in
515.IR /cg1 .
5b38b21d 516This is to avoid an ambiguity in cgroups v1
3ddb25ac 517with respect to the delegation of resources between processes in
21f0d132
MK
518.I /cg1
519and its child cgroups.
3ddb25ac 520The recommended approach in cgroups v2 is to create a subdirectory called
21f0d132 521.I leaf
3ddb25ac
MK
522for any nonleaf cgroup which should contain processes, but no child cgroups.
523Thus, processes which previously would have gone into
21f0d132
MK
524.I /cg1
525would now go into
526.IR /cg1/leaf .
3ddb25ac
MK
527This has the advantage of making explicit
528the relationship between processes in
21f0d132
MK
529.I /cg1/leaf
530and
531.IR /cg1 's
532other children.
2befa495
MK
533.\"
534.SS Cgroups v2 subtree control
21f0d132
MK
535When a cgroup
536.I A/b
537is created, its
538.IR cgroup.controllers
effa83ce 539file contains the list of controllers which were active in its parent, A.
21f0d132
MK
540This is the list of controllers which are available to this cgroup.
541No controllers are active until they are enabled through the
542.IR cgroup.subtree_control
df6f53cc 543file, by writing the list of space-delimited names of the controllers,
0a837899 544each preceded by '+' (to enable) or '\-' (to disable).
21f0d132
MK
545If the
546.I freezer
547controller is not enabled in
548.IR /A/B ,
549then it cannot be enabled in
550.IR /A/B/C .
21f0d132 551.\"
754f4cf5
MK
552.SS Cgroups v2 cgroup.events file
553With cgroups v2, a new mechanism is provided to obtain notification
554about when a cgroup becomes empty.
555The cgroups v1
556.IR release_agent
557and
558.IR notify_on_release
559files are removed, and replaced by a new, more general-purpose file,
560.IR cgroup.events .
561This file contains key-value pairs
562(delimited by newline characters, with the key and value separated by spaces)
563that identify events or state for a cgroup.
564Currently, only one key appears in this file,
565.IR populated ,
566which has either the value 0,
567meaning that the cgroup (and its descendants)
568contain no (nonzombie) processes,
569or 1, meaning that the cgroup contains member processes.
570
571The
572.IR cgroup.events
573file can be monitored, in order to receive notification when a cgroup
574transitions between the populated and unpopulated states (or vice versa).
575When monitoring this file using
576.BR inotify (7),
577transitions generate
578.BR IN_MODIFY
579events, and when monitoring the file using
580.BR poll (2),
581transitions generate
582.B POLLPRI
583events.
584
585The cgroups v2
586.IR notify_on_release
587mechanism offers at least two advantages over the cgroups v1
588.IR release_agent
589mechanism.
590First, it allows for cheaper notification,
591since a single process can monitor multiple
592.IR cgroup.events
593files.
594By contrast, the cgroups v1 mechanism requires the creation
595of a process for each notification.
a15e0673 596Second, notification can be delegated to a process that lives inside
754f4cf5 597a container associated with the newly empty cgroup.
c91a9f8a 598.\"
5c2181ad
MK
599.SS /proc files
600.TP
34eb3340 601.IR /proc/cgroups " (since Linux 2.6.24)"
92bb6d36 602This file contains information about the controllers
1a4f7d59 603that are compiled into the kernel.
34eb3340
MK
604An example of the contents of this file (reformatted for readability)
605is the following:
606
607.nf
608.in +4n
4580c2f6
MK
609#subsys_name hierarchy num_cgroups enabled
610cpuset 4 1 1
611cpu 8 1 1
612cpuacct 8 1 1
613blkio 6 1 1
614memory 3 1 1
615devices 10 84 1
616freezer 7 1 1
617net_cls 9 1 1
618perf_event 5 1 1
619net_prio 9 1 1
620hugetlb 0 1 0
621pids 2 1 1
34eb3340
MK
622.in
623.fi
624
625The fields in this file are, from left to right:
626.RS
627.IP 1. 3
628The name of the controller.
629.IP 2.
92bb6d36 630The unique ID of the cgroup hierarchy on which this controller is mounted.
11c0797f 631If multiple cgroups v1 controllers are bound to the same hierarchy,
34eb3340 632then each will show the same hierarchy ID in this field.
92bb6d36
MK
633The value in this field will be 0 if:
634.RS 5
635.IP a) 3
636the controller is not mounted on a cgroups v1 hierarchy;
637.IP b)
638the controller is bound to the cgroups v2 single unified hierarchy; or
639.IP c)
640the controller is disabled (see below).
641.RE
34eb3340
MK
642.IP 3.
643The number of control groups in this hierarchy using this controller.
644.IP 4.
645This field contains the value 1 if this controller is enabled,
646or 0 if it has been disabled (via the
647.IR cgroup_disable
648kernel command-line boot parameter).
649.RE
650.TP
5c2181ad 651.IR /proc/[pid]/cgroup " (since Linux 2.6.24)"
f5faa016
MK
652This file describes control groups to which the process
653with the corresponding PID belongs.
5f8a7eb2 654The displayed information differs for
2c4fbe35 655cgroups version 1 and version 2 hierarchies.
5f8a7eb2
MK
656
657For each cgroup hierarchy of which the process is a member,
658there is one entry containing three
5c2181ad 659colon-separated fields of the form:
5f8a7eb2 660
55f52de8 661 hierarchy-ID:controller-list:cgroup-path
5f8a7eb2
MK
662
663For example:
5c2181ad
MK
664.nf
665.ft CW
666
667 5:cpuacct,cpu,cpuset:/daemons
668.ft
669.fi
670.IP
671The colon-separated fields are, from left to right:
5f8a7eb2 672.RS
5c2181ad 673.IP 1. 3
5f8a7eb2
MK
674For cgroups version 1 hierarchies,
675this field contains a unique hierarchy ID number
676that can be matched to a hierarchy ID in
677.IR /proc/cgroups .
678For the cgroups version 2 hierarchy, this field contains the value 0.
5c2181ad 679.IP 2.
5f8a7eb2 680For cgroups version 1 hierarchies,
55f52de8 681this field contains a comma-separated list of the controllers
5f8a7eb2
MK
682bound to the hierarchy.
683For the cgroups version 2 hierarchy, this field is empty.
5c2181ad 684.IP 3.
5f8a7eb2
MK
685This field contains the pathname of the control group in the hierarchy
686to which the process belongs.
687This pathname is relative to the mount point of the hierarchy.
5c2181ad 688.RE
2e23a9b2
MK
689.SH ERRORS
690The following errors can occur for
691.BR mount (2):
692.TP
693.B EBUSY
694An attempt to mount a cgroup version 1 filesystem specified neither the
695.I name=
696option (to mount a named hierarchy) nor a controller name (or
28bcfee9 697.IR all ).
15ce4b0c
MK
698.SH NOTES
699A child process created via
700.BR fork (2)
701inherits its parent's cgroup memberships.
702A process's cgroup memberships are preserved across
703.BR execve (2).
bbfdf727 704.SH SEE ALSO
ebbc83be 705.BR prlimit (1),
f60a5da2 706.BR systemd (1),
325b7eb0 707.BR clone (2),
ebbc83be
MK
708.BR ioprio_set (2),
709.BR perf_event_open (2),
710.BR setrlimit (2),
cff6de30 711.BR cgroup_namespaces (7),
69c47536 712.BR cpuset (7),
ebbc83be
MK
713.BR namespaces (7),
714.BR sched (7),
715.BR user_namespaces (7)