Host RAM: an object across two imported chunks is a copy, never a second import

A no-copy object whose pages cross the end of a guest RAM's chunk, the chunks on both sides
imported, is bound in neither: route_runs answers Runs, and the object took the gate's path
and imported its own pages, the same host addresses as the two live chunk imports
(VK_EXT_external_memory_host leaves that undefined; imports_inside_live counted it). The
consumer's walks hit it at boot on the 2080 and the 3090: a 2 MiB heap from 0x3f22000 into a
64 MiB chunk, 0xde000 bytes in the first chunk and 0x122000 in the next.

Such an object, and one over a live chunk's pages that no resolver routed, is now a copy of its
pages (CopiedBecause::OverRamChunk, counted in copied_over_live_imports, announced as
copied-host-pages, the gate not asked), at its making and at a heap's rebind. Chosen over:
- aligning chunk imports to objects: the chunks are imported ahead, before the objects over
  them exist, and objects lie anywhere;
- one import over both chunks: each chunk's import already binds objects when the straddling
  one comes, and swapping it would move every bound object;
- a sparse binding of both chunks' memory: heaps place resources at any offset, and not every
  device binds sparse buffers.
A copy costs one copy of the object's pages per commit, the rare edge object alone (one per
chunk end an object crosses).

Test: a_heap_across_two_imported_chunks_is_a_copy_and_imports_nothing (the consumer's shape:
both chunks imported by a buffer each, then a 2 MiB heap from 0xde000 before the first chunk's
end): one copy, no pointer import, imports_inside_live 0, the gate not asked; a buffer placed
across the chunks' end reads the RAM's bytes and a fill through it reaches them.
This commit is contained in:
Anees Iqbal committed 2026-11-11 21:20:02 -08:00
1 parent ea4bbb5fa3
commit 53501197a8
6 files changed
+149 -14

No files matched your search

+4 -1
View File
@@ -3364,7 +3364,10 @@ bound.
pages and not all (across its edge, or around it), or a heap's pages and more, so that importing
them would import a page twice, which `VK_EXT_external_memory_host` leaves undefined
(`copied_over_live_imports`, the gate not asked; a buffer whose pages a live import holds all of
lies inside that import instead, `ObjectChurn::buffers_bound_in_import`). The gate is asked
lies inside that import instead, `ObjectChurn::buffers_bound_in_import`); or a live import of a
guest RAM's chunk holds some of the pages at the RAM's own addresses and no chunk binds them
(they cross a chunk's end with the chunks on both sides imported, or no run resolver routed
them; `copied_over_live_imports` too). The gate is asked
before the pages' write permission, where the pointer would be imported. A copy of pages the process maps read-only drops the GPU's writes, as Metal drops
them: each batch's completion takes them back out of the copy and writes nothing to the pages
(`copied_dropped_bytes`; the detail says so). The detail names which cause it was; for a failed