Files
metal2vulkan/crates
Anees Iqbal cbd20364dd Place the in-place check's buffers outside the Metal address space
What: the device's in-place check (`in_place_check.rs`) makes its 40 MiB buffer per class of
pages at `AddressPlacement::Outside`: the Fresh class through `Device::new_buffer_placed` (what
`new_buffer` does, at a placement; `new_buffer` is it at `Any`), the Pointer and DmaBuf classes
through `no_copy_kept`'s descriptor `with_placement(Outside)`. address.rs's "Outside the space"
and the check's module docs say so.

Why: the check runs on a thread of its own on a new RUNTIME_VERSION's first device per host,
while the program makes its resources. At `Any` its buffers took the lowest free 40 MiB of the
Metal space, from 2^32, so a program pinning there (`AddressPlacement::At`,
`setPinnedGPUAddress:`) got `PlacementConflict::Held` for a range no object of its own held,
breaking address.rs's rule that the runtime's own buffers lie in `[2^47, 2^48)`. The consumer's
repro refused a pin at 2^32 in 5 runs of 5 on MoltenVK. The placement is the only thing that
changes: the address space hands out a number, and the buffers' memory, fresh pages, import,
image and first move do not read it (`placed_new_buffer`, `place_window`), so no verdict can.

Test: `tests::in_place_check::the_in_place_check_takes_no_range_of_the_metal_space` (device
test): with the space past its first GiB held by one address pool and a 16 KiB pin every 16 MiB
of that GiB held through the check (no free run fits a check buffer), the check answers every
class as a reference device's check over an empty space, and the pins between the held ones,
made and released in turn while it runs, are all made. Without the fix it fails every time:
Pointer and Fresh come back Unchecked (their buffers found no range).

Verified on the M3 Max (MoltenVK): the test fails on the base (Pointer and Fresh Unchecked against
Passed) and passes with the fix (Pointer Passed, Fresh Passed, DmaBuf Unchecked, as the
reference; 4921 rounds of pins while the check ran).

(cherry picked from commit 113c132f47b2f9c258c3a22251d949419a9f36e4)
2026-11-02 10:55:21 -08:00
..