Service memory accounting (cgroup v2)

Live RSS vs hard limit for a systemd service; current near max = imminent OOM

cat /sys/fs/cgroup/system.slice/<name>.service/memory.current /sys/fs/cgroup/system.slice/<name>.service/memory.max

tool
cgroups8 commands
tags
cgroupsmemoryperformancetroubleshooting

More cgroups commands

  • cat /sys/fs/cgroup/system.slice/<name>.service/memory.pressure

    PSI: time tasks stalled on memory reclaim; rising avg10 = thrashing before OOM

  • grep -E 'nr_throttled|throttled_usec' /sys/fs/cgroup/system.slice/<name>.service/cpu.stat

    Count and total usec a cgroup was CPU-throttled by cpu.max quota

  • cat /sys/fs/cgroup/system.slice/<name>.service/cpu.max # "max 100000" = unlimited; "50000 100000" = 0.5 core

    cpu.max is 'quota period' in usec; 'max' = no limit. note: prefer systemctl set-property

  • cat /sys/fs/cgroup/system.slice/<name>.service/io.pressure /sys/fs/cgroup/system.slice/<name>.service/io.stat

    PSI io stall plus per-major:minor rbytes/wbytes/rios; pin noisy disk neighbors

  • cat /sys/fs/cgroup/system.slice/<name>.service/cgroup.procs; systemctl status <name>.service | grep CGroup

    Every PID currently in the service slice; cross-check with systemctl status tree

all 8 cgroups commands