perf(agc): cache the parsed /proc/self/maps across describePages calls #25115
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/25115"
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 tablefrogpillow on 2026-11-21T16:56:38Z.
What
On Linux without
PROCMAP_QUERY(kernels before 6.11, e.g. the 6.8 kernel of Ubuntu 22.04/24.04 and the CI target),describePagesanswered every page-cache miss by reading/proc/self/mapsfrom the top, and the outer loop reopened the file for each run. A title that imports many buffer-device addresses over a large, fragmented address space reparses the whole map thousands of times per burst.Jedi Survivor (PPSA07783) reopened a 13k–16k line map ~2000 times in a 30 s window, spent 36–43 s in a single address-bindings pass, and lost the device to the amdgpu hang timeout (#25019).
This parses the map once into a sorted snapshot keyed on the guest-allocation generation and binary-searches it, rebuilding only when the generation changes. A miss or gap forces one fresh reparse before it is trusted, so a readable mapping that appeared without a generation bump (a raw
mmap, asGuestWriteWatchregistrations make) is still found — this keepsagc_write_trackingand the other guest-memory tests correct.It does not build on #14473 (which caches the page-states a scan passes); for this title that cache is invalidated by the access-serial churn before it is reused, so the scan reran regardless (measured: no change on Jedi). Coordinated with @oneandonlydean on #25019.
Tested
RX Vega 56 (gfx900, Mesa RADV), Linux 6.8. Same machine and scene (Jedi PPSA07783 boot),
APS5_PROFILE_DRAW=1, headless weston:address bindings (bda)/proc/self/mapsreopens (30 s)mainVK_ERROR_DEVICE_LOSTCorrectness:
ctest -R 'agc_driver_bda|agc_bda|guest_memory|shared_writes|write_tracking|mapped_copy|collect_memo'— 36/36 pass on Vega withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(1.4.x), no newVUID-.agc_write_trackingspecifically exercises the raw-mmap-without-generation-bump path and passes.The remaining 8.2 s is the cold first import (empty cache) and the 1086 reopens are the verify-negatives reparses; a follow-up can bound those further, but the device-loss is already gone.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository🤖 Generated with Claude Code
Pull request closed