A runtime extension (Metal has none). A guest's buffers over pieces of one shared file of guest RAM
were each imported as their own dma-buf import and freed with the buffer, so a compute loop that
made and dropped no-copy buffers paid an import and a free per command buffer, and on RADV each
import maps its pages at once (the next submission's CS waits for the page-table job).
Device::import_shared_dma_buf(file, options) (unix) imports the whole dma-buf on the caller's
thread, or joins the device's live import of it, and returns a SharedDmaBufImport; while a handle
lives, the file's entry in the device's map keeps the import, so buffers over its pieces join it
instead of importing again, and it is freed once its last buffer, heap and handle have gone (one
kept import per file a live handle names, per generation). The class comes from `options` as a
no-copy buffer's (Private, Memoryless and undefined options refused, Invalid StorageMode); the
import takes the type a no-copy buffer of that class would get first, so pieces join it.
Refusals use the existing kinds (Unsupported HostMemory, OutOfMemory). A device's recovery lets go
of the lost generation's kept holds and seeds the new one's map, whose first buffer imports the
file again; nothing is imported on the recovering thread. A device without a dma-buf importer
keeps nothing (Debug: imported false). The handle imports whether or not the device's buffers over
those pages take the dma-buf route: on a device that takes the pages' pointer it is one listed
dma-buf a submission for nothing. WorkCounts::dma_buf_shared_imports_kept gauges the kept imports;
the handle's import counts in dma_buf_imports. Docs: rustdoc, dma_buf.rs Shared files, HOWTO
dma-buf section, the runtime README extensions and unix-only lists. REFUSALS.md: the StorageMode
site moved to host_class, which the no-copy call and this one share.
Public surface: Device::import_shared_dma_buf, SharedDmaBufImport (Send + Sync, consumer_auto_traits)
and WorkCounts::dma_buf_shared_imports_kept, blessed in api_signatures.tsv.
Verified: m3-max-33745 at the lane tip 856a1fabae: clippy plain, m2v_gpu, m2v_cpu_icd 0; rustdoc 0;
lavapipe runtime suite 2836 passed. Device tests (lavapipe): three buffers made and dropped in turn
take imports 1 / joined 3 with the handle, imports 3 / joined 0 without; a handle keeps a live
buffer's import; recovery imports nothing and the next buffer's import stays kept; Private refused.
Churn bench, PHOENIX (RADV 780M, release, interleaved, 450 command buffers an arm, a8f297bf11, the
same code but the count): no handle 1 import + 1 free a command buffer, call median 820-907 us, GPU
start median 3026-3037 us; handle kept 0 imports, 0 frees, 1 join, call median 25-69 us, GPU start
median 104-145 us.