25.7. Viewing cgroups of processes
You can learn which control group (cgroup) a process belongs to. Then you can check the cgroup to find which controllers and controller-specific configurations it uses.
Procedure
To view which
cgroupa process belongs to, run the# cat proc/<PID>/cgroupcommand:# cat /proc/2467/cgroup 0::/system.slice/example.serviceThe example output relates to a process of interest. In this case, it is a process identified by
PID 2467, which belongs to theexample.serviceunit. You can check if the process was placed in a correct control group as defined by thesystemdunit file specifications.To display what controllers and configuration files the
cgroupuses, check thecgroupdirectory:# cat /sys/fs/cgroup/system.slice/example.service/cgroup.controllers memory pids # 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.maxThe version 1 hierarchy of
cgroupsuses a per-controller model. Therefore the output from the/proc/PID/cgroupfile shows, whichcgroupsunder each controller the PID belongs to. You can find thecgroupsunder the controller directories at/sys/fs/cgroup/<controller_name>/.Refer to the
/usr/share/doc/kernel-doc-<kernel_version>/Documentation/admin-guide/cgroup-v2.rstfile (after installing thekernel-docpackage) for more information.