perf(agc): take the /proc/self/maps fallback off the draw path on kernels without PROCMAP_QUERY #25446
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/25446"
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 oneandonlydean on 2026-11-22T03:47:03Z.
What
On Linux kernels without the
PROCMAP_QUERYioctl (before 6.11, for example Ubuntu 24.04 on 6.8)describePagesanswers from the text of/proc/self/maps. Two callers reach that scan on the draw path, and on PPSA21564 it costs two thirds of the frame rate (#25359 is the same scan seen by the allocation census).Sampling the scans on PPSA21564 with
APS5_NO_PROCMAP_QUERY=1(about 138000 in a 170 s run, all for addresses outside the guest arena and the main image, so the page table next to them cannot remember the answer):CompareMapped, called bycapturedMemoryChangedon every draw for captured shader memory that lives in host mappings. Each one reads the whole file, about 2400 lines.ShaderMemory::accessible), answered by the first line.This PR changes two things, both only where the ioctl is unavailable:
CompareMappedcompares a range that lies outside the guest arena and the main image throughGuestCopyInUnsynced, the fault-checked copyCopyMappedalready uses, in 16 KiB pieces. A piece that cannot be copied falls back to the scan, so the answer is the same as before in every case.APS5_NO_COPY_COMPARErestores the scan per comparison.ifstreamand oneistringstreamper line. It reads the file into a per-thread buffer, parses the two addresses and the permissions by hand and stops at the first mapping above the cursor. The first read asks for 256 bytes, so a near-null probe does not make the kernel format a page of mappings. The[guestmem]profile line now counts these scans asquery, as it does forVirtualQueryon Windows.Nothing is cached, so there is no snapshot that could go stale. With the ioctl available the only added work is one test of the cached query descriptor per comparison.
#25115 (closed) kept the parsed file per mapping generation and recovered most of the time, which is what pointed at the scan. I did not take that route because the costly queries are for host memory, where no generation or access event tells a snapshot that a mapping changed. #14473 records readable mappings into the page table and does not reduce these scans (it read slower than
mainon this title).Tested
Linux, kernel 7.2, NVIDIA GeForce RTX 4090, built on
8bd65f7dd2. The fallback is forced withAPS5_NO_PROCMAP_QUERY=1.PPSA21564, level
big_hand_pirate_island, one exclusive window, 240 s arms, unprofiled, order main, PR, main, PR on the fallback, then the PR once on the default path. Frame p50, median over the 10 s rows of the steady level:main, fallbackPresents per 10 s go from about 15 to about 47. GPU time per present is the same on all arms (about 83 ms) and the level draws correctly on each. A profiled arm of this PR on the fallback counts about 600 scans per 10 s in the level, 0.3 s in all.
Tests, with
APS5_NO_PROCMAP_QUERY=1:agc_driver_draw_allocations,agc_driver_draw_allocations_draw_pipelineandagc_driver_draw_allocations_plan_verifyfail on8bd65f7dd2(516, 521 and 522 allocations per warmed dispatch against limits of 10 and 13) and pass on this branch.agc_driver_graphics,agc_driver_graphics_maps_fallbackandguest_sysmodule_maps_scanpass, and the three census tests pass without the switch. The second commit adds checks ofCompareMappedon host pages to the gap test (equal, different, across an unmapped page, a difference before the gap, and a range longer than one piece); they run in both graphics tests, so the copy path and the query path are held to the same answers. The title numbers were taken on the first commit; the second changes tests only.Not tested: a kernel that really lacks the ioctl (the switch disables it at its source,
HostMapping::QueryFd), other titles, Windows (the changed code is not built there).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 (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T06:15:04Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reviewed implementation preserves the checked-copy fallback and the maps-scan path for unsupported cases.
What I ran
Reviewed head
d4f745c427b4454990278354f19bbb64f22eaa63. I read the prepared description, commits, manifest, diff, and all changed lines in the three changed files, then inspected the called copy helper. No build or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No runtime validation was performed, including on a kernel without
PROCMAP_QUERY; the author reports that environment as untested. No build or tests were run. The three changed files listed in the manifest were read; there were no excluded changed files.To get this to a good state
Nothing is required.