Host-RAM ordering tests keep their run-bound buffer in its run's import

a_run_bound_buffer_and_a_copy_of_its_pages_order_by_their_host_bytes failed on lavapipe in
development's suite at 612f5dcfba: (1,0,0,0) against (1,0,0,1), the run's import no longer live.
The device releases a buffer's import of its run once it has been idle for 2 s
(host_residency.rs, IDLE) and binds the buffer in its chunk at its next use. The test waits for
the device's thread to import the chunks ahead (`settled`). Under the whole suite's load that
wait can outlast the 2 s, so the run's import was gone when the test counted it. The test was
then left with one import of the pages instead of the two whose ordering it checks.

Both ordering tests over a run-bound buffer now hand out its Metal address as soon as it is made
(`kept_in_its_run`). That keeps its import for good, as Buffer::gpu_address documents, so the
two imports the tests order stay under any load. The product's behaviour is unchanged.

Verification: under induced CPU load on lavapipe, against development without it (see the
flake report).

(cherry picked from commit 3462a26e6c39fd600ccdee70ad86438aeb24fe5b)
This commit is contained in:
Anees Iqbal committed 2026-11-09 05:58:17 -08:00
1 parent 0c17e50fad
commit 1571c220d7
1 file changed
+12
@@ -701,6 +701,16 @@ fn settled(device: &Device, done: impl Fn(&crate::WorkCounts) -> bool) -> crate:
later
}
/// Keep `buffer`, just made, in the import it was bound in (its run's alone, where it was): its
/// Metal address handed out keeps that import for good (`Buffer::gpu_address`). The device
/// releases a buffer's import of its run once idle for 2 s (`host_residency.rs`) and binds the
/// buffer in its chunk at its next use; a wait for the device's thread under load ([`settled`])
/// may outlast that, and the test would then find the buffer over one import of its pages, not
/// the two it orders.
fn kept_in_its_run(buffer: &Buffer) {
let _ = buffer.gpu_address();
}
/// 1 where the device binds an object over a chunk not imported yet in an import of its own run, 0
/// where its barriers do not order blits through two imports of the same pages
/// (`RuntimeDriverDefect::AliasedImportBlitsUnordered`, MoltenVK's and ANV's) and the object
@@ -1330,6 +1340,7 @@ fn a_run_bound_and_a_chunk_bound_buffer_over_the_same_pages_order_by_their_host_
// (`AliasedImportBlitsUnordered`) the first imports the chunk, and both lie in it.
let a = runs_alone(&device);
let alone = over(4 * page);
kept_in_its_run(&alone);
settled(&device, |counts| ahead(counts) == 2 + a);
let in_chunk = over(8 * page);
let made = device.work_counts();
@@ -1469,6 +1480,7 @@ fn a_run_bound_buffer_and_a_copy_of_its_pages_order_by_their_host_bytes() {
gate(&gates, true),
)
.unwrap();
kept_in_its_run(&alone);
let made = settled(&device, |counts| ahead(counts) == 2 + a);
assert_eq!(
(