View cgroups of processes

A process belongs to a control group (cgroup). /proc/PID/cgroup records its cgroup path, and controllers plus controller-specific configuration files appear under the matching path in /sys/fs/cgroup/.

Procedure

  1. To view which cgroup a process belongs to, run the # cat /proc/<PID>/cgroup command:
    # cat /proc/2467/cgroup
    0::/system.slice/example.service

    The example output relates to a process of interest. In this case, it is a process identified by PID 2467, which belongs to the example.service unit. You can check if the process was placed in a correct control group as defined by the systemd unit file specifications.

  2. Display which controllers the cgroup uses:
    # cat /sys/fs/cgroup/system.slice/example.service/cgroup.controllers
    memory pids
  3. List configuration files and other cgroup files in the cgroup directory for the example.service cgroup:
    # ls /sys/fs/cgroup/system.slice/example.service/
    cgroup.controllers
    cgroup.events
    ...
    cpu.pressure
    cpu.stat
    io.pressure
    memory.current
    memory.events
    ...
    pids.current
    pids.events
    pids.max

    The version 1 hierarchy of cgroups uses a per-controller model. Therefore the output from the /proc/PID/cgroup file shows which cgroups under each controller the PID belongs to. You can find the cgroups under the controller directories at /sys/fs/cgroup/<controller_name>/.

    Refer to the /usr/share/doc/kernel-doc-<kernel_version>/Documentation/admin-guide/cgroup-v2.rst file (after installing the kernel-doc package) for more information.