Skip to content

common: account for cgroup memory limits - #7

Closed
andyliuliming wants to merge 1 commit into
kdave:masterfrom
andyliuliming:fix-cgroup-memory-availability
Closed

common: account for cgroup memory limits#7
andyliuliming wants to merge 1 commit into
kdave:masterfrom
andyliuliming:fix-cgroup-memory-availability

Conversation

@andyliuliming

Copy link
Copy Markdown

Summary

Use the current cgroup's remaining memory when fstests runs in a memory-limited container instead of relying only on host-wide values from free(1).

The helper supports:

  • cgroup v2 memory.max and memory.current
  • cgroup v1 memory.limit_in_bytes and memory.usage_in_bytes
  • unlimited, malformed, unavailable, and non-cgroup environments through the existing host-memory fallback
  • a 64 MiB margin for the test process and runtime overhead

This prevents memory-heavy tests such as generic/551 from sizing their workload from memory that is not actually available inside the container.

Checks

  • bash -n common/rc
  • cgroup v1 finite limit/usage
  • cgroup v2 finite limit/usage
  • cgroup v2 unlimited (memory.max=max)
  • missing cgroup files

Memory-heavy tests currently use host-wide values from free(1). In a container, those values can be much larger than the memory available to the current cgroup and can cause avoidable OOM failures.

Read the remaining memory from cgroup v1 or v2 when available, keep a small runtime margin, and fall back to the host value for unlimited or unavailable cgroup data.

Signed-off-by: Liming Liu <andyliuliming@outlook.com>

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e3c7b420-3283-4416-967b-e6d92a7dd5c7
@andyliuliming
andyliuliming deleted the fix-cgroup-memory-availability branch August 12, 2026 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant