Skip to main content

Module cgroup

Module cgroup 

Source
Available on Linux only.
Expand description

Linux cgroup detection utilities.

Structsยง

CgroupEntry
An entry in /proc/self/cgroup
MemoryLimit
Represents a cgroup memory limit, with both ram and swap maximums if they exist. Fields should be None if a limit does not exist or when running on a platform without cgroup support (ie: non-Linux platforms).
Mountinfo
An entry in /proc/self/mountinfo

Functionsยง

detect_memory_limit
Returns the cgroup (v1 or v2) memory limit if it exists.
parse_proc_self_cgroup
Parses /proc/self/cgroup into a Vec<CgroupEntry>, if the file exists.
parse_proc_self_mountinfo
Parses /proc/self/mountinfo into vectors of Mountinfo objects, returning (v2_mounts, v1_mounts).
read_file_to_usize ๐Ÿ”’
read_v1_memory_limit ๐Ÿ”’
Finds the cgroup v1 and mountpoint combination containing the memory controller, and reads the memory limits within.
read_v2_memory_limit ๐Ÿ”’
Finds the mountpoint corresponding to the provided cgroup v2, and reads the memory limits within.