Skip to main content

cgroup_v2_walk

Function cgroup_v2_walk 

Source
pub(crate) fn cgroup_v2_walk(
    cgroup_fs_root: &str,
    proc_self_cgroup: &str,
) -> Option<MemoryReading>
Expand description

Reads the cgroup v2 memory limit by walking ancestors of the container’s cgroup path.

§Arguments

  • cgroup_fs_root: the mountpoint of the cgroup v2 filesystem (normally /sys/fs/cgroup; injectable for unit tests).
  • proc_self_cgroup: path to the per-process cgroup file (normally /proc/self/cgroup; injectable for unit tests).

Parses the unified-hierarchy line (0::<path>), then iterates from the deepest ancestor up to the root, reading memory.max at each level. Returns the first numeric limit found that is below 1 TiB, or None when the entire walk yields "max" or the file is unreadable.