8 About Control Groups

Control groups, referred to as cgroups, are an Oracle Linux kernel feature that organizes systemd services, and if required, individual processes (PIDs), into hierarchical groups for allocating system resources, such as CPU, memory, and I/O.

For example, if you need to divide CPU resource among three systemd services, myservice1.service, myservice2.service, and myservice3.service, in a ratio of 150:100:50, you can use the systemd tools to assign each service's corresponding cgroup a CPU weight that matches its target share.

Note:

systemd is responsible for creating and managing its cgroups in the /sys/fs/cgroup/ virtual file system. The systemd suite provides safe, high-level ways to configure cgroup resources, such as using drop-in files or the systemctl set-property command. Direct modification of systemd objects in the /sys/fs/cgroup/ virtual file system is not recommended.

By default, systemd creates a cgroup for the following:

  • Each systemd service set up on the host.

    For example, a server might have control group NetworkManager.service to group processes owned by the NetworkManager service, and control group firewalld.service to group processes owned by the firewalld service, and so on.

  • Each user (UID) on the host.

The cgroup functionality is mounted as a virtual file system under /sys/fs/cgroup. Each cgroup has a corresponding folder within /sys/fs/cgroup file system. For example, the cgroups created by systemd for the services it manages can be seen by running the command ls -l /sys/fs/cgroup/system.slice | grep ".service" as shown in the following sample code block:

ls -l /sys/fs/cgroup/system.slice | grep ".service"
...root root 0 Mar 22 10:47 atd.service
...root root 0 Mar 22 10:47 auditd.service
...root root 0 Mar 22 10:47 chronyd.service
...root root 0 Mar 22 10:47 crond.service
...root root 0 Mar 22 10:47 dbus-broker.service
...root root 0 Mar 22 10:47 dtprobed.service
...root root 0 Mar 22 10:47 firewalld.service
...root root 0 Mar 22 10:47 httpd.service
...

You can also create custom cgroups outside of the systemd branches, for example under a location such as /sys/fs/cgroup/MyGroups/, and assign process IDs (PIDs) to different cgroups according to the system needs. However, this approach should only be used for specific scenarios, such as temporary debugging or testing. For most use cases, we recommend using systemd to configure cgroups to ensure correct and persistent resource management.

Oracle Linux uses the control groups version 2 (cgroups v2) implementation. These groups provide a single control group hierarchy against which all resource controllers are mounted. In this hierarchy, you can obtain better proper coordination of resource uses across different resource controllers. This version is an improvement over cgroups v1 whose over flexibility prevented proper coordination of resource use among the system consumers.

Note that cgroups v1 is deprecated and is not available on Oracle Linux 10. The cgroups v2 functionality is enabled and mounted by default.

For more information about control groups, see the cgroups(7) and sysfs(5) manual pages.