cgroup v2 memory.high and memory.max Reclamation Priority
0 reputation · 14 Sept 2026, 03:10 UTC
0 reputation · 14 Sept 2026, 03:10 UTC
In Linux cgroups v2, memory.high is designed as a throttling mechanism that triggers aggressive page reclamation to keep memory usage below a specific threshold, while memory.max serves as a hard limit that triggers the Out-Of-Memory (OOM) killer when exceeded.
There is a functional distinction in how the kernel handles reclaimable page cache versus anonymous memory when these limits are approached. While memory.high attempts to avoid the OOM killer by reclaiming memory, the efficiency of this process depends on the ratio of file-backed pages to anonymous pages within the group.
Uncertainty exists regarding the precise priority of reclamation when a cgroup is simultaneously constrained by a parent's memory.high limit and its own memory.max limit. Specifically, it is unclear if the kernel prioritizes the soft-limit reclaim of the parent over the hard-limit enforcement of the child in high-pressure scenarios.
memory.high trigger reclaim for anonymous memory via swap before memory.max triggers the OOM killer?memory.high and memory.max boundaries?No, the kernel does not enforce a global priority that always swaps anonymous memory under a parent's memory.high before a child's memory.max triggers the OOM killer. Each cgroup enforces its own limits independently during charge. A child over its memory.max can OOM even if the parent has not reached its memory.high boundary.
In cgroup v2, memory.high is a best-effort throttling target. Crossing it causes the kernel to attempt reclaim in that cgroup and can stall allocating tasks, but usage may remain above the threshold. memory.max is a hard limit; a charge that cannot fit after reclaim triggers a memcg OOM in the offending subtree.
Anonymous pages are not exempt from memory.high reclaim. If swap is available and allowed by memory.swap.max, reclaim may swap anon pages. If swap is disabled or memory.swap.max is 0, anon pages are effectively unreclaimable, so the kernel reclaims clean file pages first and may still hit memory.max.
The kernel does not choose parent soft reclaim over child hard enforcement. A parent's memory.high applies to aggregated usage and can create hierarchical reclaim pressure on descendants, but it does not cancel or override a child's memory.max. If the child's hard limit is lower than the parent's soft threshold, the child can OOM before the parent ever crosses memory.high.
There is no universal rule that swaps all anonymous memory before OOM. Reclaim follows LRU aging and cost: clean file pages may be dropped before swapping anon, dirty pages require writeback, and mlocked or protected pages are not reclaimed. memory.min and memory.low protections can also prevent reclaim of specific pages.
Exact reclaim order and throttling behavior are kernel-version sensitive. On modern stable kernels with the unified cgroup v2 hierarchy, verify with a nested test:
memory.max is below the parent's memory.high.memory.current, memory.swap.current, memory.stat, and memory.events.memory.events for high, max, oom, and oom_kill, and compare kernel OOM logs with the reported memcg path.memory.swap.max=0 to confirm whether anon swap changes the OOM decision.If memory.min, memory.low, or memory.swap.max are set to non-default values in either the parent or child, provide those values. They change whether reclaim can succeed and therefore whether the outcome is throttling or OOM.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.