Repository navigation
feat(agc): import shared ranges whose backing offset is not 64 KiB aligned - #5390
oneandonlydean merged 3 commits into
Conversation
7254bfd to
353e68d
Compare
353e68d to
d4fa836
Compare
|
Rebased onto |
d4fa836 to
ad572eb
Compare
|
Rebased onto
The description has the new numbers: ASTRO BOT on |
|
Tested on Linux (Arch),
That is the check at AI-assisted: yes |
|
Thanks for running it and printing the values, that pinned it down.
d7018a5 checks the lead only for a dma-buf import ( The Intel Arc B390 failure is probably the same, if ANV takes the host-pointer import there. I could not check that here; on that machine the note in the output would say which path the import took. On a Linux host with |
|
Checked
AI-assisted: yes |
|
The ANV run explains the lavapipe failure: both devices take the host-pointer path, where the lead is 0, so checking the lead only for a dma-buf import in |
…igned A sparse import binds whole 64 KiB blocks, so a range whose memfd offset is not a multiple of 64 KiB fell back to one UDMABUF_CREATE and, above udmabuf's size limit, to copies. The sparse buffer now starts at the block below the range: HostImport::lead holds that distance, the import's device address points at the range itself, and every offset into the import's buffer goes through HostImportOffset.
A unit shadow published its units into the import's buffer at the guest offset from the import's base, without the import's lead, so a sparse import that starts below its range (HostImport::lead) got the units lead bytes before their place. The shadow keeps the lead with the import's base and buffer, and the shadow verify reads the guest bytes at the same place. agc_driver_sparse_dma_buf_import publishes a unit shadow of its unaligned import and checks the unit's guest bytes and the bytes around it; without the lead it fails there.
A device that imports shared memory through host pointers, such as lavapipe, imports the unaligned range that way, and a host-pointer import has no lead.
d7018a5 to
52c4589
Compare
|
@oneandonlydean rebased onto Run on RADV: AMD Radeon RX 9070 XT, Mesa 26.2.4, Arch Linux,
The "on RADV it passes 3 of 3 with the lead checked" in my earlier comment was this same device, but without printing the path. Windows was not rerun after the rebase; the sparse tests are Linux only. AI-assisted: yes |
What
Follow-up to #5309. A sparse buffer binds whole blocks (64 KiB on RADV), so #5309 takes the sparse path only for a shared range whose offset in the memfd is a multiple of the block size, and decides that before importing. Any other range larger than 64 MiB still goes to one
UDMABUF_CREATE, which udmabuf refuses above its defaultsize_limit_mbof 64, and is copied. ASTRO BOT (PPSA21567) has several such ranges with #5309, including a heap that is made again with each new allocation:Each starts on a 16 KiB page, not on a 64 KiB block.
This PR starts the sparse buffer at the 64 KiB block below the range, inside #5309's decision:
createSparseDmaBufImporttakeslead = offset % 64 KiBoff the backing offset before deciding, and sizes the sparse bufferlead + bytes. The decision is otherwise feat(agc): import shared ranges above 64 MiB as sparse buffers over udmabuf chunks #5309's: a device whose sparse block size is larger than 64 KiB still declines before anything is imported, and failures after the decision still throw;HostImport::leadis the distance from the start of the buffer tobase(0 for every other import);entry.addressis the device address ofbaseitself, so address-based (BDA) users are unchanged;HostImportOffset(import, address)(address - base + lead), instead ofaddress - import->base: fills, copies, label stores, indirect arguments and counts, index and vertex inputs, detile offsets, the storage write-back's copies into each import segment, unit-shadow sources and seeds, DCC key stores, the in-place view binding and itscopySourceBase;begin - importBase + importLead.The leading bytes of the buffer belong to the memfd but are never addressed.
Measured
ASTRO BOT, RX 9070 XT (RADV),
size_limit_mbleft at its default of 64, 60 s from launch with no input,APS5_TRACE_HOST_IMPORT=1:main(4224d240a), 1 run107538d89andad572ebb1, 2 runs each)UDMABUF_CREATE)Measured earlier on the title screen against #5309's first head, per 10 s: image mirror refreshes dropped from 26,049 (914,912 blocks copied) to 6,623 (262,595), and guest memory reads from 9.4 GB to 3.2 GB with
APS5_HOST_IMPORT_MIB=16384. The frame rate did not change (~20 FPS): the title screen is bound by GPU time and draw recording, not by these copies.Tested
agc_pending_key_storesandagc_driver_tessellation, which fail the same way onmain(4224d240a), andagc_host_import_sparse, which needs test(agc): drop a shared range's backing when the range goes away #5759 (merged since; below).agc_host_import_sparsechanges its unaligned case: a range 4 KiB into the memfd is now imported, withlead4 KiB, the device address of the range itself, and its first bind at the block below it. A new case keeps the decision check: with a mocked sparse block of 128 KiB, a range 64 KiB into the memfd imports and binds no chunk.agc_driver_sparse_dma_buf_importregisters a range 16 KiB into the memfd, larger than the currentsize_limit_mb, and fills 64 KiB across the first chunk boundary through the import by guest address, checking the backing memory at that address and the bytes on both sides. It then publishes a unit shadow of that import and checks the unit's guest bytes and the 16 KiB on each side; without the lead in the publish it fails there.agc_driver_sparse_dma_buf_importtherefore checks the lead only for a dma-buf import (d7018a5, after @nicolasfalesy's report). On lavapipe (Mesa 26.2.4,/dev/udmabufwritable) it failed 2 of 2 runs before that commit and passes 3 of 3 after it, with a note that the import went through a host pointer; on RADV it passes 3 of 3 with the lead checked. The 21 tests matching^agc.*(import|dma|sparse|shadow|unit)give the same result on both devices: 19 pass,agc_shadowed_key_storesskips, andagc_host_import_sparsefails without test(agc): drop a shared range's backing when the range goes away #5759.4224d240a), the test'sSharedRangeleaves dangling pointers inbackings, which can make any case after the first resolve the wrong backing. test(agc): drop a shared range's backing when the range goes away #5759 fixes that and is merged now. With its change applied to this branch,agc_host_import_sparsepassed 8 of 8 runs before, and 4 of 4 on the current head, both on RADV and under lavapipe (the test mocks the device).audio_out2_shutdown,audio_out_shutdownandguest_kqueue(0xc0000409) out of 1288, the same three asmain(4224d240a) on the same VM. The GPU tests skip in this VM, and the sparse tests skip there since udmabuf imports are Linux only.lead0, runs as before. Hades (PPSA03355) stops at ~9 s as onmain(fix(agc): settle dma-buf imports on Linux on the settle queue #5905).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)agc_host_import_sparseneeds, is merged)🤖 Generated with Claude Code