1 .\" Copyright (C) 2015 Serge Hallyn <serge@hallyn.com>
2 .\" and Copyright (C) 2016, 2017 Michael Kerrisk <mtk.manpages@gmail.com>
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.
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.
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
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .TH CGROUPS 7 2021-08-27 "Linux" "Linux Programmer's Manual"
28 cgroups \- Linux control groups
30 Control groups, usually referred to as cgroups,
31 are a Linux kernel feature which allow processes to
32 be organized into hierarchical groups whose usage of
33 various types of resources can then be limited and monitored.
34 The kernel's cgroup interface is provided through
35 a pseudo-filesystem called cgroupfs.
36 Grouping is implemented in the core cgroup kernel code,
37 while resource tracking and limits are implemented in
38 a set of per-resource-type subsystems (memory, CPU, and so on).
43 is a collection of processes that are bound to a set of
44 limits or parameters defined via the cgroup filesystem.
48 is a kernel component that modifies the behavior of
49 the processes in a cgroup.
50 Various subsystems have been implemented, making it possible to do things
51 such as limiting the amount of CPU time and memory available to a cgroup,
52 accounting for the CPU time used by a cgroup,
53 and freezing and resuming execution of the processes in a cgroup.
54 Subsystems are sometimes also known as
55 .IR "resource controllers"
56 (or simply, controllers).
58 The cgroups for a controller are arranged in a
60 This hierarchy is defined by creating, removing, and
61 renaming subdirectories within the cgroup filesystem.
62 At each level of the hierarchy, attributes (e.g., limits) can be defined.
63 The limits, control, and accounting provided by cgroups generally have
64 effect throughout the subhierarchy underneath the cgroup where the
65 attributes are defined.
66 Thus, for example, the limits placed on
67 a cgroup at a higher level in the hierarchy cannot be exceeded
68 by descendant cgroups.
70 .SS Cgroups version 1 and version 2
71 The initial release of the cgroups implementation was in Linux 2.6.24.
72 Over time, various cgroup controllers have been added
73 to allow the management of various types of resources.
74 However, the development of these controllers was largely uncoordinated,
75 with the result that many inconsistencies arose between controllers
76 and management of the cgroup hierarchies became rather complex.
77 A longer description of these problems can be found in the kernel
79 .IR Documentation/admin\-guide/cgroup\-v2.rst
81 .IR Documentation/cgroup\-v2.txt
82 in Linux 4.17 and earlier).
84 Because of the problems with the initial cgroups implementation
86 starting in Linux 3.10, work began on a new,
87 orthogonal implementation to remedy these problems.
88 Initially marked experimental, and hidden behind the
89 .I "\-o\ __DEVEL__sane_behavior"
90 mount option, the new version (cgroups version 2)
91 was eventually made official with the release of Linux 4.5.
92 Differences between the two versions are described in the text below.
94 .IR cgroup.sane_behavior ,
95 present in cgroups v1, is a relic of this mount option.
96 The file always reports "0" and is only retained for backward compatibility.
98 Although cgroups v2 is intended as a replacement for cgroups v1,
99 the older system continues to exist
100 (and for compatibility reasons is unlikely to be removed).
101 Currently, cgroups v2 implements only a subset of the controllers
102 available in cgroups v1.
103 The two systems are implemented so that both v1 controllers and
104 v2 controllers can be mounted on the same system.
105 Thus, for example, it is possible to use those controllers
106 that are supported under version 2,
107 while also using version 1 controllers
108 where version 2 does not yet support those controllers.
109 The only restriction here is that a controller can't be simultaneously
110 employed in both a cgroups v1 hierarchy and in the cgroups v2 hierarchy.
112 .SH CGROUPS VERSION 1
113 Under cgroups v1, each controller may be mounted against a separate
114 cgroup filesystem that provides its own hierarchical organization of the
115 processes on the system.
116 It is also possible to comount multiple (or even all) cgroups v1 controllers
117 against the same cgroup filesystem, meaning that the comounted controllers
118 manage the same hierarchical organization of processes.
120 For each mounted hierarchy,
121 the directory tree mirrors the control group hierarchy.
122 Each control group is represented by a directory, with each of its child
123 control cgroups represented as a child directory.
125 .IR /user/joe/1.session
126 represents control group
128 which is a child of cgroup
132 Under each cgroup directory is a set of files which can be read or
133 written to, reflecting resource limits and a few general cgroup
136 .SS Tasks (threads) versus processes
137 In cgroups v1, a distinction is drawn between
141 In this view, a process can consist of multiple tasks
142 (more commonly called threads, from a user-space perspective,
143 and called such in the remainder of this man page).
144 In cgroups v1, it is possible to independently manipulate
145 the cgroup memberships of the threads in a process.
147 The cgroups v1 ability to split threads across different cgroups
148 caused problems in some cases.
149 For example, it made no sense for the
152 since all of the threads of a process share a single address space.
153 Because of these problems,
154 the ability to independently manipulate the cgroup memberships
155 of the threads in a process was removed in the initial cgroups v2
156 implementation, and subsequently restored in a more limited form
157 (see the discussion of "thread mode" below).
159 .SS Mounting v1 controllers
160 The use of cgroups requires a kernel built with the
163 In addition, each of the v1 controllers has an associated
164 configuration option that must be set in order to employ that controller.
166 In order to use a v1 controller,
167 it must be mounted against a cgroup filesystem.
168 The usual place for such mounts is under a
170 filesystem mounted at
172 Thus, one might mount the
174 controller as follows:
178 mount \-t cgroup \-o cpu none /sys/fs/cgroup/cpu
182 It is possible to comount multiple controllers against the same hierarchy.
183 For example, here the
187 controllers are comounted against a single hierarchy:
191 mount \-t cgroup \-o cpu,cpuacct none /sys/fs/cgroup/cpu,cpuacct
195 Comounting controllers has the effect that a process is in the same cgroup for
196 all of the comounted controllers.
197 Separately mounting controllers allows a process to
200 for one controller while being in
204 It is possible to comount all v1 controllers against the same hierarchy:
208 mount \-t cgroup \-o all cgroup /sys/fs/cgroup
212 (One can achieve the same result by omitting
214 since it is the default if no controllers are explicitly specified.)
216 It is not possible to mount the same controller
217 against multiple cgroup hierarchies.
218 For example, it is not possible to mount both the
222 controllers against one hierarchy, and to mount the
224 controller alone against another hierarchy.
225 It is possible to create multiple mount with exactly
226 the same set of comounted controllers.
227 However, in this case all that results is multiple mount points
228 providing a view of the same hierarchy.
230 Note that on many systems, the v1 controllers are automatically mounted under
234 automatically creates such mounts.
236 .SS Unmounting v1 controllers
237 A mounted cgroup filesystem can be unmounted using the
239 command, as in the following example:
243 umount /sys/fs/cgroup/pids
247 .IR "But note well" :
248 a cgroup filesystem is unmounted only if it is not busy,
249 that is, it has no child cgroups.
250 If this is not the case, then the only effect of the
252 is to make the mount invisible.
253 Thus, to ensure that the mount is really removed,
254 one must first remove all child cgroups,
255 which in turn can be done only after all member processes
256 have been moved from those cgroups to the root cgroup.
258 .SS Cgroups version 1 controllers
259 Each of the cgroups version 1 controllers is governed
260 by a kernel configuration option (listed below).
261 Additionally, the availability of the cgroups feature is governed by the
263 kernel configuration option.
265 .IR cpu " (since Linux 2.6.24; " \fBCONFIG_CGROUP_SCHED\fP )
266 Cgroups can be guaranteed a minimum number of "CPU shares"
267 when a system is busy.
268 This does not limit a cgroup's CPU usage if the CPUs are not busy.
269 For further information, see
270 .IR Documentation/scheduler/sched\-design\-CFS.rst
272 .IR Documentation/scheduler/sched\-design\-CFS.txt
273 in Linux 5.2 and earlier).
276 this controller was extended to provide CPU "bandwidth" control.
277 If the kernel is configured with
278 .BR CONFIG_CFS_BANDWIDTH ,
279 then within each scheduling period
280 (defined via a file in the cgroup directory), it is possible to define
281 an upper limit on the CPU time allocated to the processes in a cgroup.
282 This upper limit applies even if there is no other competition for the CPU.
283 Further information can be found in the kernel source file
284 .IR Documentation/scheduler/sched\-bwc.rst
286 .IR Documentation/scheduler/sched\-bwc.txt
287 in Linux 5.2 and earlier).
289 .IR cpuacct " (since Linux 2.6.24; " \fBCONFIG_CGROUP_CPUACCT\fP )
290 This provides accounting for CPU usage by groups of processes.
292 Further information can be found in the kernel source file
293 .IR Documentation/admin\-guide/cgroup\-v1/cpuacct.rst
295 .IR Documentation/cgroup\-v1/cpuacct.txt
296 in Linux 5.2 and earlier).
298 .IR cpuset " (since Linux 2.6.24; " \fBCONFIG_CPUSETS\fP )
299 This cgroup can be used to bind the processes in a cgroup to
300 a specified set of CPUs and NUMA nodes.
302 Further information can be found in the kernel source file
303 .IR Documentation/admin\-guide/cgroup\-v1/cpusets.rst
305 .IR Documentation/cgroup\-v1/cpusets.txt
306 in Linux 5.2 and earlier).
309 .IR memory " (since Linux 2.6.25; " \fBCONFIG_MEMCG\fP )
310 The memory controller supports reporting and limiting of process memory, kernel
311 memory, and swap used by cgroups.
313 Further information can be found in the kernel source file
314 .IR Documentation/admin\-guide/cgroup\-v1/memory.rst
316 .IR Documentation/cgroup\-v1/memory.txt
317 in Linux 5.2 and earlier).
319 .IR devices " (since Linux 2.6.26; " \fBCONFIG_CGROUP_DEVICE\fP )
320 This supports controlling which processes may create (mknod) devices as
321 well as open them for reading or writing.
322 The policies may be specified as allow-lists and deny-lists.
323 Hierarchy is enforced, so new rules must not
324 violate existing rules for the target or ancestor cgroups.
326 Further information can be found in the kernel source file
327 .IR Documentation/admin\-guide/cgroup\-v1/devices.rst
329 .IR Documentation/cgroup\-v1/devices.txt
330 in Linux 5.2 and earlier).
332 .IR freezer " (since Linux 2.6.28; " \fBCONFIG_CGROUP_FREEZER\fP )
335 cgroup can suspend and restore (resume) all processes in a cgroup.
338 also causes its children, for example, processes in
342 Further information can be found in the kernel source file
343 .IR Documentation/admin\-guide/cgroup\-v1/freezer\-subsystem.rst
345 .IR Documentation/cgroup\-v1/freezer\-subsystem.txt
346 in Linux 5.2 and earlier).
348 .IR net_cls " (since Linux 2.6.29; " \fBCONFIG_CGROUP_NET_CLASSID\fP )
349 This places a classid, specified for the cgroup, on network packets
351 These classids can then be used in firewall rules,
352 as well as used to shape traffic using
354 This applies only to packets
355 leaving the cgroup, not to traffic arriving at the cgroup.
357 Further information can be found in the kernel source file
358 .IR Documentation/admin\-guide/cgroup\-v1/net_cls.rst
360 .IR Documentation/cgroup\-v1/net_cls.txt
361 in Linux 5.2 and earlier).
363 .IR blkio " (since Linux 2.6.33; " \fBCONFIG_BLK_CGROUP\fP )
366 cgroup controls and limits access to specified block devices by
367 applying IO control in the form of throttling and upper limits against leaf
368 nodes and intermediate nodes in the storage hierarchy.
370 Two policies are available.
371 The first is a proportional-weight time-based division
372 of disk implemented with CFQ.
373 This is in effect for leaf nodes using CFQ.
374 The second is a throttling policy which specifies
375 upper I/O rate limits on a device.
377 Further information can be found in the kernel source file
378 .IR Documentation/admin\-guide/cgroup\-v1/blkio\-controller.rst
380 .IR Documentation/cgroup\-v1/blkio\-controller.txt
381 in Linux 5.2 and earlier).
383 .IR perf_event " (since Linux 2.6.39; " \fBCONFIG_CGROUP_PERF\fP )
384 This controller allows
386 monitoring of the set of processes grouped in a cgroup.
388 Further information can be found in the kernel source files
390 .IR net_prio " (since Linux 3.3; " \fBCONFIG_CGROUP_NET_PRIO\fP )
391 This allows priorities to be specified, per network interface, for cgroups.
393 Further information can be found in the kernel source file
394 .IR Documentation/admin\-guide/cgroup\-v1/net_prio.rst
396 .IR Documentation/cgroup\-v1/net_prio.txt
397 in Linux 5.2 and earlier).
399 .IR hugetlb " (since Linux 3.5; " \fBCONFIG_CGROUP_HUGETLB\fP )
400 This supports limiting the use of huge pages by cgroups.
402 Further information can be found in the kernel source file
403 .IR Documentation/admin\-guide/cgroup\-v1/hugetlb.rst
405 .IR Documentation/cgroup\-v1/hugetlb.txt
406 in Linux 5.2 and earlier).
408 .IR pids " (since Linux 4.3; " \fBCONFIG_CGROUP_PIDS\fP )
409 This controller permits limiting the number of process that may be created
410 in a cgroup (and its descendants).
412 Further information can be found in the kernel source file
413 .IR Documentation/admin\-guide/cgroup\-v1/pids.rst
415 .IR Documentation/cgroup\-v1/pids.txt
416 in Linux 5.2 and earlier).
418 .IR rdma " (since Linux 4.11; " \fBCONFIG_CGROUP_RDMA\fP )
419 The RDMA controller permits limiting the use of
420 RDMA/IB-specific resources per cgroup.
422 Further information can be found in the kernel source file
423 .IR Documentation/admin\-guide/cgroup\-v1/rdma.rst
425 .IR Documentation/cgroup\-v1/rdma.txt
426 in Linux 5.2 and earlier).
428 .SS Creating cgroups and moving processes
429 A cgroup filesystem initially contains a single root cgroup, '/',
430 which all processes belong to.
431 A new cgroup is created by creating a directory in the cgroup filesystem:
435 mkdir /sys/fs/cgroup/cpu/cg1
439 This creates a new empty cgroup.
441 A process may be moved to this cgroup by writing its PID into the cgroup's
447 echo $$ > /sys/fs/cgroup/cpu/cg1/cgroup.procs
451 Only one PID at a time should be written to this file.
453 Writing the value 0 to a
455 file causes the writing process to be moved to the corresponding cgroup.
457 When writing a PID into the
459 all threads in the process are moved into the new cgroup at once.
461 Within a hierarchy, a process can be a member of exactly one cgroup.
462 Writing a process's PID to a
464 file automatically removes it from the cgroup of
465 which it was previously a member.
469 file can be read to obtain a list of the processes that are
471 The returned list of PIDs is not guaranteed to be in order.
472 Nor is it guaranteed to be free of duplicates.
473 (For example, a PID may be recycled while reading from the list.)
475 In cgroups v1, an individual thread can be moved to
476 another cgroup by writing its thread ID
477 (i.e., the kernel thread ID returned by
483 file in a cgroup directory.
484 This file can be read to discover the set of threads
485 that are members of the cgroup.
489 it must first have no child cgroups and contain no (nonzombie) processes.
490 So long as that is the case, one can simply
491 remove the corresponding directory pathname.
492 Note that files in a cgroup directory cannot and need not be
495 .SS Cgroups v1 release notification
496 Two files can be used to determine whether the kernel provides
497 notifications when a cgroup becomes empty.
498 A cgroup is considered to be empty when it contains no child
499 cgroups and no member processes.
501 A special file in the root directory of each cgroup hierarchy,
503 can be used to register the pathname of a program that may be invoked when
504 a cgroup in the hierarchy becomes empty.
505 The pathname of the newly empty cgroup (relative to the cgroup mount point)
506 is provided as the sole command-line argument when the
511 program might remove the cgroup directory,
512 or perhaps repopulate it with a process.
514 The default value of the
516 file is empty, meaning that no release agent is invoked.
520 file can also be specified via a mount option when the
521 cgroup filesystem is mounted:
525 mount \-o release_agent=pathname ...
531 program is invoked when a particular cgroup becomes empty is determined
533 .IR notify_on_release
534 file in the corresponding cgroup directory.
535 If this file contains the value 0, then the
537 program is not invoked.
538 If it contains the value 1, the
541 The default value for this file in the root cgroup is 0.
542 At the time when a new cgroup is created,
543 the value in this file is inherited from the corresponding file
544 in the parent cgroup.
546 .SS Cgroup v1 named hierarchies
548 it is possible to mount a cgroup hierarchy that has no attached controllers:
552 mount \-t cgroup \-o none,name=somename none /some/mount/point
556 Multiple instances of such hierarchies can be mounted;
557 each hierarchy must have a unique name.
558 The only purpose of such hierarchies is to track processes.
559 (See the discussion of release notification below.)
560 An example of this is the
562 cgroup hierarchy that is used by
564 to track services and user sessions.
568 kernel boot option (described below) can be used to disable cgroup v1
569 named hierarchies, by specifying
570 .IR cgroup_no_v1=named .
572 .SH CGROUPS VERSION 2
574 all mounted controllers reside in a single unified hierarchy.
575 While (different) controllers may be simultaneously
576 mounted under the v1 and v2 hierarchies,
577 it is not possible to mount the same controller simultaneously
578 under both the v1 and the v2 hierarchies.
580 The new behaviors in cgroups v2 are summarized here,
581 and in some cases elaborated in the following subsections.
583 Cgroups v2 provides a unified hierarchy against
584 which all controllers are mounted.
586 "Internal" processes are not permitted.
587 With the exception of the root cgroup, processes may reside
588 only in leaf nodes (cgroups that do not themselves contain child cgroups).
589 The details are somewhat more subtle than this, and are described below.
591 Active cgroups must be specified via the files
592 .IR cgroup.controllers
594 .IR cgroup.subtree_control .
598 file has been removed.
600 .I cgroup.clone_children
601 file that is employed by the
603 controller has been removed.
605 An improved mechanism for notification of empty cgroups is provided by the
609 For more changes, see the
610 .IR Documentation/admin\-guide/cgroup\-v2.rst
611 file in the kernel source
613 .IR Documentation/cgroup\-v2.txt
614 in Linux 4.17 and earlier).
617 Some of the new behaviors listed above saw subsequent modification with
618 the addition in Linux 4.14 of "thread mode" (described below).
620 .SS Cgroups v2 unified hierarchy
621 In cgroups v1, the ability to mount different controllers
622 against different hierarchies was intended to allow great flexibility
623 for application design.
625 the flexibility turned out to be less useful than expected,
626 and in many cases added complexity.
627 Therefore, in cgroups v2,
628 all available controllers are mounted against a single hierarchy.
629 The available controllers are automatically mounted,
630 meaning that it is not necessary (or possible) to specify the controllers
631 when mounting the cgroup v2 filesystem using a command such as the following:
635 mount \-t cgroup2 none /mnt/cgroup2
639 A cgroup v2 controller is available only if it is not currently in use
640 via a mount against a cgroup v1 hierarchy.
641 Or, to put things another way, it is not possible to employ
642 the same controller against both a v1 hierarchy and the unified v2 hierarchy.
643 This means that it may be necessary first to unmount a v1 controller
644 (as described above) before that controller is available in v2.
647 makes heavy use of some v1 controllers by default,
648 it can in some cases be simpler to boot the system with
649 selected v1 controllers disabled.
650 To do this, specify the
651 .IR cgroup_no_v1=list
652 option on the kernel boot command line;
654 is a comma-separated list of the names of the controllers to disable,
657 to disable all v1 controllers.
658 (This situation is correctly handled by
660 which falls back to operating without the specified controllers.)
662 Note that on many modern systems,
664 automatically mounts the
667 .I /sys/fs/cgroup/unified
668 during the boot process.
670 .SS Cgroups v2 mount options
671 The following options
673 can be specified when mounting the group v2 filesystem:
675 .IR nsdelegate " (since Linux 4.15)"
676 Treat cgroup namespaces as delegation boundaries.
677 For details, see below.
679 .IR memory_localevents " (since Linux 5.2)"
680 .\" commit 9852ae3fe5293264f01c49f2571ef7688f7823ce
683 should show statistics only for the cgroup itself,
684 and not for any descendant cgroups.
685 This was the behavior before Linux 5.2.
686 Starting in Linux 5.2,
687 the default behavior is to include statistics for descendant cgroups in
689 and this mount option can be used to revert to the legacy behavior.
690 This option is system wide and can be set on mount or
691 modified through remount only from the initial mount namespace;
692 it is silently ignored in noninitial namespaces.
694 .SS Cgroups v2 controllers
695 The following controllers, documented in the kernel source file
696 .IR Documentation/admin\-guide/cgroup\-v2.rst
698 .IR Documentation/cgroup\-v2.txt
699 in Linux 4.17 and earlier),
700 are supported in cgroups version 2:
702 .IR cpu " (since Linux 4.15)"
703 This is the successor to the version 1
709 .IR cpuset " (since Linux 5.0)"
710 This is the successor of the version 1
714 .IR freezer " (since Linux 5.2)"
715 .\" commit 76f969e8948d82e78e1bc4beb6b9465908e74873
716 This is the successor of the version 1
720 .IR hugetlb " (since Linux 5.6)"
721 This is the successor of the version 1
725 .IR io " (since Linux 4.5)"
726 This is the successor of the version 1
730 .IR memory " (since Linux 4.5)"
731 This is the successor of the version 1
735 .IR perf_event " (since Linux 4.11)"
736 This is the same as the version 1
740 .IR pids " (since Linux 4.5)"
741 This is the same as the version 1
745 .IR rdma " (since Linux 4.11)"
746 This is the same as the version 1
750 There is no direct equivalent of the
754 controllers from cgroups version 1.
755 Instead, support has been added to
757 to allow eBPF filters that hook on cgroup v2 pathnames to make decisions
758 about network traffic on a per-cgroup basis.
762 controller provides no interface files;
763 instead, device control is gated by attaching an eBPF
764 .RB ( BPF_CGROUP_DEVICE )
765 program to a v2 cgroup.
767 .SS Cgroups v2 subtree control
768 Each cgroup in the v2 hierarchy contains the following two files:
770 .IR cgroup.controllers
771 This read-only file exposes a list of the controllers that are
774 The contents of this file match the contents of the
775 .I cgroup.subtree_control
776 file in the parent cgroup.
778 .I cgroup.subtree_control
779 This is a list of controllers that are
783 The set of controllers in this file is a subset of the set in the
784 .IR cgroup.controllers
786 The set of active controllers is modified by writing strings to this file
787 containing space-delimited controller names,
788 each preceded by '+' (to enable a controller)
789 or '\-' (to disable a controller), as in the following example:
793 echo \(aq+pids \-memory\(aq > x/y/cgroup.subtree_control
797 An attempt to enable a controller
798 that is not present in
799 .I cgroup.controllers
802 error when writing to the
803 .I cgroup.subtree_control
806 Because the list of controllers in
807 .I cgroup.subtree_control
809 .IR cgroup.controllers ,
810 a controller that has been disabled in one cgroup in the hierarchy
811 can never be re-enabled in the subtree below that cgroup.
814 .I cgroup.subtree_control
815 file determines the set of controllers that are exercised in the
818 When a controller (e.g.,
821 .I cgroup.subtree_control
822 file of a parent cgroup,
823 then the corresponding controller-interface files (e.g.,
825 are automatically created in the children of that cgroup
826 and can be used to exert resource control in the child cgroups.
828 .SS Cgroups v2 """no internal processes""" rule
829 Cgroups v2 enforces a so-called "no internal processes" rule.
830 Roughly speaking, this rule means that,
831 with the exception of the root cgroup, processes may reside
832 only in leaf nodes (cgroups that do not themselves contain child cgroups).
833 This avoids the need to decide how to partition resources between
834 processes which are members of cgroup A and processes in child cgroups of A.
836 For instance, if cgroup
838 exists, then a process may reside in
842 This is to avoid an ambiguity in cgroups v1
843 with respect to the delegation of resources between processes in
845 and its child cgroups.
846 The recommended approach in cgroups v2 is to create a subdirectory called
848 for any nonleaf cgroup which should contain processes, but no child cgroups.
849 Thus, processes which previously would have gone into
853 This has the advantage of making explicit
854 the relationship between processes in
860 The "no internal processes" rule is in fact more subtle than stated above.
861 More precisely, the rule is that a (nonroot) cgroup can't both
862 (1) have member processes, and
863 (2) distribute resources into child cgroups\(emthat is, have a nonempty
864 .I cgroup.subtree_control
868 possible for a cgroup to have both member processes and child cgroups,
869 but before controllers can be enabled for that cgroup,
870 the member processes must be moved out of the cgroup
871 (e.g., perhaps into the child cgroups).
873 With the Linux 4.14 addition of "thread mode" (described below),
874 the "no internal processes" rule has been relaxed in some cases.
876 .SS Cgroups v2 cgroup.events file
877 Each nonroot cgroup in the v2 hierarchy contains a read-only file,
879 whose contents are key-value pairs
880 (delimited by newline characters, with the key and value separated by spaces)
881 providing state information about the cgroup:
885 $ \fBcat mygrp/cgroup.events\fP
891 The following keys may appear in this file:
894 The value of this key is either 1,
895 if this cgroup or any of its descendants has member processes,
898 .IR frozen " (since Linux 5.2)"
899 .\" commit 76f969e8948d82e78e1bc4beb6b9465908e7487
900 The value of this key is 1 if this cgroup is currently frozen,
905 file can be monitored, in order to receive notification when the value of
906 one of its keys changes.
907 Such monitoring can be done using
909 which notifies changes as
913 which notifies changes by returning the
921 .SS Cgroup v2 release notification
922 Cgroups v2 provides a new mechanism for obtaining notification
923 when a cgroup becomes empty.
927 .IR notify_on_release
928 files are removed, and replaced by the
933 This key either has the value 0,
934 meaning that the cgroup (and its descendants)
935 contain no (nonzombie) member processes,
936 or 1, meaning that the cgroup (or one of its descendants)
937 contains member processes.
939 The cgroups v2 release-notification mechanism
940 offers the following advantages over the cgroups v1
944 It allows for cheaper notification,
945 since a single process can monitor multiple
947 files (using the techniques described earlier).
948 By contrast, the cgroups v1 mechanism requires the expense of creating
949 a process for each notification.
951 Notification for different cgroup subhierarchies can be delegated
952 to different processes.
953 By contrast, the cgroups v1 mechanism allows only one release agent
954 for an entire hierarchy.
956 .SS Cgroups v2 cgroup.stat file
957 .\" commit ec39225cca42c05ac36853d11d28f877fde5c42e
958 Each cgroup in the v2 hierarchy contains a read-only
960 file (first introduced in Linux 4.14)
961 that consists of lines containing key-value pairs.
962 The following keys currently appear in this file:
965 This is the total number of visible (i.e., living) descendant cgroups
966 underneath this cgroup.
968 .I nr_dying_descendants
969 This is the total number of dying descendant cgroups
970 underneath this cgroup.
971 A cgroup enters the dying state after being deleted.
972 It remains in that state for an undefined period
973 (which will depend on system load)
974 while resources are freed before the cgroup is destroyed.
975 Note that the presence of some cgroups in the dying state is normal,
976 and is not indicative of any problem.
978 A process can't be made a member of a dying cgroup,
979 and a dying cgroup can't be brought back to life.
981 .SS Limiting the number of descendant cgroups
982 Each cgroup in the v2 hierarchy contains the following files,
983 which can be used to view and set limits on the number
984 of descendant cgroups under that cgroup:
986 .IR cgroup.max.depth " (since Linux 4.14)"
987 .\" commit 1a926e0bbab83bae8207d05a533173425e0496d1
988 This file defines a limit on the depth of nesting of descendant cgroups.
989 A value of 0 in this file means that no descendant cgroups can be created.
990 An attempt to create a descendant whose nesting level exceeds
998 to this file means that no limit is imposed.
999 The default value in this file is
1002 .IR cgroup.max.descendants " (since Linux 4.14)"
1003 .\" commit 1a926e0bbab83bae8207d05a533173425e0496d1
1004 This file defines a limit on the number of live descendant cgroups that
1005 this cgroup may have.
1006 An attempt to create more descendants than allowed by the limit fails
1008 fails with the error
1013 to this file means that no limit is imposed.
1014 The default value in this file is
1017 .SH CGROUPS DELEGATION: DELEGATING A HIERARCHY TO A LESS PRIVILEGED USER
1018 In the context of cgroups,
1019 delegation means passing management of some subtree
1020 of the cgroup hierarchy to a nonprivileged user.
1021 Cgroups v1 provides support for delegation based on file permissions
1022 in the cgroup hierarchy but with less strict containment rules than v2
1024 Cgroups v2 supports delegation with containment by explicit design.
1025 The focus of the discussion in this section is on delegation in cgroups v2,
1026 with some differences for cgroups v1 noted along the way.
1028 Some terminology is required in order to describe delegation.
1031 is a privileged user (i.e., root) who owns a parent cgroup.
1034 is a nonprivileged user who will be granted the permissions needed
1035 to manage some subhierarchy under that parent cgroup,
1037 .IR "delegated subtree" .
1039 To perform delegation,
1040 the delegater makes certain directories and files writable by the delegatee,
1041 typically by changing the ownership of the objects to be the user ID
1043 Assuming that we want to delegate the hierarchy rooted at (say)
1045 and that there are not yet any child cgroups under that cgroup,
1046 the ownership of the following is changed to the user ID of the delegatee:
1049 Changing the ownership of the root of the subtree means that any new
1050 cgroups created under the subtree (and the files they contain)
1051 will also be owned by the delegatee.
1053 .IR /dlgt_grp/cgroup.procs
1054 Changing the ownership of this file means that the delegatee
1055 can move processes into the root of the delegated subtree.
1057 .IR /dlgt_grp/cgroup.subtree_control " (cgroups v2 only)"
1058 Changing the ownership of this file means that the delegatee
1059 can enable controllers (that are present in
1060 .IR /dlgt_grp/cgroup.controllers )
1061 in order to further redistribute resources at lower levels in the subtree.
1062 (As an alternative to changing the ownership of this file,
1063 the delegater might instead add selected controllers to this file.)
1065 .IR /dlgt_grp/cgroup.threads " (cgroups v2 only)"
1066 Changing the ownership of this file is necessary if a threaded subtree
1067 is being delegated (see the description of "thread mode", below).
1068 This permits the delegatee to write thread IDs to the file.
1069 (The ownership of this file can also be changed when delegating
1070 a domain subtree, but currently this serves no purpose,
1071 since, as described below, it is not possible to move a thread between
1072 domain cgroups by writing its thread ID to the
1076 In cgroups v1, the corresponding file that should instead be delegated is the
1080 The delegater should
1082 change the ownership of any of the controller interfaces files (e.g.,
1087 Those files are used from the next level above the delegated subtree
1088 in order to distribute resources into the subtree,
1089 and the delegatee should not have permission to change
1090 the resources that are distributed into the delegated subtree.
1092 See also the discussion of the
1093 .IR /sys/kernel/cgroup/delegate
1094 file in NOTES for information about further delegatable files in cgroups v2.
1096 After the aforementioned steps have been performed,
1097 the delegatee can create child cgroups within the delegated subtree
1098 (the cgroup subdirectories and the files they contain
1099 will be owned by the delegatee)
1100 and move processes between cgroups in the subtree.
1101 If some controllers are present in
1102 .IR dlgt_grp/cgroup.subtree_control ,
1103 or the ownership of that file was passed to the delegatee,
1104 the delegatee can also control the further redistribution
1105 of the corresponding resources into the delegated subtree.
1107 .SS Cgroups v2 delegation: nsdelegate and cgroup namespaces
1108 Starting with Linux 4.13,
1109 .\" commit 5136f6365ce3eace5a926e10f16ed2a233db5ba9
1110 there is a second way to perform cgroup delegation in the cgroups v2 hierarchy.
1111 This is done by mounting or remounting the cgroup v2 filesystem with the
1114 For example, if the cgroup v2 filesystem has already been mounted,
1115 we can remount it with the
1121 mount \-t cgroup2 \-o remount,nsdelegate \e
1122 none /sys/fs/cgroup/unified
1126 .\" Alternatively, we could boot the kernel with the options:
1128 .\" cgroup_no_v1=all systemd.legacy_systemd_cgroup_controller
1130 .\" The effect of the latter option is to prevent systemd from employing
1131 .\" its "hybrid" cgroup mode, where it tries to make use of cgroups v2.
1133 The effect of this mount option is to cause cgroup namespaces
1134 to automatically become delegation boundaries.
1136 the following restrictions apply for processes inside the cgroup namespace:
1138 Writes to controller interface files in the root directory of the namespace
1139 will fail with the error
1141 Processes inside the cgroup namespace can still write to delegatable
1142 files in the root directory of the cgroup namespace such as
1145 .IR cgroup.subtree_control ,
1146 and can create subhierarchy underneath the root directory.
1148 Attempts to migrate processes across the namespace boundary are denied
1151 Processes inside the cgroup namespace can still
1152 (subject to the containment rules described below)
1153 move processes between cgroups
1155 the subhierarchy under the namespace root.
1157 The ability to define cgroup namespaces as delegation boundaries
1158 makes cgroup namespaces more useful.
1159 To understand why, suppose that we already have one cgroup hierarchy
1160 that has been delegated to a nonprivileged user,
1162 using the older delegation technique described above.
1163 Suppose further that
1165 wanted to further delegate a subhierarchy
1166 under the existing delegated hierarchy.
1167 (For example, the delegated hierarchy might be associated with
1168 an unprivileged container run by
1170 Even if a cgroup namespace was employed,
1171 because both hierarchies are owned by the unprivileged user
1173 the following illegitimate actions could be performed:
1175 A process in the inferior hierarchy could change the
1176 resource controller settings in the root directory of that hierarchy.
1177 (These resource controller settings are intended to allow control to
1178 be exercised from the
1181 a process inside the child cgroup should not be allowed to modify them.)
1183 A process inside the inferior hierarchy could move processes
1184 into and out of the inferior hierarchy if the cgroups in the
1185 superior hierarchy were somehow visible.
1189 mount option prevents both of these possibilities.
1193 mount option only has an effect when performed in
1194 the initial mount namespace;
1195 in other mount namespaces, the option is silently ignored.
1200 automatically mounts the cgroup v2 filesystem.
1201 In order to experiment with the
1203 operation, it may be useful to boot the kernel with
1204 the following command-line options:
1208 cgroup_no_v1=all systemd.legacy_systemd_cgroup_controller
1212 These options cause the kernel to boot with the cgroups v1 controllers
1213 disabled (meaning that the controllers are available in the v2 hierarchy),
1216 not to mount and use the cgroup v2 hierarchy,
1217 so that the v2 hierarchy can be manually mounted
1218 with the desired options after boot-up.
1220 .SS Cgroup delegation containment rules
1222 .IR "containment rules"
1223 ensure that the delegatee can move processes between cgroups within the
1225 but can't move processes from outside the delegated subtree into
1226 the subtree or vice versa.
1227 A nonprivileged process (i.e., the delegatee) can write the PID of
1228 a "target" process into a
1230 file only if all of the following are true:
1232 The writer has write permission on the
1234 file in the destination cgroup.
1236 The writer has write permission on the
1238 file in the nearest common ancestor of the source and destination cgroups.
1239 Note that in some cases,
1240 the nearest common ancestor may be the source or destination cgroup itself.
1241 This requirement is not enforced for cgroups v1 hierarchies,
1242 with the consequence that containment in v1 is less strict than in v2.
1243 (For example, in cgroups v1 the user that owns two distinct
1244 delegated subhierarchies can move a process between the hierarchies.)
1246 If the cgroup v2 filesystem was mounted with the
1248 option, the writer must be able to see the source and destination cgroups
1249 from its cgroup namespace.
1252 the effective UID of the writer (i.e., the delegatee) matches the
1253 real user ID or the saved set-user-ID of the target process.
1255 .\" commit 576dd464505fc53d501bb94569db76f220104d28
1256 this requirement also applied in cgroups v2
1257 (This was a historical requirement inherited from cgroups v1
1258 that was later deemed unnecessary,
1259 since the other rules suffice for containment in cgroups v2.)
1262 one consequence of these delegation containment rules is that the
1263 unprivileged delegatee can't place the first process into
1264 the delegated subtree;
1265 instead, the delegater must place the first process
1266 (a process owned by the delegatee) into the delegated subtree.
1268 .SH CGROUPS VERSION 2 THREAD MODE
1269 Among the restrictions imposed by cgroups v2 that were not present
1270 in cgroups v1 are the following:
1272 .IR "No thread-granularity control" :
1273 all of the threads of a process must be in the same cgroup.
1275 .IR "No internal processes" :
1276 a cgroup can't both have member processes and
1277 exercise controllers on child cgroups.
1279 Both of these restrictions were added because
1280 the lack of these restrictions had caused problems
1282 In particular, the cgroups v1 ability to allow thread-level granularity
1283 for cgroup membership made no sense for some controllers.
1284 (A notable example was the
1286 controller: since threads share an address space,
1287 it made no sense to split threads across different
1291 Notwithstanding the initial design decision in cgroups v2,
1292 there were use cases for certain controllers, notably the
1295 for which thread-level granularity of control was meaningful and useful.
1296 To accommodate such use cases, Linux 4.14 added
1300 Thread mode allows the following:
1303 .IR "threaded subtrees"
1304 in which the threads of a process may
1305 be spread across cgroups inside the tree.
1306 (A threaded subtree may contain multiple multithreaded processes.)
1309 .IR "threaded controllers",
1310 which can distribute resources across the cgroups in a threaded subtree.
1312 A relaxation of the "no internal processes rule",
1313 so that, within a threaded subtree,
1314 a cgroup can both contain member threads and
1315 exercise resource control over child cgroups.
1317 With the addition of thread mode,
1318 each nonroot cgroup now contains a new file,
1320 that exposes, and in some circumstances can be used to change,
1321 the "type" of a cgroup.
1322 This file contains one of the following type values:
1325 This is a normal v2 cgroup that provides process-granularity control.
1326 If a process is a member of this cgroup,
1327 then all threads of the process are (by definition) in the same cgroup.
1328 This is the default cgroup type,
1329 and provides the same behavior that was provided for
1330 cgroups in the initial cgroups v2 implementation.
1333 This cgroup is a member of a threaded subtree.
1334 Threads can be added to this cgroup,
1335 and controllers can be enabled for the cgroup.
1337 .I "domain threaded"
1338 This is a domain cgroup that serves as the root of a threaded subtree.
1339 This cgroup type is also known as "threaded root".
1342 This is a cgroup inside a threaded subtree
1343 that is in an "invalid" state.
1344 Processes can't be added to the cgroup,
1345 and controllers can't be enabled for the cgroup.
1346 The only thing that can be done with this cgroup (other than deleting it)
1347 is to convert it to a
1349 cgroup by writing the string
1355 The rationale for the existence of this "interim" type
1356 during the creation of a threaded subtree
1357 (rather than the kernel simply immediately converting all cgroups
1358 under the threaded root to the type
1361 possible future extensions to the thread mode model
1363 .SS Threaded versus domain controllers
1364 With the addition of threads mode,
1365 cgroups v2 now distinguishes two types of resource controllers:
1368 .\" In the kernel source, look for ".threaded[ \t]*= true" in
1369 .\" initializations of struct cgroup_subsys
1370 controllers: these controllers support thread-granularity for
1371 resource control and can be enabled inside threaded subtrees,
1372 with the result that the corresponding controller-interface files
1373 appear inside the cgroups in the threaded subtree.
1374 As at Linux 4.19, the following controllers are threaded:
1381 controllers: these controllers support only process granularity
1382 for resource control.
1383 From the perspective of a domain controller,
1384 all threads of a process are always in the same cgroup.
1385 Domain controllers can't be enabled inside a threaded subtree.
1387 .SS Creating a threaded subtree
1388 There are two pathways that lead to the creation of a threaded subtree.
1389 The first pathway proceeds as follows:
1397 that currently has the type
1399 This has the following effects:
1402 The type of the cgroup
1407 The type of the parent cgroup,
1410 .IR "domain threaded" .
1411 The parent cgroup is the root of a threaded subtree
1412 (also known as the "threaded root").
1414 All other cgroups under
1416 that were not already of type
1418 (because they were inside already existing threaded subtrees
1419 under the new threaded root)
1420 are converted to type
1421 .IR "domain invalid" .
1422 Any subsequently created cgroups under
1424 will also have the type
1425 .IR "domain invalid" .
1431 .IR "domain invalid"
1434 in order to convert them to the type
1436 As a consequence of this step, all threads under the threaded root
1439 and the threaded subtree is now fully usable.
1440 The requirement to write
1442 to each of these cgroups is somewhat cumbersome,
1443 but allows for possible future extensions to the thread-mode model.
1445 The second way of creating a threaded subtree is as follows:
1447 In an existing cgroup,
1449 that currently has the type
1451 we (1) enable one or more threaded controllers and
1452 (2) make a process a member of
1454 (These two steps can be done in either order.)
1455 This has the following consequences:
1461 .IR "domain threaded" .
1463 All of the descendant cgroups of
1465 that were not already of type
1467 are converted to type
1468 .IR "domain invalid" .
1471 As before, we make the threaded subtree usable by writing the string
1474 .IR "domain invalid"
1477 in order to convert them to the type
1480 One of the consequences of the above pathways to creating a threaded subtree
1481 is that the threaded root cgroup can be a parent only to
1484 .IR "domain invalid" )
1486 The threaded root cgroup can't be a parent of a
1491 can't have a sibling that is a
1495 .SS Using a threaded subtree
1496 Within a threaded subtree, threaded controllers can be enabled
1497 in each subgroup whose type has been changed to
1499 upon doing so, the corresponding controller interface files
1500 appear in the children of that cgroup.
1502 A process can be moved into a threaded subtree by writing its PID to the
1504 file in one of the cgroups inside the tree.
1505 This has the effect of making all of the threads
1506 in the process members of the corresponding cgroup
1507 and makes the process a member of the threaded subtree.
1508 The threads of the process can then be spread across
1509 the threaded subtree by writing their thread IDs (see
1513 files in different cgroups inside the subtree.
1514 The threads of a process must all reside in the same threaded subtree.
1518 some containment rules apply when writing to the
1522 The writer must have write permission on the
1524 file in the destination cgroup.
1526 The writer must have write permission on the
1528 file in the common ancestor of the source and destination cgroups.
1530 the common ancestor may be the source or destination cgroup itself.)
1532 The source and destination cgroups must be in the same threaded subtree.
1533 (Outside a threaded subtree, an attempt to move a thread by writing
1534 its thread ID to the
1538 cgroup fails with the error
1543 file is present in each cgroup (including
1545 cgroups) and can be read in order to discover the set of threads
1546 that is present in the cgroup.
1547 The set of thread IDs obtained when reading this file
1548 is not guaranteed to be ordered or free of duplicates.
1552 file in the threaded root shows the PIDs of all processes
1553 that are members of the threaded subtree.
1556 files in the other cgroups in the subtree are not readable.
1558 Domain controllers can't be enabled in a threaded subtree;
1559 no controller-interface files appear inside the cgroups underneath the
1561 From the point of view of a domain controller,
1562 threaded subtrees are invisible:
1563 a multithreaded process inside a threaded subtree appears to a domain
1564 controller as a process that resides in the threaded root cgroup.
1566 Within a threaded subtree, the "no internal processes" rule does not apply:
1567 a cgroup can both contain member processes (or thread)
1568 and exercise controllers on child cgroups.
1570 .SS Rules for writing to cgroup.type and creating threaded subtrees
1571 A number of rules apply when writing to the
1578 In other words, the only explicit transition that is possible is to convert a
1583 The effect of writing
1585 depends on the current value in
1592 .IR "domain threaded" :
1593 start the creation of a threaded subtree
1594 (whose root is the parent of this cgroup) via
1595 the first of the pathways described above;
1597 .IR "domain\ invalid" :
1598 convert this cgroup (which is inside a threaded subtree) to a usable (i.e.,
1603 no effect (a "no-op").
1608 file if the parent's type is
1609 .IR "domain invalid" .
1610 In other words, the cgroups of a threaded subtree must be converted to the
1612 state in a top-down manner.
1614 There are also some constraints that must be satisfied
1615 in order to create a threaded subtree rooted at the cgroup
1618 There can be no member processes in the descendant cgroups of
1622 can itself have member processes.)
1624 No domain controllers may be enabled in
1626 .IR cgroup.subtree_control
1629 If any of the above constraints is violated, then an attempt to write
1633 file fails with the error
1636 .SS The """domain threaded""" cgroup type
1637 According to the pathways described above,
1638 the type of a cgroup can change to
1639 .IR "domain threaded"
1640 in either of the following cases:
1644 is written to a child cgroup.
1646 A threaded controller is enabled inside the cgroup and
1647 a process is made a member of the cgroup.
1650 .IR "domain threaded"
1653 can revert to the type
1655 if the above conditions no longer hold true\(emthat is, if all
1659 are removed and either
1661 no longer has threaded controllers enabled or
1662 no longer has member processes.
1665 .IR "domain threaded"
1672 .IR "domain invalid"
1675 that are not in lower-level threaded subtrees revert to the type
1678 The root cgroups in any lower-level threaded subtrees revert to the type
1679 .IR "domain threaded" .
1681 .SS Exceptions for the root cgroup
1682 The root cgroup of the v2 hierarchy is treated exceptionally:
1683 it can be the parent of both
1692 file of one of the children of the root cgroup, then
1694 The type of that cgroup becomes
1697 The type of any descendants of that cgroup that
1698 are not part of lower-level threaded subtrees changes to
1699 .IR "domain invalid" .
1701 Note that in this case, there is no cgroup whose type becomes
1702 .IR "domain threaded" .
1703 (Notionally, the root cgroup can be considered as the threaded root
1704 for the cgroup whose type was changed to
1707 The aim of this exceptional treatment for the root cgroup is to
1708 allow a threaded cgroup that employs the
1710 controller to be placed as high as possible in the hierarchy,
1711 so as to minimize the (small) cost of traversing the cgroup hierarchy.
1713 .SS The cgroups v2 """cpu""" controller and realtime threads
1714 As at Linux 4.19, the cgroups v2
1716 controller does not support control of realtime threads
1717 (specifically threads scheduled under any of the policies
1721 .BR SCHED_DEADLINE ;
1726 controller can be enabled in the root cgroup only
1727 if all realtime threads are in the root cgroup.
1728 (If there are realtime threads in nonroot cgroups, then a
1733 .I cgroup.subtree_control
1734 file fails with the error
1739 places certain realtime threads in nonroot cgroups in the v2 hierarchy.
1741 these threads must first be moved to the root cgroup before the
1743 controller can be enabled.
1746 The following errors can occur for
1750 An attempt to mount a cgroup version 1 filesystem specified neither the
1752 option (to mount a named hierarchy) nor a controller name (or
1755 A child process created via
1757 inherits its parent's cgroup memberships.
1758 A process's cgroup memberships are preserved across
1763 .B CLONE_INTO_CGROUP
1764 flag can be used to create a child process that begins its life in
1765 a different version 2 cgroup from the parent process.
1769 .IR /proc/cgroups " (since Linux 2.6.24)"
1770 This file contains information about the controllers
1771 that are compiled into the kernel.
1772 An example of the contents of this file (reformatted for readability)
1777 #subsys_name hierarchy num_cgroups enabled
1793 The fields in this file are, from left to right:
1796 The name of the controller.
1798 The unique ID of the cgroup hierarchy on which this controller is mounted.
1799 If multiple cgroups v1 controllers are bound to the same hierarchy,
1800 then each will show the same hierarchy ID in this field.
1801 The value in this field will be 0 if:
1804 the controller is not mounted on a cgroups v1 hierarchy;
1806 the controller is bound to the cgroups v2 single unified hierarchy; or
1808 the controller is disabled (see below).
1811 The number of control groups in this hierarchy using this controller.
1813 This field contains the value 1 if this controller is enabled,
1814 or 0 if it has been disabled (via the
1816 kernel command-line boot parameter).
1819 .IR /proc/[pid]/cgroup " (since Linux 2.6.24)"
1820 This file describes control groups to which the process
1821 with the corresponding PID belongs.
1822 The displayed information differs for
1823 cgroups version 1 and version 2 hierarchies.
1825 For each cgroup hierarchy of which the process is a member,
1826 there is one entry containing three colon-separated fields:
1830 hierarchy\-ID:controller\-list:cgroup\-path
1838 5:cpuacct,cpu,cpuset:/daemons
1842 The colon-separated fields are, from left to right:
1845 For cgroups version 1 hierarchies,
1846 this field contains a unique hierarchy ID number
1847 that can be matched to a hierarchy ID in
1849 For the cgroups version 2 hierarchy, this field contains the value 0.
1851 For cgroups version 1 hierarchies,
1852 this field contains a comma-separated list of the controllers
1853 bound to the hierarchy.
1854 For the cgroups version 2 hierarchy, this field is empty.
1856 This field contains the pathname of the control group in the hierarchy
1857 to which the process belongs.
1858 This pathname is relative to the mount point of the hierarchy.
1861 .SS /sys/kernel/cgroup files
1863 .IR /sys/kernel/cgroup/delegate " (since Linux 4.15)"
1864 .\" commit 01ee6cfb1483fe57c9cbd8e73817dfbf9bacffd3
1865 This file exports a list of the cgroups v2 files
1866 (one per line) that are delegatable
1867 (i.e., whose ownership should be changed to the user ID of the delegatee).
1868 In the future, the set of delegatable files may change or grow,
1869 and this file provides a way for the kernel to inform
1870 user-space applications of which files must be delegated.
1871 As at Linux 4.15, one sees the following when inspecting this file:
1875 $ \fBcat /sys/kernel/cgroup/delegate\fP
1877 cgroup.subtree_control
1882 .IR /sys/kernel/cgroup/features " (since Linux 4.15)"
1883 .\" commit 5f2e673405b742be64e7c3604ed4ed3ac14f35ce
1884 Over time, the set of cgroups v2 features that are provided by the
1885 kernel may change or grow,
1886 or some features may not be enabled by default.
1887 This file provides a way for user-space applications to discover what
1888 features the running kernel supports and has enabled.
1889 Features are listed one per line:
1893 $ \fBcat /sys/kernel/cgroup/features\fP
1899 The entries that can appear in this file are:
1902 .IR memory_localevents " (since Linux 5.2)"
1903 The kernel supports the
1904 .I memory_localevents
1907 .IR nsdelegate " (since Linux 4.15)"
1908 The kernel supports the
1915 .BR systemd\-cgls (1),
1916 .BR systemd\-cgtop (1),
1919 .BR perf_event_open (2),
1921 .BR cgroup_namespaces (7),
1925 .BR user_namespaces (7)
1927 The kernel source file
1928 .IR Documentation/admin\-guide/cgroup\-v2.rst .