Skip to content

BUILD-1234: honor the cgroup v2 memory limit at the mount root - #4335

Open
TG0000 wants to merge 1 commit into
ItsNotRexed:mainfrom
TG0000:fix/cgroup-namespace-memory
Open

TG0000 wants to merge 1 commit into
ItsNotRexed:mainfrom
TG0000:fix/cgroup-namespace-memory

Conversation

@TG0000

@TG0000 TG0000 commented Nov 23, 2026

Copy link
Copy Markdown

Claimed as BUILD-1234 in the coordination issue.

What and why

In an isolated cgroup v2 namespace, the visible mount root can be a memory-limited cgroup. The kernel's namespace documentation describes that layout. After #4278, the large-module budget walker stops before /, so it overlooks that limit for both a process at 0::/ and its descendants. Read the mounted root once and keep the tightest available limit. An ordinary root with no memory limits keeps the existing behavior.

Tested

  • A synthetic root with a limit of 5,000 bytes and 3,000 in use returned UINT64_MAX on 03b09a08 and 2,000 bytes with this change.
  • Native Windows large_module_gate_test passed, including its threaded budget test. The same C++ suite also passed with the Linux-gated cgroup reader enabled against synthetic files under LLVM-MinGW 23.1.6. Live Linux namespace integration was outside this Windows test.
  • git diff --check passed. CPU only, no game files.

AI-assisted (OpenAI Codex).

@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Read 36aecce and tested the changed function on Windows 11, MSVC 14.51. The result is partial, because I have no Linux computer.

The changed lines are inside #if defined(__linux__). Thus the Windows build does not compile them. large_module_gate_test.exe prints large_module_gate: ok at this head and with the header from main 03b09a08.

To run the function, I compiled cgroup_memory_room with MSVC from a probe file outside the repository (cl /std:c++20 /EHsc /D__linux__). I used the header of this head and the header of main with the same hand-made folders.

case main 03b09a0 this head
path /user.slice/app.scope, parent limit 10000, 4000 used 6000 6000
the same, plus a limit of 5000 (3000 used) at the mount root 6000 2000
path /, limit 5000 (3000 used) at the mount root no limit 2000
path /, limit 5000 (9000 used) at the mount root no limit 0
path /, max at the mount root no limit no limit
path with a trailing slash 6000 6000
empty path (0::) no limit no limit
cgroup v1 line only no limit no limit

This head gives the values that the new CHECK lines expect. Main gives different values only in the cases with a limit at the mount root.

I did not test a Linux build or a real cgroup. I found no defect. AI-assisted.

@theswiss24

Copy link
Copy Markdown

Tested 36aecce1 natively on Linux: Ubuntu 24.04.5 (kernel 6.8.0-149, a QEMU VM), GCC 13, CMake 3.28, Ninja, Release: pass.

large_module_gate_test (built with --target large_module_gate_test) printed large_module_gate: ok, exit 0. On main 03b09a08, built the same way, it also passes (without the new case).

This host has a cgroup v2 mount (cgroup2fs), and the test ran in an ordinary session cgroup (0::/user.slice/user-1000.slice/session-….scope), not in an isolated cgroup namespace. So this checks the Linux-gated reader and the synthetic cases on a real Linux build, but not the live namespaced-root layout. CPU only, no game files.

Tested and written by Claude (Claude Code), posting from @theswiss24's account.

@tupacfan04

Copy link
Copy Markdown
Contributor

PASS. runtime/test/large_module_gate.h:69 reads the mount root via cgroup_root when rel == "/", and nothing above the root is read. A harness against the real header (MSVC, __linux__ path, synthetic files) confirms the tightest of leaf+root is used (1000), a process at 0::/ gets 1000, a limit in the directory above the mount root is ignored, and max/missing files give UINT64_MAX; the base header returns 2000/UINT64_MAX for the same cases. large_module_gate_test passes, compileall clean, merge clean.

Minor test gap: the repo test never combines a descendant limit with a root limit in one call (large_module_gate_test.cpp:139-148); the harness covers it and passes.

Approve. AI-assisted review, no game files, no GPU.

@sh1shu1

sh1shu1 commented Nov 23, 2026

Copy link
Copy Markdown

Tested 36aecce on NVIDIA RTX 4070 SUPER (driver 616.92), Windows 11 26200, MSVC 14.44, Vulkan SDK 1.4.363, RelWithDebInfo: pass, no regression against main 03b09a0.

  • ctest: 154/154 passed, same 9 skips as main 03b09a0
  • large_module_gate: 1/1
  • run_gpu_tests (LEONIDA_VK_VALIDATION=1): 164/210 native, 195/210 with LEONIDA_W64_EMULATE=1, 0 failed; identical to main 03b09a0
    AI-assisted (Claude Code, Claude Fable 5.1).

@AirKyzzZ

Copy link
Copy Markdown

Tested 36aecce1 on RTX 2060, NVIDIA 566.14, Windows 10 22H2 (19045), clang-cl 23.1.6 + SDK 10.0.26100, and Apple M3 Pro, macOS 27.0.1, Apple clang 17: pass.

Windows: builds, and large_module_gate passes (the cgroup reader is compiled out there). Full ctest shows the 2 known failures plus one winhttp_offline run that failed 3 HANDLE_CLOSING callback checks. This PR doesn't touch that test, and on main it then passed 100/100 with --repeat until-fail:100, so I'm counting it as a flake. To run the new cases I built large_module_gate_test.cpp on the Mac with -D__linux__: the whole cgroup block passes at this head, and with main's header it fails at line 143, the first mount-root CHECK. The only other failure in that build is line 108 (available_memory_bytes() > 0), and that's just macOS having no /proc/meminfo. AI-assisted.

@traeb0n

traeb0n commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 36aecce on NVIDIA GeForce RTX 5070, driver 621.01, Windows 11 Pro 26300, MSVC 14.44 RelWithDebInfo (scripts/build_runtime.ps1), Vulkan SDK 1.4.363, LEONIDA_VK_VALIDATION=1 for ctest, plus a code read: pass.

  • Full ctest -E loader -j 4: 150/150, 0 compiler warnings. large_module_gate (9.0 s, with its threaded budget test) and vk_pipeline_check_cli pass when run alone. On Windows the cgroup reader and its test are compiled out (#if defined(__linux__)). That means this run only shows the change doesn't affect the Windows build. The cgroup cases are covered by your MinGW run of the reader.

Code read of the walk, for rel = "/user.slice/app.scope":
"/user.slice/app.scope" → "/user.slice" (resize(slash)) → "/" (slash == 0 → resize(1)) → reads cgroup_root itself → break.

Each level is read once, the mount root last, and rel = "/" reads only the root. On an ordinary host the root cgroup has no memory.max, so the read fails and the room stays UINT64_MAX, the same as before. One existing quirk this doesn't change: a rel without a leading / gives cgroup_root + "foo" with no separator. The kernel always writes a leading / in 0::, so that never comes up in practice.

No game files. AI-assisted (Claude Code).

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built and ran large_module_gate_test at 36aecce11 on Windows 11: large_module_gate: ok, exit 0; git diff --check clean.

The gate reads the cgroup v2 memory limit at the mounted root (the container's own limit, not just the leaf path), and the added case covers that root. No blocking issue.

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.

8 participants