fix(agc): plan a heap again when its mirror's range has left the write watch #6646
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6646"
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 EagleBearerYS on 2026-10-16T01:22:14Z.
What
Resident Evil Village (PPSA01556) stopped before the title with a driver failure, on a tree of main
44df216321with our open import PRs (#6457, #6479), Windows 11, RTX 3070 Laptop GPU:That run's host imports kept the write watch when settled (
[write-watch] host imports of write-watched memory keep the write watch: yes), so the mirror that left the watch was most likely a range under the 1 MiB settle floor.SILENT HILL: Townfall (PPSA33286) hits the same throw on plain
main3b10c7ef0, on Windows 11 with an AMD Radeon 780M, 25 s after boot (compute shader 0x14919ce00: AGC graphics: a heap mirror's range is no longer write-watched; keravyn-ops's run on #6678). With #6455 and #6678, which settle imports under 1 MiB, the same run reached 90 s with 829 unwatched heaps against 3,711, which fits the settle-floor reading above. It hasn't been run with this PR.An address-based build serves a registered range that the host import budget refuses from a heap mirror, refreshed from the write watch.
acquireMirrorlooked at the watch only when it made the mirror, and the address-space cache only compared the device, the registry generation and the import epoch. A range leaves the watch for good when a host import that does not keep the watch covers it: on Windows, a direct import of private memory that is not settled (below the 1 MiB settle floor, or any import when imports cannot be settled); elsewhere, any import while imports are compared. Retiring the import does not put it back. The next build that reused the mirror, from the cache or from the mirror registry, threw "a heap mirror's range is no longer write-watched" from the heap refresh. A lower import budget makes this far more likely: more ranges are refused and mirrored, and more imports are made and evicted around them.GuestMemory::UnwatchSerial(), and look at the watch again only when some range has left it since.[buffers]line'sunwatched heaps), so a refused heap never falls back to a copy per build or reachesAPS5_ADDRESS_COPY_MAX_MIB. A sparse heap's mirror is kept the same way: its committed pieces are copied and its holes zeroed. A sparse range never passes the import's accessibility check, so it is always kept.main, so one larger thanAPS5_ADDRESS_COPY_MAX_MIBstill stops the build at the copy cap with its range named.Tested
agc_heap_mirror_unwatch: a 2 MiB mirrored heap with one 64 KiB block taken off the watch, the copy cap set to 1 MiB in-process (SetAddressCopyLimit). While the budget refuses the heap, the next build keeps the mirror and serves the CPU's new bytes in the unwatched block and in a watched one; once the budget holds it, the build after imports the heap and releases the mirror.agc_heap_mirror_unwatch_no_space_cache: the same without the address-space cache.agc_heap_mirror_unwatched_import: the heap is imported without the watch (ImportWatch::Unwatch) once the budget holds it; the next build takes the import instead of the cached mirror. Not registered on Windows, where the mock cannot model a settled import.agc_sparse_heap_mirror_unwatchandagc_sparse_heap_mirror_unwatch_no_space_cache: a sparse heap, 2 MiB committed of 4 MiB reserved, with a committed block taken off the watch; the next build keeps the sparse mirror and serves both blocks' new bytes. Red on this PR's first revision with "a sparse heap mirror's range is no longer write-watched".agc_heap_mirror_run_unwatchandagc_heap_mirror_run_unwatch_no_space_cache: two adjacent 2 MiB heaps mirrored as one run, a block of the first taken off the watch and both written; the next build keeps both mirrors and serves both writes.FATAL: an address-based build copies 2 MiB of 1 registered ranges, past 1 MiB (APS5_ADDRESS_COPY_MAX_MIB)), and the run tests fail with "a heap mirror of the run was dropped once part of the run left the write watch". The per-mirror collect is needed: with one full refresh for the whole run in its place, the run tests fail with "the watched heap beside an unwatched one missed the CPU's write".ctest -R '^agc'passes (612 tests, 42 skipped).GuestBufferMemory.cppthe new tests fail with "a heap mirror's range is no longer write-watched" on both; with this PR they pass 5 of 5 on both. No new suite failures (guest_kqueuefails on Windows with and without this PR).agc_heap_mirror_unwatched_importisn't registered) andagc_driver_graphicspass 3 of 3 on both, none skipped; the only suite failure isguest_kqueueon Windows, which this PR doesn't touch.main3de84fa106(543d7cf5eb, the head), which brings #7339's host import construction guard and #6678's deferred settles; the header keeps bothSetAddressCopyLimitandSetHostImportDeferredSettles. On GitHub's runners (run): the^agctests (714, 0 failed), with the seven heap mirror tests, pass 3 runs in a row on Linux, and the libc and libkernel suites pass. On Windows the only failures areagc_driver_pm4_replay_toolandagc_shader_replay_tool, which fail the same way on that runner for an unrelated branch (run).Checklist
main. #6546 handles the same check another way and composes with this PR (below). Overlaps (git merge-treewithmain5d9dcc42d2):Requires into a full refresh, counted inheapUnwatched. This PR refreshes such a mirror in full too, and collects each mirror of a run on its own, so a run's watched mirrors keep their refresh by written blocks. On top of that it plans the range again when the host import path takes it now, so a heap the budget holds is imported instead of mirrored. The two conflict in three hunks ofGuestBufferMemory.cpp(refreshHeapMirrors,refreshSparseMirror,refreshHeapRuns); whichever lands second keeps this PR's version of the three refreshes, which already includes the full refresh; keeping #6546's++heapUnwatchedbeside it would count twice.CMakeLists.txt; keep both.GuestBufferMemory.cpp: it addsspaceMissand aResumeSpacepath that refreshes a cached space's heap runs and sparse mirrors. Whichever lands second carries the check intospaceMiss: it takesHostImports&and returnsSpaceMiss::Unwatchedwhen one of the space's heap or sparse mirrors has left the watch and the host import path takes its range now, withcase SpaceMiss::Unwatched: break;inAcquireRegistered's switch (which replaces this PR'selse hit = std::all_of(...)). A mirror whose import is refused is no miss:ResumeSpacekeeps the space and its existing calls refresh that mirror in full. Keep both sides' helpers beforeacquireMirror.NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T01:37:12Z.
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/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppL2423-2426Some 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/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T08:15:44Z.
Checked the diff against main: the three
Requires on a heap mirror's write watch become a per-mirror full refresh (counted inheapUnwatched), a range the host import path takes now is planned again, and runs collect mirror by mirror. The new tests (heap, sparse heap, run, with and without the address-space cache, plus the unwatched-import case) fail on main with the removed message, the debt entry is updated, and the Windows and Linux registrations match the neighbouring tests. Sending it to the merge queue for the full Linux and Windows build.