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