perf(agc): share one dma-buf import per 64 MiB of Linux direct memory #1152
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1152"
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 alfalfa-star on 2026-10-07T14:57:22Z.
What
With #943, every Linux direct-memory allocation the GPU uses becomes its own udmabuf and its own imported buffer object, because each allocation had a memfd of its own. Imported buffer objects can't be "always valid" in the GPU VM the way ordinary allocations are, so amdgpu validates every one of them at every command submission. PPSA14632 imports about 7000 allocations (about 5800 of them 64 KiB), and each
vkQueueSubmittook about 2.3 ms, around 5 s per 10 s, all held under the GPU mutex.A standalone test on RADV (RX 9070 XT, kernel 7.2.9) measured submits after the first ones:
So the cost follows the number of imported buffer objects. Their size and the number of ordinary allocations don't matter.
DIRECT_MEMORY_SIZE, at file offset = physical address.PhysicalBackingkeeps the file and its offset, andSharedBackingreturns that offset. A range allocated again is zeroed through a temporary mapping, as the old per-allocation memfd was zero-filled.VkBufferand binds it into the chunk's memory, so there is one udmabuf import per chunk. 64 MiB fits udmabuf's defaultsize_limit_mb.HostImport::chunkholds the chunk, so it lives until the last buffer bound to it retires.Tested
Linux 7.2.9 (Arch), Mesa 26.2.4 RADV, RX 9070 XT.
vkQueueSubmitdrops from ~2400 us to 46 us on average;guest_memory:CheckDirectMemorySharedBackingnow checks that two allocations share one file at offsets equal to their physical addresses, and that a released and reallocated range reads back zeroed. The existing offset checks are relative to the allocation's physical address. I checked that the new checks fail when broken.ctest: 359 of 359 pass on this branch; 463 of 463 after the rebase onto currentmain.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T03:25:47Z.
#943 is on main now, so this conflicts with main in
GuestBufferMemory.hpp,GuestBufferMemory.cpp,DirectMemory.cpp,tests/GuestMemory.cppandTechnicalDebt.md. Please rebase onto main so only your commit is left.Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-08T16:53:59Z.
Rebased onto current
main(be2b6d3e). Only this PR's commit is left. The code diff is unchanged; the only conflict was the TechnicalDebt line.ctest: 463/463.Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T19:43:29Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
be2b6d3e, merged ontomain8b393b6ein one build with 31 other PRs that had no Windows run.guest_memorypasses on Windows, so this only checks that the Windows build and test are unaffected.guest_offline_imports, broken by #2359 (reported there).No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T22:32:13Z.
Rebased onto current
main(only conflict: the TechnicalDebt line next to its neighbours) and rebuilt. Full ctest passes (548/548), andguest_memoryfails when the non-test changes are reverted, so the new checks do exercise the change. The chunk import logic (key by dev/ino/chunk index, buffer bound at an aligned offset, fallback to the individual import for ranges that cross a chunk) and the zeroing of reallocated direct memory look right to me. Merging once CI is green on the rebased head.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T23:03:22Z.
Rebased again onto current
main:mainmoved after the previous rebase and the PR conflicted again. Only conflict was the TechnicalDebt line next to the libSceZlib one; both kept. Rebuilt and ran the scoped ctest (libs, AgcDriver, libkernel): 332/332 pass. Merging once CI is green on the rebased head.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:04:35Z.
Rebased onto current
mainagain. This time the conflict was inDirectMemory.cppas well as the TechnicalDebt line:mainaddedPhysicalBacking::HostWriteData, which mapped the backing's own memfd at offset 0 and closed it in the destructor.HostWriteDatanow maps its view atfileOffsetof the shared file; the destructor only unmaps the view (the file is shared and not closed per backing).Scoped ctest (libs, AgcDriver, libkernel) passes, including
guest_memory. Merging once CI is green.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T06:07:07Z.
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)docs/dev/TechnicalDebt.mdL264docs/dev/TechnicalDebt.mdL264docs/dev/TechnicalDebt.mdL264