fix(libkernel): release flexible accounting after fixed mmap #7242
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7242"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T18:51:59Z.
What
On a successful
MAP_FIXEDanonymous or file-backedmmap, the host replaces the old guest pages. If those pages were charged ing_flexibleRanges, leaving the old interval recorded makessceKernelAvailableFlexibleMemorySizeunder-report available memory. Release the replaced interval from flexible accounting only after the mapping succeeds; failed mappings leave the charge unchanged.The regression replaces the middle page of a three-page flexible mapping, checks that neighboring bytes remain intact and the replaced page is zeroed or contains the mapped file data, verifies the flexible budget decreases by exactly one page, then confirms the full budget is restored after unmapping. The file-backed case runs on Linux, where regular file mappings are supported by this path.
This addresses only the confirmed fixed-replacement behavior in #7120. It does not change the issue’s separate, unconfirmed question about whether ordinary anonymous
mmapconsumes the flexible budget.Tested
libkernelandguest_memory_tests.guest_mmap_fixed_anonymouspassed, including the anonymous and Linux file-backed accounting regressions. This host (Intel Xeon E5-1620 v2) lacks CPU features required by the test runtime, so the focused test used a temporary local-only bypass of the startup CPU feature guard; the guard and all unrelated source were restored. This is not a standard unmodified-host runtime result.python3 tools/check_conventions.py --base upstream/mainpassed.git diff --checkpassed.tools/pr_overlap.py --branch codex/fix-mmap-flexible-replacement-7120reported no overlap with open PRs.Checklist
main; no other open PR implements the same POSIX mmap behaviorNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file; n/a.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T19:08:09Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libkernel/DirectMemory/PosixMemory.cppL120-121Some 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.
core/libs/tests/GuestMemory.cppcore/libs/prx/libkernel/DirectMemory/Export.cppcore/libs/tests/GuestMemory.cppcore/libs/tests/GuestMemory.cppcore/libs/prx/libkernel/DirectMemory/Export.cppcore/libs/prx/libkernel/DirectMemory/PosixMemory.cppcore/libs/tests/GuestMemory.cppcore/libs/prx/libkernel/DirectMemory/Export.cppImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T20:17:46Z.
Overlap follow-up: #6534 independently changes the same
DoMapAnoncall inPosixMemory.cppto passfixedAnonymous, as part of Windows stack replacement. That is the same call-site hunk this PR changes to release flexible-memory accounting after success. The behavior is distinct, but the hunk will need a mechanical rebase/merge if either PR lands first; this PR does not depend on #6534 at runtime. I will preserve both behaviors when resolving the overlap. #7201 also touchesExport.cpp, but its current changes are in separate macOS query/locking paths; theReleaseFlexibleMappingRangewrapper here is additive.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T20:23:53Z.
Manual overlap audit on current
main922dc899: #4449 adds separate shared-backing tests; #5021 changes theExport.cppVirtualQuery/lock paths andGuestMemory.cpptest gates; #6044 is a rename of the memory test file; #6222 adds macOS VirtualQuery and file-descriptor pinning paths; #6565 adds separate lease tests. Their current diffs do not change this PR’s flexible-range release wrapper, fixed mmap success paths, or focused tests. #7201 is likewise separate macOS query/locking work. The only same-callsite behavior overlap is #6534, already described above; it passesfixedAnonymousintoDoMapAnonfor Windows stack replacement, while this PR releases flexible accounting after success.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T20:24:19Z.
I rebased this PR onto current
main922dc8999because its original parent was six commits behind. The rebased commit has the same patch ID as the prior head, preserves the MarcZX100 author, and the diff and conventions checks pass on the new base. The earlier Linux Release build/focused regression run applies to the unchanged patch before this rebase; a fresh local build could not be configured here because the worktree’s other required submodules are not initialized. Hosted CI reran conventions and eligibility successfully; Linux/Windows and other platform build jobs are skipped by path policy.