test(libkernel): cover flexible budget after direct replacements #6515

Merged
Ondra97 merged 1 commit from upstream-pr/6515 into main 2026-10-19 03:02:24 +00:00
Ondra97 commented 2026-10-15 18:28:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-15T18:28:49Z.


What

I added a limited-budget regression for direct mappings that replace the middle 32 KiB of a 64 KiB flexible mapping through the ordinary, typed, named and batch APIs.

The test checks that failed MAP_NOOVERWRITE calls preserve the address, budget and mapped data; successful replacements recover exactly 32 KiB, keep neighboring data intact and report direct memory; recovered capacity can actually be allocated; and releasing direct memory and cleaning up the remaining flexible pages do not release the same budget twice.

The production fix landed in #7112. This rebased PR keeps its additional regression coverage and removes the duplicate production changes. Production code is identical to main. #6491 covers flexible-over-flexible replacements; #6044 moves this test file.

Tested

Base e5c2b3c325e485ba7fd417c47c46f48aa2c89115; head 8627ac796583c9db7694c8c324546d39b7bd7016. These are CPU memory/API tests, with no title or performance claim.

  • Windows (native host): Windows 11 Pro 10.0.26300, AMD Ryzen 9 7900X, 32 GB RAM, NVIDIA GeForce RTX 4070 Ti SUPER; WinLibs MinGW-w64 GCC 15.2.0, Ninja, Release. The Release application and all system libraries (relinker, libs, including patched libraries) and selected fixtures built successfully. All 15 selected CTests passed with zero skips (3.85 s total; limited-budget regression 0.12 s).
  • Linux (VirtualBox): Ubuntu 24.04.5 LTS, kernel 7.0.0-38-generic, GCC 13.3.0, 4 vCPUs and 8 GiB RAM; VirtualBox 7.2.20 on the Windows host above. Graphics: not exercised. The library/test build (libc, libkernel, guest_memory_tests, guest_flexible_memory_budget_tests) passed, followed by all six selected CTests with zero skips. All 16,121 transferred source/dependency SHA-256 hashes matched before the build and after restoration.
  • Regression sensitivity, Linux (VirtualBox): four isolated mutations each omitted one API's existing successful-release call. Each failed the limited-budget regression at its own API with exactly 32,768 bytes still charged. After restoring the production source byte for byte and rebuilding, all six tests passed again.
  • Conventions, whitespace and main-sync checks passed. The registration audit passed on both configurations: 983 Windows and 995 Linux (VirtualBox) test executable targets, with none newly unregistered.

The focused CTest filter on both platforms includes guest_memory and all five guest_flexible_memory_* modes. Windows additionally ran patched_libraries, guest_kernel_sys, guest_memory_pool_stats, guest_jit_shared_memory, guest_addresses, guest_mmap_fixed_anonymous, guest_mprotect_unmapped, guest_page_table_stats and guest_mlock.

Linux graphics/Vulkan tests: NOT RUN — intentionally excluded from VirtualBox validation. Native/bare-metal Linux was not tested. Native Linux GPU validation: not tested. The Linux application and unrelated test targets were not built. No GPU execution or retail/homebrew title was tested. Hosted full builds require collaborator dispatch; local results do not replace those jobs.

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; #7112 and the former Windows build prerequisite #6452 are merged
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes; I am responsible for this change
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4878000983 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6515). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-15T18:28:49Z. --- ### What I added a limited-budget regression for direct mappings that replace the middle 32 KiB of a 64 KiB flexible mapping through the ordinary, typed, named and batch APIs. The test checks that failed `MAP_NOOVERWRITE` calls preserve the address, budget and mapped data; successful replacements recover exactly 32 KiB, keep neighboring data intact and report direct memory; recovered capacity can actually be allocated; and releasing direct memory and cleaning up the remaining flexible pages do not release the same budget twice. The production fix landed in #7112. This rebased PR keeps its additional regression coverage and removes the duplicate production changes. Production code is identical to `main`. #6491 covers flexible-over-flexible replacements; #6044 moves this test file. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Base `e5c2b3c325e485ba7fd417c47c46f48aa2c89115`; head `8627ac796583c9db7694c8c324546d39b7bd7016`. These are CPU memory/API tests, with no title or performance claim. - **Windows (native host):** Windows 11 Pro 10.0.26300, AMD Ryzen 9 7900X, 32 GB RAM, NVIDIA GeForce RTX 4070 Ti SUPER; WinLibs MinGW-w64 GCC 15.2.0, Ninja, Release. The Release application and all system libraries (`relinker`, `libs`, including patched libraries) and selected fixtures built successfully. All 15 selected CTests passed with zero skips (3.85 s total; limited-budget regression 0.12 s). - **Linux (VirtualBox):** Ubuntu 24.04.5 LTS, kernel 7.0.0-38-generic, GCC 13.3.0, 4 vCPUs and 8 GiB RAM; VirtualBox 7.2.20 on the Windows host above. Graphics: not exercised. The library/test build (`libc`, `libkernel`, `guest_memory_tests`, `guest_flexible_memory_budget_tests`) passed, followed by all six selected CTests with zero skips. All 16,121 transferred source/dependency SHA-256 hashes matched before the build and after restoration. - **Regression sensitivity, Linux (VirtualBox):** four isolated mutations each omitted one API's existing successful-release call. Each failed the limited-budget regression at its own API with exactly 32,768 bytes still charged. After restoring the production source byte for byte and rebuilding, all six tests passed again. - Conventions, whitespace and main-sync checks passed. The registration audit passed on both configurations: 983 Windows and 995 Linux (VirtualBox) test executable targets, with none newly unregistered. The focused CTest filter on both platforms includes `guest_memory` and all five `guest_flexible_memory_*` modes. Windows additionally ran `patched_libraries`, `guest_kernel_sys`, `guest_memory_pool_stats`, `guest_jit_shared_memory`, `guest_addresses`, `guest_mmap_fixed_anonymous`, `guest_mprotect_unmapped`, `guest_page_table_stats` and `guest_mlock`. Linux graphics/Vulkan tests: NOT RUN — intentionally excluded from VirtualBox validation. Native/bare-metal Linux was not tested. Native Linux GPU validation: not tested. The Linux application and unrelated test targets were not built. No GPU execution or retail/homebrew title was tested. Hosted full builds require collaborator dispatch; local results do not replace those jobs. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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: <!-- #PR, or none --> none; #7112 and the former Windows build prerequisite #6452 are merged - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes; I am responsible for this change
github-actions[bot] commented 2026-10-15 18:35:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T18:35:32Z.


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/GuestFlexibleMemoryBudget.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6199481051 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6515#issuecomment-6199481051). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T18:35:32Z. --- <!-- 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/GuestFlexibleMemoryBudget.cpp` |
Pouare514 commented 2026-10-17 12:05:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pouare514 on 2026-10-17T12:05:35Z.


Heads-up from #7112 (open, mine): partial overlap with this PR - both release flexible budget after direct replacements. #7112 additionally scopes _releaseFlexible to tracked ranges (fixes over-release on munmap of direct/reserved ranges, the TLOU 2^64-wrap direction), covers _mapFlexible release-then-record + ReserveVirtualRange, and pins it in guest_memory. Proposal: whichever lands first, the other rebases (my PR can adopt your _mapDirect helper shape and keep scoping + tests, or vice versa). No action needed now, just flagging to avoid surprise at merge.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6233680698 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6515#issuecomment-6233680698). Originally posted by [Pouare514](https://github.com/Pouare514) on 2026-10-17T12:05:35Z. --- Heads-up from #7112 (open, mine): partial overlap with this PR - both release flexible budget after direct replacements. #7112 additionally scopes _releaseFlexible to tracked ranges (fixes over-release on munmap of direct/reserved ranges, the TLOU 2^64-wrap direction), covers _mapFlexible release-then-record + ReserveVirtualRange, and pins it in guest_memory. Proposal: whichever lands first, the other rebases (my PR can adopt your _mapDirect helper shape and keep scoping + tests, or vice versa). No action needed now, just flagging to avoid surprise at merge.
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!6515
No description provided.