About the Control Group File System

cgroup functionality is mounted as a hierarchical file system in /sys/fs/cgroup.

The directory /sys/fs/cgroup is also called the root control group. The directory contents might look as follows::

ls /sys/fs/cgroup
cgroup.controllers      cpuset.mems.effective  memory.stat
cgroup.max.depth        cpu.stat               misc.capacity
cgroup.max.descendants  dev-hugepages.mount    sys-fs-fuse-connections.mount
cgroup.procs            dev-mqueue.mount       sys-kernel-config.mount
cgroup.stat             init.scope             sys-kernel-debug.mount
cgroup.subtree_control  io.pressure            sys-kernel-tracing.mount
cgroup.threads          io.stat                system.slice
cpu.pressure            memory.numa_stat       user.slice
cpuset.cpus.effective   memory.pressure
You can use the mkdir command to create cgroup subdirectories within the root control group. For example, you might create the following cgroup subdirectories:
  • /sys/fs/cgroup/MyGroups/

  • /sys/fs/cgroup/MyGroups/cgroup1

  • /sys/fs/cgroup/MyGroups/cgroup2

Note:

Best practice is to create child cgroups at least 2 levels deep inside the /sys/fs/cgroup. The examples in the preceding list follow this practice by using the first child group, MyGroups, as a parent that contains the different cgroups needed for the system.

Each cgroup in the hierarchy contains the following files:

cgroup.controllers

This read-only file lists the controllers available in the current cgroup. The contents of this file match the contents of the cgroup.subtree_control file in the parent cgroup.

cgroup.subtree_control

This file contains those controllers in the cgroup.controllers file that are enabled for the current cgroup's immediate child cgroups.

When a controller (for example, pids) is present in the cgroup.subtree_control file, the corresponding controller-interface files (for example, pids.max) are automatically created in the immediate children of the current cgroup.

For a sample procedure that creates child groups where you can implement resource management for an application, see Setting CPU Weight to Regulate Distribution of CPU Time.

To remove a cgroup, ensure that the cgroup doesn't contain other child groups, and then remove the directory. For example, to remove child group /sys/fs/cgroup/MyGroups/cgroup1 you can run the following command:.

sudo rmdir /sys/fs/cgroup/MyGroups/cgroup1