test(libc): skip the failed heap commit check when the host overcommits #6310

Merged
eliyarson merged 2 commits from upstream-pr/6310 into main 2026-10-17 21:15:04 +00:00
eliyarson commented 2026-10-15 10:51:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by eliyarson on 2026-10-15T10:51:35Z.


What

guest_allocator_failures limits RLIMIT_DATA to 128 MiB and expects malloc(300 GiB) to fail with ENOMEM. A guest heap commit is mmap(MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, RW) over an existing PROT_NONE/MAP_NORESERVE arena reservation. Observed on Linux 7.2, a 300 GiB MAP_FIXED RW mapping over such a reservation succeeds under RLIMIT_DATA=128 MiB (the replaced pages are subtracted, so the limit is not charged), while a fresh 300 GiB RW mmap fails with ENOMEM. Only the overcommit heuristic (vm.overcommit_memory=0) or strict mode (2) can make the commit fail. On hosts that set vm.overcommit_memory=1 (kubelet/k3s sets it) the commit succeeds and the test reported malloc(300 GiB): succeeded despite RLIMIT_DATA.

Test only. When the 300 GiB commit succeeds, Linux now takes the skip path the other platforms already had, and the skip line prints the vm.overcommit_memory value. The remaining allocator checks still run and the test exits 0 when nothing failed, as GuestAmpr.cpp does for its partial skips. The RLIMIT_DATA setup is unchanged.

Tested

CachyOS, Linux 7.2.2-1-cachyos, vm.overcommit_memory=1: ctest -R guest_allocator_failures passes and prints skipped: the host can commit 300 GiB (vm.overcommit_memory=1), so the failed commit and arena release checks did not run. python3 tools/check_conventions.py --base origin/main passes. Not tested: the failing-commit path with vm.overcommit_memory=0 or 2; Windows; macOS.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4872085584 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6310). Originally posted by [eliyarson](https://github.com/eliyarson) on 2026-10-15T10:51:35Z. --- ### What `guest_allocator_failures` limits `RLIMIT_DATA` to 128 MiB and expects `malloc(300 GiB)` to fail with `ENOMEM`. A guest heap commit is `mmap(MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, RW)` over an existing `PROT_NONE`/`MAP_NORESERVE` arena reservation. Observed on Linux 7.2, a 300 GiB `MAP_FIXED` RW mapping over such a reservation succeeds under `RLIMIT_DATA=128 MiB` (the replaced pages are subtracted, so the limit is not charged), while a fresh 300 GiB RW `mmap` fails with `ENOMEM`. Only the overcommit heuristic (`vm.overcommit_memory=0`) or strict mode (`2`) can make the commit fail. On hosts that set `vm.overcommit_memory=1` (kubelet/k3s sets it) the commit succeeds and the test reported `malloc(300 GiB): succeeded despite RLIMIT_DATA`. Test only. When the 300 GiB commit succeeds, Linux now takes the skip path the other platforms already had, and the skip line prints the `vm.overcommit_memory` value. The remaining allocator checks still run and the test exits 0 when nothing failed, as `GuestAmpr.cpp` does for its partial skips. The `RLIMIT_DATA` setup is unchanged. ### Tested CachyOS, Linux 7.2.2-1-cachyos, `vm.overcommit_memory=1`: `ctest -R guest_allocator_failures` passes and prints `skipped: the host can commit 300 GiB (vm.overcommit_memory=1), so the failed commit and arena release checks did not run`. `python3 tools/check_conventions.py --base origin/main` passes. Not tested: the failing-commit path with `vm.overcommit_memory=0` or `2`; Windows; macOS. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-15 12:18:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:18:26Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6044 core/libs/tests/GuestAllocatorFailures.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191864655 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6310#issuecomment-6191864655). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:18:26Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestAllocatorFailures.cpp` |
jotitadev commented 2026-10-16 10:42:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-16T10:42:09Z.

Review: COMMENTED


Tested the path the description lists as untested: Linux with vm.overcommit_memory=0. Ubuntu 26.04, kernel 7.0, GCC 15.2, Release full build, i7-8700, 30 GB RAM. Head d70e9fb6c merged onto main 72c5eed1f.

  • guest_allocator_failures passes without skipping. Run directly, it prints Checked 10 failed heap commits and arena range reuse and exits 0, the same as on main, so the 300 GiB commit still fails under heuristic overcommit and the new skip is not taken.
  • The rest of the suite, excluding GPU tests, matches main (648/650, the same two file_writer_* failures on both).

I did not test vm.overcommit_memory=1 or 2.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5546637951 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6310#pullrequestreview-5546637951). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-16T10:42:09Z. **Review:** COMMENTED --- Tested the path the description lists as untested: Linux with `vm.overcommit_memory=0`. Ubuntu 26.04, kernel 7.0, GCC 15.2, Release full build, i7-8700, 30 GB RAM. Head `d70e9fb6c` merged onto `main` `72c5eed1f`. - `guest_allocator_failures` passes without skipping. Run directly, it prints `Checked 10 failed heap commits and arena range reuse` and exits 0, the same as on main, so the 300 GiB commit still fails under heuristic overcommit and the new skip is not taken. - The rest of the suite, excluding GPU tests, matches main (648/650, the same two `file_writer_*` failures on both). I did not test `vm.overcommit_memory=1` or `2`. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
oneandonlydean commented 2026-10-17 03:30:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T03:30:41Z.


Thanks, the analysis matches what we see. One request before merge: please only take the skip when overcommitMode() == 1. Under modes 0 and 2 a successful 300 GiB commit is still the failure this test exists to catch (jotitadev's mode 0 run shows the commit fails there), so it should keep calling report("malloc(300 GiB)", ...), ideally with the mode in the message. The skip line for mode 1 is fine as written.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6229063569 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6310#issuecomment-6229063569). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T03:30:41Z. --- Thanks, the analysis matches what we see. One request before merge: please only take the skip when `overcommitMode() == 1`. Under modes 0 and 2 a successful 300 GiB commit is still the failure this test exists to catch (jotitadev's mode 0 run shows the commit fails there), so it should keep calling `report("malloc(300 GiB)", ...)`, ideally with the mode in the message. The skip line for mode 1 is fine as written.
eliyarson commented 2026-10-17 18:32:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by eliyarson on 2026-10-17T18:32:54Z.


Pushed as 90fbcba2c. The skip is now taken only when overcommitMode() == 1. If the 300 GiB commit succeeds under any other mode — 0, 2, or -1 when the file cannot be read — the test calls report("malloc(300 GiB)", "committed 300 GiB with vm.overcommit_memory=<mode>") and fails. The mode-1 skip line is unchanged.

Tested: Release build, cmake --build build --target guest_allocator_failures_tests exit 0, and ctest -R guest_allocator_failures passes. This host has /proc/sys/vm/overcommit_memory = 1, so the run takes the skip path and prints:

skipped: the host can commit 300 GiB (vm.overcommit_memory=1), so the failed commit and arena release checks did not run

python3 tools/check_conventions.py --base origin/main: all checks passed.

Not tested: modes 0 and 2. Changing vm.overcommit_memory needs root, which I do not have on this machine, so the new failure path has not run inside the test. I only compiled the branch snippet on its own with the mode forced to 0, 2 and -1 to check the message, which printed malloc(300 GiB): committed 300 GiB with vm.overcommit_memory=0 (and 2, -1). jotitadev's mode 0 run (Checked 10 failed heap commits and arena range reuse) shows the 300 GiB commit fails under mode 0, so that path is unchanged by this commit. I have no mode 2 run. The non-Linux #else path is untouched and still skips when the commit succeeds, since there is no overcommit mode to read there.

LLM assistance used.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6238637000 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6310#issuecomment-6238637000). Originally posted by [eliyarson](https://github.com/eliyarson) on 2026-10-17T18:32:54Z. --- Pushed as `90fbcba2c`. The skip is now taken only when `overcommitMode() == 1`. If the 300 GiB commit succeeds under any other mode — 0, 2, or -1 when the file cannot be read — the test calls `report("malloc(300 GiB)", "committed 300 GiB with vm.overcommit_memory=<mode>")` and fails. The mode-1 skip line is unchanged. Tested: Release build, `cmake --build build --target guest_allocator_failures_tests` exit 0, and `ctest -R guest_allocator_failures` passes. This host has `/proc/sys/vm/overcommit_memory` = 1, so the run takes the skip path and prints: ``` skipped: the host can commit 300 GiB (vm.overcommit_memory=1), so the failed commit and arena release checks did not run ``` `python3 tools/check_conventions.py --base origin/main`: all checks passed. Not tested: modes 0 and 2. Changing `vm.overcommit_memory` needs root, which I do not have on this machine, so the new failure path has not run inside the test. I only compiled the branch snippet on its own with the mode forced to 0, 2 and -1 to check the message, which printed `malloc(300 GiB): committed 300 GiB with vm.overcommit_memory=0` (and `2`, `-1`). jotitadev's mode 0 run (`Checked 10 failed heap commits and arena range reuse`) shows the 300 GiB commit fails under mode 0, so that path is unchanged by this commit. I have no mode 2 run. The non-Linux `#else` path is untouched and still skips when the commit succeeds, since there is no overcommit mode to read there. LLM assistance used.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!6310
No description provided.