Skip to main content

Module cgroup

Module cgroup 

Source
Available on crate feature memory only.
Expand description

Cgroup-aware memory limit and pressure detection.

Three signals, all container-first (what the kernel/OOM-killer act on, not host-wide used/total):

  • limit (memory.max): the hard ceiling – crossing it is an OOM-kill.
  • high (memory.high): the soft throttle – the kernel reclaims hard and throttles allocations here, BEFORE the OOM-kill. Shedding before it avoids a latency cliff.
  • PSI (memory.pressure some avg10): the earliest signal – the fraction of the last 10s in which a task stalled waiting on memory. It rises on reclaim/thrash before byte ratios cross a threshold.

Functions§

detect_memory_high
Soft throttle ceiling: cgroup v2 memory.high.
detect_memory_limit
Detect the memory limit for this process.
detect_memory_pressure
Detect THIS container’s own memory pressure as a 0.0-1.0+ usage fraction.
detect_memory_stall
Memory PSI stall fraction: cgroup v2 memory.pressure some avg10, as a 0.0-1.0 fraction (avg10 is the percentage of the last 10s in which at least one task stalled waiting on memory).