Files
metal2vulkan/docs
Anees Iqbal 6aff9aaa3c Stop a listed guest RAM's chunks at 256 MiB: a chunk's import pins every page of it
Where each listed import costs every submission (RADV with a source of dma-bufs), a guest RAM
was imported in chunks as long as the source's dma-bufs and the device's limits took: about
2.5 GiB on a consumer's 16 GiB guest on the Radeon 780M. A chunk's import pins every page of the
chunk, and udmabuf allocates the pages of the memfd the guest never touched, which stay
allocated once the chunk is freed. So each chunk an object lies in made all its bytes resident:
the consumer measured QEMU's Pss_Shmem at 7.86 GiB without the source and 12.31 GiB with it.

listed_chunk_bytes now stops at LONGEST_LISTED_CHUNK, 256 MiB, on every device and kernel. It
is a structural bound, not tied to udmabuf's size_limit_mb, which stays an upper bound through
HostRam::with_largest_dma_buf. The trade is speed against memory, with no accuracy change and
so no switch. Each live chunk costs every submission about half a microsecond (an 8 GiB RAM on
the 780M: 128 chunks of 64 MiB took a submission's median from 14 us to 60-88 us; 3 chunks of
2730 MiB, to 16 us). At 256 MiB, a 16 GiB RAM lists at most 64 chunks.

The kept-chunk rule (releases_idle_chunks) is unchanged, so the first-gather win of kept chunks
stays. The docs (the host_ram module, Device::use_host_ram, HOWTO section 6, and the FAST-PATHS
"Idle dma-buf imports are released" entry, edited in place) say where the chunks stop and why.
The lane probe submit_per_ram_chunk_length now measures only the lengths the plan can make (64,
128 and 256 MiB). Its run before the cap measured 64 MiB to 1 GiB.

Verified: the unit test listed_chunks_are_as_long_as_every_limit_takes_in_whole_64_mib fails
without the cap (a 2.5 GiB source gave 2560 MiB chunks) and passes with it (job ids in the tip).

(cherry picked from commit 9a158941e94173b4e0dc53b89f3b15c9b59f60c2)
2026-11-07 15:03:11 -08:00
..