Commit Graph
3242 Commits
Author SHA1 Message Date
Anees Iqbal ea02af47a4 Re-bless the cost records at d562bd4148
1135 recording(s) whose bounds moved. Cause: RT 1987 (206fbfba1c) makes a block ahead for a pool near its next block, and RT 1989 (d562bd4148) keeps a block's worth of bytes ahead per pool and has calls wait for a making instead of making a block in place, so made-ahead, made-in-place and waited-for block counts move. Contrast: pin 32's replay at 39b45dd232 (m3-max-12459) went over on blit-whole-texture-copy alone (buffer_blocks_made_ahead 1 where the record said 0); every value row matched the known-gaps ledger. The full list of moved bounds is in this commit's diff.
Measured on the M3 (s37-pl.sh rebless: cost --runs 8 --write over the whole
set, then cost --runs 8 --alone --write over the changed cases).

(cherry picked from commit ac01ee50d788bbd880e7f9d1a439bbf12c4e6bb7)
2026-11-09 15:47:53 -08:00
Anees Iqbal 0dbb240941 RUNTIME_VERSION 1991 and the runtime-sources pin for the large block kept apart and taken blocks waited for again
Two holes in RT 1989's blocks made ahead (b38f14b41a): a call for a pool's own (small) block took
the smallest made block at least as large, which could be the block kept for recent large
placements, so the next large texture waited for a new making (at d562bd4148 a 24 x 4 MiB burst
left 5-6 blocks of 32 MiB for 4 large textures, job 12519); and a call whose awaited block another
call took made one in place (the 5080 first-growth red at 39b45dd232 fits that). Now calls below
the pool's recent large size leave that size alone, and take_ready waits again for a taken block.
A pool of 16 MiB blocks with placements past them in the last 10 s keeps up to 96 MiB ahead.

Verified by the change's owner at d562bd4148 plus the commit (job 12522): clippy plain, m2v_gpu
and m2v_cpu_icd and rustdoc clean; memory tests 62/62 on the RX 550 (POLARIS12) and on lavapipe,
the burst keeping the 32 MiB block made ([32, 16] MiB, [32] MiB), nothing made in place. Cost
cases expected unchanged (64 MiB blocks, no placement past half a block). Here: API table check
and generators unchanged, pin recomputed.
2026-11-09 15:46:14 -08:00
Anees Iqbal f79bf9a144 Blocks made ahead: calls for a pool's own blocks leave its large block alone, and a taken block is waited for again
1. The large block kept ahead was not kept for the large placements. While a pool's placements
   past its 16 MiB blocks are recent, it keeps one 32 MiB block ahead (074d8e762e). But
   add_ready and the waits took the smallest made block of the needed size or more. So a burst of
   textures that ran through the pool's own 16 MiB blocks before their refill took the 32 MiB
   block too, and the next large placement waited for a new one. Shown at d562bd4148 by the new
   burst phase of tests::blocks_ahead (24 textures of 4 MiB back to back with a queue use held
   open): the burst took the 32 MiB block, nothing made ahead was left (lavapipe and the RX 550),
   and the pool ended with 5 and 6 blocks of 32 MiB against 4 large textures.

   Fix (memory.rs, memory/ready.rs): a call takes a block within a range (ready::Need). Below the
   pool's recent large size it takes no block of that size or more. The waits and the "will a
   block come" check use the same range. The pool's own blocks are kept at a full block's worth
   again (4 of 16 MiB), and the large block is kept besides them. Before, the large block was
   inside the 64 MiB but could already come on top of four small ones. So a pool of 16 MiB blocks
   with placements past 16 MiB in the last 10 s keeps up to 64 + 32 MiB ahead; every other pool
   keeps 64 MiB, as before 1984. ready.rs and FAST-PATHS' kept-blocks row say so.

2. A call that waited for a block made for it could still make one itself, if another call took
   that block first: take_ready then returned false and keep_room made the block in place. Now
   Waiter::wait says whether a fitting block was made, and take_ready waits again when one was
   but another call took it. Found by reading the path for the 5080's first-growth red at RT 1987.
   A call now makes a pool's block itself only where no making serves it: a host-copies placement
   while that pool's thread reads pages, a making that failed or a thread that did not start, or a
   placement before the device's first creation call.

3. The test placements_past_a_pool_s_small_blocks_find_a_block_of_their_size_made_ahead checked
   the device's count of waits, which also counts other pools' blocks. On the RX 550 (job 12498)
   it went red with the filtered suite running: 7 waits, 1 after the first 20 MiB texture. Alone,
   d562bd4148 passed 3 of 3 with the memory log on (job 12514): 5 waits, 0 after. It now reads the
   image pool's made blocks before each later 20 MiB texture, and it adds the burst phase.

Work counts expected to move against 074d8e762e: none in the cost cases. Their pools' blocks are
64 MiB and they place nothing past half a block, so the range is unbounded there and the reserve
is the same. Only a device whose blocks shrank and that places past them keeps the large block
ahead through a burst: fewer blocks_ahead_waited_for, and pooled_memory_blocks_made rises by the
small blocks the burst waits for instead of taking the large one.

(cherry picked from commit b38f14b41a45a152453358a9f6dd5459bf74f3cd)
2026-11-09 15:45:26 -08:00
Anees Iqbal ed26af7d18 The runtime-sources pin for the ANV trim defect's measured memory (comments only)
d57f5271cf adds the measured memory to TrimmedCommandBufferFailsResubmission's paragraph in
driver_defects.rs and to spares.rs: on ms01's Iris Xe, after a 1024-encoder burst, never freed,
freed and trimmed, and freed untrimmed each held 156.9-157.8 MB resident and 398,320 KiB of
driver memory (2 runs each, job 12506), so leaving the pool untrimmed on ANV costs nothing
measurable and is no speed-for-memory choice. Comments only: no RUNTIME_VERSION change; pin
recomputed, API table check and refusal surface unchanged.
2026-11-09 15:36:28 -08:00
Anees Iqbal 694e067cc8 TrimmedCommandBufferFailsResubmission: the untrimmed frees' memory on ANV, measured
A probe on ms01's Iris Xe (Mesa 26.2.6, i915; job 12506, 2 runs of each way) committed a command
buffer of 1024 blit encoders, then RECENT_USES + 1 of one, so the burst's command buffers went past
the pool's recent uses, and read /proc/self/status and the DRM file's fdinfo after each step. After
the frees, whether the command buffers were kept (the spares before RT 1985), freed and trimmed
(RT 1985 to 1989) or freed untrimmed (RT 1990), the process's resident memory was 156.9 to 157.8
MB, 82,568 to 82,580 kB of it anonymous (about 9.8 MB before the burst), and drm-total-system0
398,320 KiB in all 6 runs; a second burst and its frees moved none of them by more than 0.7 MB. The
trim returned none of what the burst grew there, so the untrimmed frees cost no memory measured.

driver_defects.rs's paragraph and spares.rs's bullet say so. Not a speed-for-memory choice
(docs/FAST-PATHS.md): the frees and the trim cost the same memory on ANV, measured.

(cherry picked from commit d57f5271cfd322858e50cc7b41d146fae27f73f7)
2026-11-09 15:35:56 -08:00
Anees Iqbal 3207826ca4 RUNTIME_VERSION 1990 and the runtime-sources pin for ANV's trimmed command buffers
On ms01's Iris Xe (ANV, Mesa 26.2.6, i915) runtime_lane::predication::streams_run_what_metal_ran
failed every run from 9c458c96a6 on: a kept barrier command buffer, submitted again without being
recorded again, keeps in its last batch object's list the first batch object of every command
buffer chained after it; the spares' trim destroyed those, their slab's GEM handle closed, and the
next submission's EXECBUFFER2 returned ENOENT, which ANV reports as a lost device. New
RuntimeDriverDefect TrimmedCommandBufferFailsResubmission on every ANV GPU: a spare pool's command
buffers are still freed on the free thread, but the pool is not trimmed (f02e4d40af..ca6d9ee688).

Verified by the change's owner on Iris: the stream failed in all 10 trimmed runs (4 at
39b45dd232, 6 with the key forced off) and passed in all 8 untrimmed ones; the new spares device
test fails 4/4 without the fix (command buffer 16 of 59, one recovery) and passes 3/3 with it;
lavapipe passes it; clippy (plain, m2v_gpu, m2v_cpu_icd), rustdoc and fmt clean at f02e4d40af's
source. Final-tree Iris lane + runtime suite (12502) and lint (12501) not yet in. Cost on ANV:
a pool keeps its freed command buffers' objects inside the driver (unmeasured). Here: API table
check, refusals and coverage generators unchanged, pin recomputed.
2026-11-09 15:24:55 -08:00
Anees Iqbal ca6d9ee688 TrimmedCommandBufferFailsResubmission: the measurements, the spares test's among them
The defect's paragraph in driver_defects.rs now counts every run on ms01's Iris Xe (Mesa 26.2.6,
i915) since the first commit: runtime_lane::predication::streams_run_what_metal_ran failed in each
of 10 runs whose frees trimmed the pool (4 at 39b45dd232, jobs 12446 and 12454; 6 with this
branch's defect key forced off, jobs 12474, 12484 and 12493) and passed in each of 8 that freed
without trimming (2 a probe's, 6 this branch's); and the stepwise form of
tests::spares::device::kept_barriers_run_again_after_the_command_buffers_after_them_were_freed
failed at its 16th command buffer, one recovery, in each of 4 runs with the key forced off (one
under VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, which printed no validation line) and passed,
59 command buffers completed and no recovery, in each of 3 with the fix (job 12493).

(cherry picked from commit 7fe5e75103d0e92bf126986aa4dcff17ef218fb8)
2026-11-09 15:24:02 -08:00
Anees Iqbal dab470c613 Spares trims test: grow the command buffers after the frees step by step, not by a second burst
The second-burst form also passed on ms01's Iris Xe with the pool trimmed (3 runs, and once under
the validation layer). Mesa's slab allocator released the emptied slabs as the second burst made
its command buffers, but the burst went on to make new slabs, whose buffer objects the kernel gave
the lowest free handles, those just released among them, so the kept barriers' stale handles named
live objects again by the time they were submitted.

After the frees each command buffer now takes the kept barriers again and makes STEP (16) command
buffers more than the one before: the allocation that finds the current slab full takes the freed
slices back, releasing the slabs they emptied, and the next allocations come from the slices taken
back, making no new slab, so the next submission of the kept barriers names a released handle. To
be run on the Iris Xe with the fix and without it.

(cherry picked from commit 6a4fd700b4fc22e729e340e3a0bc0cc332100a56)
2026-11-09 15:24:02 -08:00
Anees Iqbal 2015a1e07b Spares trims test: a second burst, which makes the driver take back the freed command buffers' memory
The first form of kept_barriers_run_again_after_the_command_buffers_after_them_were_freed passed
on ms01's Iris Xe with the pool trimmed (3 runs). A probe of its submissions there showed its
plan held: the burst's 127 kept barriers came before command buffers 322 to 574 of its 1343, all
1214 past the pool's recent uses were freed and trimmed, and every kept barrier was then submitted
again naming a freed one, but each submission completed. Mesa's slab allocator takes freed slices
back only when an allocation finds its first slab full (pb_slab_alloc_reclaimed), and the 126
command buffers the test then made fit in free slices, so no slab emptied and no handle closed.

The test now ends with a second burst of the same encoders: past the three the pool kept, it makes
as many command buffers as the first, so the allocator takes back the freed slices, releasing the
slabs they emptied, before the second burst's submission takes the kept barriers again. To be run
on the Iris Xe with the fix and without it.

(cherry picked from commit 7cf5b62cdbabb6d084e40af64153dd5c712309bb)
2026-11-09 15:24:02 -08:00
Anees Iqbal f02e4d40af Spares on ANV: free command buffers without trimming the pool, the kept barriers' submissions fail after a trim
Iris's runtime_lane::predication::streams_run_what_metal_ran failed at 39b45dd232 as a
GpuRecoveryVictim: vkQueueSubmit of a batch returned VK_ERROR_DEVICE_LOST (submit.rs's
submit_batch), because DRM_IOCTL_I915_GEM_EXECBUFFER2 returned ENOENT (strace), the execbuffer's
object list holding an object of handle 0 (INTEL_DEBUG=submit). Bisected to 9c458c96a6, the
give-back's frees moved to the free thread, uncapped.

The cause is ANV's chaining (Mesa main of 2026-11-09, read): a submission's command buffers are
chained, each one's last batch buffer object jumping to the next one's first, and under i915 the
jump adds the next one's object to those the first names (anv_cmd_buffer_record_chain_submit),
which only a reset or begin clears (anv_batch_bo_start). The kept barriers are submitted again as
recorded, so each submission names every command buffer that ever came next after one. A freed
command buffer stays in Mesa's common pool with its first batch buffer object until
vkTrimCommandPool destroys it; batch buffer objects are slices of 2 MiB slabs whose handle is
closed once every slice is free. The spares' uncapped frees and trims emptied whole slabs, and the
next submission of a kept barrier named a closed handle.

The probes on ms01's Iris Xe (Mesa 26.2.6, i915): the stream failed in each of 4 runs as
committed; it passed in each of 2 runs that freed without trimming, 2 that freed nothing, and 3
whose kept barriers were begun with SIMULTANEOUS_USE (which ANV never chains). Every command buffer
submitted at the failure was owned and none freed (an ownership trace of the spares), and the
validation layer, on in that test, reported nothing at the failure.

RuntimeDriverDefect::TrimmedCommandBufferFailsResubmission names it, on every ANV GPU (under the
xe kernel driver ANV records no such objects, but no GPU of it is measured). There a spare pool's
command buffers are freed, still on the free thread, and the pool is not trimmed
(release::PoolBuffers takes a trim flag; Spares::new(trims) from the device's defects); the
priming still trims, its command buffer never following a kept one. The kept barriers keep their
chaining: SIMULTANEOUS_USE would split each batch into an execbuffer per kept barrier. The cost on
ANV: a pool keeps, in the driver, as many command buffers' objects as it held at once, reset.

Tests: tests::spares::device::kept_barriers_run_again_after_the_command_buffers_after_them_were_freed
(a burst whose middle KEPT encoders come after kept barriers, freed past the recent uses, then the
kept barriers submitted again; every command buffer completes, no recovery);
tests::driver_defects lists the defect for every ANV profile. To be run on ms01's Iris Xe with
the fix and without it. api_signatures.tsv blessed (one variant row); docs/REFUSALS.md
regenerated: unchanged.

(cherry picked from commit 4e392a6bc8507445693982c6c041535490a4cc34)
2026-11-09 15:24:02 -08:00
Anees Iqbal d562bd4148 RUNTIME_VERSION 1989 and the runtime-sources pin for a block's worth of bytes made ahead
RT 1984's 16 MiB plain blocks on a slow, fragmented host made about 4x as many blocks, and the
ready thread, one block ahead, fell behind: in reims's pin 31 scroll on the 780M (12.7.6), 82-114
image blocks a boot were made in place on the guest's threads with 306-833 ms of compaction there
(1 and 0 at pins 29 and 30), and 8 of 11 rAF gaps of 100 ms or more overlapped them. Now each pool
keeps a block's worth of bytes ahead (64 MiB at most: 4 x 16 MiB with small blocks; one block of a
large placement's size while such placements are recent), made back to back by its thread, and a
call that finds no block waits for the making under way instead of making one (096241d096).

Verified by the change's owner: lavapipe 78/78 over the memory, blocks_ahead, plain_blocks,
clip_bursts, freed and exported memory, device_recovery and host_copy tests (12486); the two new
tests fail at the base (12487: 1 in place and 16 MiB ahead; 5 in place, four of 32 MiB); clippy
under m2v_cpu_icd and rustdoc clean (12491). Not yet in: the 780M bench before/after (gem10 12492)
and plain clippy at the exact tip (12494). Resting cost: unchanged against pre-1984 (64 MiB ahead
per growing pool); a pool of 16 MiB blocks keeps up to 48 MiB more than RT 1987 while it grows.
Expected to move the M3 cost records' made-ahead and made-in-place counts (re-blessed next).
Here: API table check and generators unchanged, pin recomputed.
2026-11-09 15:20:17 -08:00
Anees Iqbal 074d8e762e Blocks made ahead: a block's worth of bytes per pool, a block for large placements, and calls wait instead of making
The problem, from reims's pin 31 scroll round on um870's 780M. After slow makings, its plain
blocks were made at 16 MiB (RT 1984). Over two boots:
- 250 and 264 pooled blocks were made;
- 114 and 82 image blocks were made in place on the guest's threads;
- 110 and 159 blocks made ahead were waited for (91 and 122 hurried);
- direct compaction on guest threads took 833 and 306 ms.

Two causes:
- The ready thread kept one block ahead per pool. With 16 MiB blocks that is a quarter of the
  reserve that one 64 MiB block used to give. A call that found no block made and no making under
  way made its own.
- A placement larger than a 16 MiB block takes a 32 MiB block of its own size
  (pooled_block_bytes). No block made ahead could hold it, so it was always made in place.

What changed (memory/ready.rs, memory.rs):
- A pool keeps a block's worth of bytes ahead: as many of its blocks as one 64 MiB block holds
  (4 of 16 MiB).
- While the pool's placements larger than its blocks are recent (the last within
  KEPT_EMPTY_FOR), the reserve also holds one block of the largest such size. The pool's own
  blocks fill the rest of the 64 MiB (32 MiB + 2 x 16 MiB).
- One thread per pool makes them one after another, one vkAllocateMemory each, after a single
  wait for a burst's end. A block a call or a top-up queues while the thread runs joins its queue;
  a waiting call's block goes first.
- A call that finds no made block of the size it needs no longer makes one itself. It waits for
  the block being made or queued, or queues one first and waits. If the pool has no thread, it
  starts one. The waited block's pages are not read.
- The host copies' pool is now waited for too, except while its thread reads a block's pages
  (whose first touch may wait behind the program's GPU work). The waiter counts itself before it
  checks a reading flag; the thread sets the flag before it checks for waiters.
- A block is made in place only in these cases: a host-copies placement while that pool's thread
  reads pages; a making that failed or a thread that could not start; a placement before the
  device's first creation call.
- A placement over half of BLOCK_BYTES stays dedicated, as before.
- keep_room's per-pool step moves into keep_pool_room.

Resting cost (bytes kept ahead per pool, counted against the kept-blocks budget):
- Against pre-1984 (one 64 MiB block per growing or near-next pool): unchanged at 64 MiB.
- Against RT 1984 and RT 1987 (one block of the pool's size): unchanged for 64 MiB pools. A pool
  of 16 MiB blocks keeps up to 48 MiB more while it grows or is near its next block.
- At the device's first creation call, a pool of 16 MiB blocks also makes 3 blocks ahead after
  its first. If the pool never nears its next block they go after KEPT_EMPTY_FOR
  (blocks_ahead_unused). Pools of 64 MiB blocks, the default before any slow making, make none
  extra.

Work counts expected to move, for the cost records:
- buffer_blocks_made_in_place and image_blocks_made_in_place fall to 0, except in the cases above.
  That includes each kept pool's first block at a device's first creation call, which the call
  now waits for on the ready thread.
- buffer_blocks_made_ahead and image_blocks_made_ahead rise by as many. So does
  blocks_ahead_waited_for, since a call waited for each of them. These are not hurried: the
  making started at once for the call.
- host_copy_blocks_readied rises, and host_copy_blocks_made_in_place falls, where a host-copies
  placement found no making at all.
- pooled_memory_blocks_made is unchanged with 64 MiB blocks. With 16 MiB blocks the extra reserve
  blocks count there when added. When swept unused they count as blocks_ahead_unused and
  pooled_memory_blocks_freed.
- Kept-ahead bytes against the heap budget: a block's worth per pool, as above.

Docs: memory/ready.rs, memory.rs, the WorkCounts fields, and FAST-PATHS' kept-blocks row, which
now describes the 64 MiB reserve and the large block.

Tests (tests::blocks_ahead), on lavapipe under --cfg m2v_cpu_icd:
- a_pool_of_small_blocks_keeps_a_block_s_bytes_ahead_and_no_creation_call_makes_one: 16 MiB
  blocks, 4 MiB textures. 0 in place, 64 MiB kept ahead. The base fails it: 1 in place, 16 MiB
  ahead.
- placements_past_a_pool_s_small_blocks_find_a_block_of_their_size_made_ahead: a 20 MiB texture
  every 4. 0 in place, four 32 MiB blocks, 0 waits after the first 20 MiB texture. The base fails
  it: 5 in place, four of them 32 MiB.
- The memory, blocks_ahead, plain_blocks, zeroed_start, clip_bursts, exported/freed memory,
  device_recovery and host_copy tests passed, 78 of 78 (jobs 12486 and 12491).
- The 780M bench before and after (images, mixed and burst arms, fragmented) is running on gem10
  (job 12492). Its numbers go in the pin notes.

(cherry picked from commit 096241d0964536db875ab2957c64b40922e7fa8e)
2026-11-09 15:19:28 -08:00
Anees Iqbal 897d87288b Reclaim bench: hurried waits, in-place block sizes, the longest making, a burst arm
Each phase of tests::reclaim_submit_bench now prints:
- the blocks made ahead whose wait for a burst's end a call cut short (WorkCounts::blocks_ahead_hurried);
- the pooled blocks made in place, by their size;
- the longest single block making, wherever it ran (vkAllocateMemory, mapping and buffer of addresses).

The last two come from two test-only records in Memory, which the bench clears per phase. A new
arm, images in bursts, makes the images arm's 4 MiB textures 16 back to back every 500 ms.

Why: the block-ahead reserve change after this one needs before/after numbers for these. reims's
pin 31 counts on the 780M (82 to 114 image blocks made in place, 110 to 159 made ahead and waited
for) came from bursts and from textures past a small block, which the existing arms do not make
or did not split by size.

Test-only: no product path changes, so no pin or RUNTIME_VERSION change.
(cherry picked from commit 52bf3275384372fa82afa619b617132aded5058e)
2026-11-09 15:19:28 -08:00
Anees Iqbal 14a17e2e1f The runtime-sources pin for the CPU-copy wait docs (comments only, no RUNTIME_VERSION change)
9cedb97e36 changed only doc comments in device/staging.rs, interop.rs and texture/host_copy.rs
(what a CPU copy waits for on a device whose texture copies go through its first VkQueue, as
measured on the RX 550) plus a new device test, so the runtime's behaviour is unchanged and only
the pin over its sources moves. Verified here: pin recomputed, API table check and refusal
surface unchanged.
2026-11-09 14:36:20 -08:00
Anees Iqbal 4dda928b2b CPU copies beside a held wait: measured on the RX 550, no hang; docs say what they wait for
host_copy.rs and staging.rs said a texture's CPU copy through a
submission on the device's first VkQueue waits forever behind a
command buffer waiting on an event only a later command of the calling
thread signals. On a device with neither VK_EXT_host_image_copy nor a
transfer-only queue family (RADV POLARIS12, RX 550, Mesa 26.2.6:
hostImageCopy false; families graphics+compute+transfer x1,
compute+transfer x4, sparse alone) every texture's getBytes, and a
replaceRegion past the staged bound, takes such a submission, so the
claim mattered there.

Measured with a new device test, tests::copies_beside_a_held_wait: a
command buffer committed with a wait for an event (MTLEvent, then
MTLSharedEvent) at 1, then on another thread a getBytes of a Shared
RGBA8 texture, 4097 one-texel replaceRegions (one past STAGED_COPIES,
so the last makes a submission and waits for it) and a getBytes, bounded
at 10 s, and only then a command buffer on another queue that signals
1. On the RX 550 the copies took 0.161 s (event) and 0.149 s (shared
event), 3 internal submissions each, the waiter Committed meanwhile:
the scheduler holds a batch whose event wait no submitted signal meets
on the host (scheduler/mod.rs), so the VkQueue holds nothing waiting for
the later signal. The waiter then ran and filled its word. On lavapipe
the copies run on the host (0 internal submissions) in 0.01 s.

Negative control (scratch, not committed): the same copies beside a
plain event's wait for a signal reserved with Event::reserve_vk_signal,
which goes to its VkQueue before the signal is submitted: on the RX 550
the copies did not return within the 10 s bound (the waiter Scheduled)
until the test signalled the reserved counter from the host; on
lavapipe they returned in 0.01 s. So the test fails where a wait sits on
the VkQueue, and the hold is what keeps a Metal program's copies off it.

Docs: staging.rs's 'why a copy engine' keeps the measured cost behind
submitted work and says what a copy never waits for, with these
numbers; host_copy.rs points there; Event::reserve_vk_signal's safety
contract adds that a texture CPU copy behind a wait for the reserved
signal waits for it on such a device, so a thread submits the signal
before it makes such a call.

Verified (potluck, um790): the two committed tests pass on the RX 550
and on lavapipe; clippy on the runtime and validation crates under
--cfg m2v_gpu is clean.

(cherry picked from commit 9cedb97e36bc6f011311d0427239ae07f8a592a5)
2026-11-09 14:35:46 -08:00
Anees Iqbal 18cc660620 Sample positions: separate depth and stencil textures at custom positions
A pass with a Depth32Float texture and a Stencil8 texture as its two
attachments, at custom sample positions, was never measured on any device.
Such a pass renders through depth_stencil_scratch.rs's combined scratch
image, made for the positions, and copies each aspect back.

The new test separate_depth_and_stencil_take_the_positions
(dz_s8_custom4_separate) draws the edge plane at P4 and reads every sample
back. Each texture must hold what a Depth32Float_Stencil8 texture's aspect
holds there (dsz_custom4_x). A device without custom positions at 4
samples, or one that refuses the separate multisampled textures, says so
and stops.

No Metal probe ran this pair at custom positions. The expectation joins
two measured answers: separate textures' per-aspect stores, and the
combined texture's at these positions.

Verified (potluck, um790, RADV POLARIS12 on the RX 550, Mesa 26.2.6):
the test passes, printing "dz_s8_custom4_separate on AMD Radeon RX 550 /
550 Series (RADV POLARIS12): Metal's", with the other nine
runtime_lane::sample_positions tests; clippy on the validation crate
under --cfg m2v_gpu is clean. Not run on another device.

(cherry picked from commit 10f21f4aa4fbe8b2c7d3b57b789e42a197e628cd)
2026-11-09 14:19:07 -08:00
Anees Iqbal 4013bfd1ed Block CPU copy tests: no host copy and no staging queue means a submission a read
block_cpu_copies_stage_their_writes_and_read_where_the_device_copies_on_the_host
and block_cpu_reads_come_out_of_the_textures_host_shadow took a device
with neither a host read of a BC1 texture nor a staging queue for the
MoltenVK case, where the driver defect HostTransferImagesCopiedAtBind
keeps block formats off a host path the device has and the texture's
first read makes a host shadow. RADV POLARIS12 (RX 550, Mesa 26.2.6) is
another such device for another reason: hostImageCopy is false, and its
families are graphics+compute+transfer (one queue), compute+transfer
(four) and sparse alone, so no family of transfers alone for a staging
queue. There every texture's CPU read takes a submission of its own
(RGBA8: 7 of 7 reads, get_bytes_reads_each_layout_its_rows_alone), the
product makes no shadow (host_shadow.rs keys it on the defect and a
host path the device has), and the tests failed: 4 reads took 4
submissions where they expected 1, and [4, 4] where they expected [0, 0].

The tests now key their arms on the product's own condition: the shadow
arm where the device copies on the host and has the defect; with no host
copy, no staging queue and no shadow, each read takes one submission.

Verified (potluck, um790): both tests pass on the RX 550 (4 levels, 0
host and 0 staged reads, 4 submissions; read twice, 4 and 4) and on
lavapipe (host path); the rest of cpu_copy_layouts passes on both;
clippy under --cfg m2v_gpu is clean. Before, at fd51807e87, both failed
on the RX 550 as above.

(cherry picked from commit 8a25c95998d32d8f0b8ca8999b4b2aa4d883707a)
2026-11-09 14:19:07 -08:00
Anees Iqbal 5ffb515a7c Creation prediction test: a device with no fetch form refuses the XR blend, printed
a_multisampled_extended_range_blend_takes_the_creation_s_pipeline
unwrapped its render state, so on RADV POLARIS12 (RX 550, Mesa 26.2.6),
which has neither rasterization-order color attachment access nor the
fragment shader pixel interlock, the typed refusal (Unsupported of
FramebufferFetch, needs AnyOf([FragmentShaderPixelInterlock],
[RasterizationOrderColorAttachmentAccess])) failed the test. The state
helper now answers the refusal; the test prints a SKIPPED line and stops
where the device's profile has no fetch form and the refusal is
FramebufferFetch, as the lanes' FETCH-SKIP does, and fails on any other
refusal, or on that one where the device has a fetch form.

Verified (potluck, um790): on the RX 550 the test prints the SKIPPED
line with the refusal and passes, with the other two creation tests;
on lavapipe (m2v_cpu_icd) all three pass; clippy on the runtime and
validation crates under --cfg m2v_gpu is clean.

(cherry picked from commit e75767ed866531b8f821ac8c9d4a320d13e2a516)
2026-11-09 14:19:06 -08:00
Anees Iqbal fd51807e87 Device recovery test: a later recovery's slow failing is announced as well as its wait
each_recovery_announces_its_own_wait bounded a later recovery's
notice that its command buffers in flight took past the bound to fail
at one, and required only a call's wait: a later recovery that
swallowed the slow-failing notice (the shape the step had before each
recovery's notices became its own) passed. It now goes on through the
recoveries until one announced a call's wait and one its command
buffers' slow failing, each still at most once per recovery, and
names which never came.

The product fix is already on development (0529a98e4c: the step
notices go through Device::degrade_recovery_step, whatever the kind's
record says); this closes the step the test did not require.

(cherry picked from commit a2d31d7a0e2af472e359334f8dda226befcbe9c8)
2026-11-09 14:07:16 -08:00
Anees Iqbal 3575cf6cd7 Re-bless the authored compile census at 39b45dd232
Its product fingerprint follows development's versions at 39b45dd232. Blessed on the
M3 (s37-pl.sh censusbless --bless, dv-m3).

(cherry picked from commit d4c4b274438e05043973379949fd2a0ef463ca14)
2026-11-09 13:56:59 -08:00
Anees Iqbal 39b45dd232 RUNTIME_VERSION 1988 and the runtime-sources pin for the in-place check's near-byte walk
On ms01's Iris Xe the in-place check's writes and narrow-writes classes answered Passed in some
processes and Failed in others (2 of 8 loaded runtime suites, job 12318), and the verdicts are
kept per driver identity. Failed is the device's truth: the GPU writes back a row's last 64-byte
line as it read it, putting back bytes beside the texels that the CPU writer changed. The writer
walked the window at a stride and came back to those few bytes once a sweep, so a round caught
the write-back by chance (0-1 of 20 for R8 61x37). The writer now walks the line-sharing bytes many
times a sweep, and CHECK_VERSION goes 16 -> 17 so every device measures again (b74bba4d98).

Verified by the change's owner: per-round detection on Iris 16-20 of 20 alone, 10-19 beside the
suite; the placement test beside the suite 5/5, every class catching all three accesses on its
own (180/180); runtime suites 2011/2011 x3 on Iris; the new walk and compare tests fail with the
stride walk alone (gem10 12371); clippy and rustdoc clean (12375). Other devices not yet run on it:
a device whose store path writes back lines rarely may now answer Failed (expected, unverified).
Here: API table check and generators unchanged, pin recomputed.
2026-11-09 13:48:46 -08:00
Anees Iqbal 63a147a235 In-place check: the writer comes back to the bytes beside the texels in their lines many times a sweep
On ms01's Iris Xe (ANV, RPL-P) tests::in_place_check::the_in_place_check_takes_no_range_of_the_metal_space
failed 2 of 8 under the runtime suite's load (job 12318) and once in pin 31's Iris leg: one device
answered storage writes (or those of 1- and 2-byte texels) passed in all six classes where the
other answered failed. The failed answer is the device's: every change the rounds found is a byte
beside a row's last texels, in their 64-byte line, holding the writer's value of one sweep before
(a write-back of the line as the GPU read it), and the reference check of the same run caught it
in three classes and carried it to the others. Passed was the check missing it: the writer walked
the whole window at a stride and came back to the few bytes that share a line with texels once a
sweep, so it met the GPU's short read and write-back of such a line by chance. Per round on the
Iris Xe (job 12341, 20 rounds a shape): a 61x37 R8Uint image at a 256-byte pitch (3 such bytes a
row in a 20 KiB window) caught it in 0 to 1 of 20, a 45x29 R16Uint one in 1 to 6, a 101x51
RGBA8Uint one at 512 in 6 to 14, alone, with 24 spinning threads, and beside the suite alike, so
three rounds of each answered the narrow writes passed in about one class in two (the reference
of job 12348 caught them in three of six) and now and then in all six.

The writer's order is now a Walk: the stride's walk over the window, passing over the texels and
the bytes beside them in their lines (near_bytes: of each row, the bytes of its first and last
texels' lines, but the texels), and after each of its bytes NEAR_STEPS (8) steps of a walk round
those bytes in order, each walk sweep after sweep with its own marks. A byte beside the texels in
their line comes back within one pass round them (a few hundred bytes for the check's shapes)
plus the stride's steps between, so a line's write-back meets one of the CPU's writes however
short its span; every other byte still comes back once a sweep. Written carries the near walk's
bytes, sweep and reach, and the compare reads each byte against its own walk's last sweep. The
rounds take the device's line (in_place's line, nonCoherentAtomSize) for it. Reads rounds, which
write every byte, keep the stride's walk alone. CHECK_VERSION 17: a record measured with the old
walk is never read, so a passed verdict a loaded process kept is measured again.

Tests: a_round_s_writer_comes_back_to_the_bytes_beside_the_texels_in_their_lines_many_times_a_sweep
(every check shape whose texels share a 64-byte line: the near bytes are exactly those, each comes
back within its bound, every other byte once a sweep; a stride's walk alone breaks the bound) and
a_round_finds_a_byte_beside_the_texels_in_their_line_put_back_as_the_walk_found_it_before (the
compare finds a near byte holding its sweep before: padded where free, changed where not).

Verification: the Iris runs follow in the jobs after this commit.
(cherry picked from commit b74bba4d980032042103c81891d0d9d4ebc55c51)
2026-11-09 13:48:01 -08:00
Anees Iqbal 206fbfba1c RUNTIME_VERSION 1987 and the runtime-sources pin for blocks made ahead near a pool's next block
A pool's first growth (and its first after a pause) was always made in place by keep_room on the
calling thread, because blocks were made ahead only for a pool that grew recently; reims's 780M
scroll made exactly one such block a scroll on the guest's decode thread under 15-56 ms of
compaction. Now a pool near its next block (a pooled block held, its longest free range under
three quarters of a block) gets that block made ahead, exportable pools too (35c4231506).

Verified by the change's owner (um790 jobs 12337, 12354): the growing-pool test sees the first
growth made ahead on RADV PHOENIX and lavapipe and fails at development's memory files; runtime
suite 2011/2011 (780M) and 2014/2014 (lavapipe); clippy and rustdoc clean; release scroll arm, 3
runs per build: 7 ahead + 1 in place -> 8 ahead + 0 in place every phase. M3 cost check (12346)
not yet run: pooled_memory_blocks_made may rise where a pool rests between half and three
quarters full. Here: API table check and generators unchanged, pin recomputed.
2026-11-09 13:38:42 -08:00
Anees Iqbal 05dcfce04e Memory: a pool near its next block gets it made ahead, its first growth among them
Blocks were made ahead (memory/ready.rs) only for a pool that grew lately:
a second or later pooled block added within KEPT_EMPTY_FOR. So a pool's
first growth, and its first after a pause, was always made in place by
the creation call whose keep_room found no room for half a block: in a
guest's scroll on a Radeon 780M, the buffers' pool's first growth block,
made on the guest's thread.

A pool made ahead for now also gets its next block made ahead, grown or
not, once it is near it (Pool::near_next): it holds a pooled block and
its longest free range is below three quarters of a block (ahead_room), a
quarter of a block before the half block keep_room keeps. The pools of
exportable buffers take the same rule (exported_growing lists those near
their next block too). A block made ahead for a pool that stopped growing
goes after KEPT_EMPTY_FOR only once the pool has room for three quarters
of a block again, so a pool that rests near its next block keeps that
block, one at most a pool, counted against the kept empty blocks'
budget, and makes none over and over. That is the resting cost, written
in docs/FAST-PATHS.md's row on kept blocks and in ready.rs. The other
option, a block ready for every pool in use, holds one at rest for every
pool, not only those near their next.

Tests: blocks_ahead's growing-pool test now asserts its first growth is
made ahead too (renamed). reclaim_submit_bench gains a scroll arm:
Private buffers of 7471104 bytes (a scroll's, eight to a block) every 30
ms, 64 a phase.

Verified on um790's Radeon 780M (RADV PHOENIX) and lavapipe (jobs 12337,
12354):
- blocks_ahead, 780M: first growth 1 made ahead, 0 in place (lavapipe
  the same). Negative, development's memory.rs and ready.rs: 0 ahead, 1
  in place, the test fails.
- Runtime suite: 780M 2011/2011, lavapipe 2014/2014; clippy with
  m2v_gpu, m2v_cpu_icd and no cfg clean; rustdoc clean.
- reclaim_submit_bench_scroll, release, three runs each, alternating:
  development made 7 blocks ahead and 1 in place in each phase, quiet and
  fragmented (compact_stall about 2500 in the pressed phase), every run;
  with this change 8 ahead and 0 in place in every phase. The slowest
  creation call: development 0.2 to 0.4 ms, this change 0.1 to 0.2 ms.
  The in-place makings were fast in this bench's fragmenting; the
  consumer's trace had the same making under the kernel's compaction.

(cherry picked from commit 35c4231506652a454e43e703b162384a0a2f71cc)
2026-11-09 13:37:57 -08:00
Anees Iqbal 1c55359c9e RUNTIME_VERSION 1986 and the runtime-sources pin for give-back frees on the free thread
A spare command pool's give-back no longer frees and trims on the giving thread: the completion
thread posts the command buffers past the pool's recent uses (and an idle spare's) with the pool
to the device's free thread, which frees and trims them inside exit-guard sections and then keeps
the pool among the spares again (62307392d4). reims measured the trim at 0.65 ms median and up to
3 ms on the 780M, on the completion thread before the completed handlers ran.

Verified by the change's owner at its tree before the rebase (um790 job 12334): RADV PHOENIX
runtime suite 2009/2009 and lavapipe 2012/2012 with clippy clean; the device test sees the frees
on the free thread and fails with them on the giving thread; release, 780M, 32 rounds: status
final to first completed handler 1508/1596 us -> 5.9/5.7 us at the median. MoltenVK (job 12333)
not yet run. Here: the API table check, refusals and coverage generators unchanged, pin
recomputed.
2026-11-09 13:22:55 -08:00
Anees Iqbal fb01e74b58 Spares: the free and trim cost on MoltenVK
tests::spares_bench on the M3 Max (MoltenVK 1.4.2, job 12271, the bench
as landed): 6 rounds of 252 command buffers freed 32 at a time, each
followed by vkTrimCommandPool: the frees 0.9 to 1.0 us at the median (1.8
us at the slowest), the trims 0.9 to 1.0 us (3.5 us at the slowest). The
process's physical footprint (proc_pid_rusage's ri_phys_footprint, which
counts the GPU memory the process owns) rose 176 KiB with the first
round's makings (179872 to 180048 KiB) and stayed at 180048 to 180128 KiB
through every free, trim and later round: on MoltenVK the spares' command
buffers grow no owned memory that a trim would return at this scale.

(cherry picked from commit b1ad9d75d87840612b6cabcbcf5f946db6707e24)
2026-11-09 13:22:03 -08:00
Anees Iqbal 9c458c96a6 Spares: a give-back's frees and trims run on the device's free thread
A give-back of a command buffer's pool runs in complete_seen, on the
queue's completion thread, before the command buffer's completed handlers
run and before its waiters are released. Where the give-back freed the
command buffers past the pool's recent uses (or an idle spare's), their
vkFreeCommandBuffers and vkTrimCommandPool ran there: on a Radeon 780M a
median of 1.5 to 1.6 ms (2.2 ms at the slowest) between the status
reading final and the first completed handler, and the same on the
waiter's return, on the guest's frame path.

The giving thread now only takes the command buffers out of the pool
(those past its recent uses, or all an idle spare holds) and posts them,
with the pool, to the device's free thread (free_thread.rs, its existing
bounded queue of 64): the thread frees them FREED_AT_ONCE at a time, the
pool trimmed after each, each inside an exit-guard section, then keeps
the pool among the spares again (the newest, or the oldest for an idle
spare). The pool stays out of the spares meanwhile, so a taker takes
another spare or makes a pool. Where the queue is full, or the thread
cannot start, the frees run on the giving thread inside a section as
before. The device's teardown drains the posted frees before it releases
the spares. With nothing capping a give-back's time any more, a give-back
frees every command buffer past the recent uses, and an idle spare sheds
all it holds, at once: the per-give-back cap of 32 left a burst's pool
holding the rest until it was taken again, which a pool out of the spares
may not be. FreeThread::wait counts its wait as it begins, as before;
drain is the uncounted wait.

Tests: the spares device test now asserts the frees ran on
metal2vulkan-frees alone (Spares::freed_on, test-only), waiting for the
free thread between command buffers, and that the burst's command
buffers go after RECENT_USES + 1 more uses. tests::spares_latency
(ignored, release) times status-final to first completed handler and to
the waiter's return for a give-back that frees a burst's command buffers.

Verified on um790 (job 12334, at this tree):
- Radeon 780M (RADV PHOENIX), --cfg m2v_gpu: clippy clean, runtime suite
  2009/2009; SPARES 3 / 65 / 2 held, freed on ["metal2vulkan-frees"].
- lavapipe, --cfg m2v_cpu_icd: clippy clean, 2012/2012, freed on the
  free thread.
- clippy with no cfg and rustdoc clean.
- Negative (the frees on the giving thread): the device test fails on both,
  freed on ["metal2vulkan-queue-wait-0"].
- spares_latency, release, 32 rounds, two runs each: development
  (203673d873 plus the bench) 1508 and 1596 us median (2156 and 2042 us
  slowest) to the first completed handler for the freeing give-back, 1536
  and 1604 us to the waiter's return; with this change 5.9 and 5.7 us
  (48 and 53 us slowest) and 16.8 and 14.7 us (56 and 63 us slowest).
  Give-backs that free none: 1.6 to 3.0 us either way.

(cherry picked from commit 62307392d4ba2b99ef69b1861cf848f8a5bc6fda)
2026-11-09 13:22:03 -08:00
Anees Iqbal 815661f9ed Layer claims: the loader's own reports of a driver manifest it ignored pass
A host whose Vulkan driver listing keeps a manifest whose library is gone
(a vendor's manifest left behind by a driver no longer installed is
common) makes the loader report it at vkCreateInstance, through the
messenger chained there, as Errors of id name "Loader Message": the
dynamic linker's error about the library, then "loader_icd_scan: Failed
loading library associated with ICD JSON <lib>. Ignoring this JSON"; a
library that loads and gives no vkCreateInstance adds
"loader_scanned_icd_add: Could not get 'vkCreateInstance' via
'vk_icdGetInstanceProcAddr' for ICD <lib>"; one that is no driver gives
"loader_scanned_icd_add: Attempt to retrieve either
'vkGetInstanceProcAddr' or 'vk_icdGetInstanceProcAddr' from ICD <lib>
failed." The layer claims counted them, so every claim failed on such a
host (the Iris Xe's 9 failures beside a stale nvidia_icd.json) with
nothing of the device's.

IgnoredDrivers (the runtime's tests::layer_claim and the validation
crate's runtime_case::layer_claim, each its own copy as for the duplicate
layer warning) collects the libraries the loader said it ignored, and
passes, of id name "Loader Message" alone: that message, the linker's
error that begins with one of those libraries and ": ", and the missing
vkCreateInstance about one of them; and the no-driver message, which
names the library it ignored itself. Each passed message is printed
(LOADER-DRIVER / LANE-LOADER-DRIVER). The runtime's claims, the
validation crate's Messages::take, creation_heard_checked and
resource_ids' message check use it.

Verified: unit tests of the matcher (each report matched; the same words
of another id name, a linker error or missing vkCreateInstance about a
library the loader did not say it ignored, an empty library, other loader
messages, all refused). On lavapipe under m2v_cpu_icd with
VK_DRIVER_FILES naming lavapipe and a scratch manifest naming a missing
library: at development 9b00cd81d6, 12 runtime tests (teardown_threads)
and 2 validation tests fail on the loader's two messages; with this
change, the runtime's 21 pass with LOADER-DRIVER lines.

(cherry picked from commit 3f2a390dcbbc6dc33bc7ed6bc0680109911cdb83)
2026-11-09 12:45:15 -08:00
Anees Iqbal 203673d873 RUNTIME_VERSION 1985 and the runtime-sources pin for spare command pools that follow their uses
733db7a42c changes the runtime's spare command pools: a pool given back keeps, per level, the most
command buffers any of its last 8 uses handed out and frees the rest; the oldest spare idle for
10 s sheds what it holds when a later give-back finds it; each give-back frees at most 32
(vkFreeCommandBuffers, then vkTrimCommandPool, in an exit-guard section on the giving thread).
vkDestroyCommandPool still runs only at teardown (NVIDIA 615.71.09's hang there). reims measured
the old rule's growth on a 780M: every VkCommandBuffer kept for the device's life, 96 KiB of GTT
each, 2668 -> 6970 over 6 guest resets.

Verified by the branch: um790 12300 at the rebased tip, 780M runtime suite 2009/2009 and lavapipe
2012/2012, clippy for both; the device test holds 3, 65, then 2 command buffers (65 after 10 more
with the frees made no-ops, 3 of 11 spares tests failing). Iris Xe and RTX 5080 spares tests pass
(5080 3/3 rounds, no hang). One give-back freeing 32: free 4-103 us, trim 0.4 us-3.0 ms (780M
median 0.65 ms). MoltenVK cost pending. Here: signatures --check, REFUSALS and coverage docs
regenerated, fmt.
2026-11-09 12:41:37 -08:00
Anees Iqbal ac9e2adf62 Spares: a command pool's command buffers follow its recent uses; idle spares shed theirs
A spare command pool kept every command buffer it ever made: each burst of
command buffers at once filled its pools, and they held it for the device's
life. Mesa recycles freed command buffers into their pool and returns their
memory only at vkTrimCommandPool; on RADV each one holds 96 KiB of GTT
(buffer objects of 80 and 16 KiB), which the consumer saw grow without end.

A pool given back now keeps, of each level, as many command buffers as the
most one of its last 8 uses handed out (a secondary at least) and frees the
rest; and the oldest spare no command buffer took for 10 s frees what it
holds as a later give-back finds it, then goes back as the oldest spare. A
give-back frees at most 32: vkFreeCommandBuffers, then vkTrimCommandPool
(release.rs's PoolBuffers), inside an exit-guard section, on the giving
thread. No vkDestroyCommandPool moves off teardown. The device's priming
frees and trims its own command buffers too.

The cost of a give-back freeing 32, tests::spares_bench (ignored, run by
name): Radeon 780M (RADV) 18 to 35 us to free, 0.63 to 0.70 ms median to
trim (3.0 ms slowest), the GTT returned, where 252 at once took 5.2 to
6.3 ms; Iris Xe (ANV) 64 to 103 us and 43 to 47 us; RTX 5080 Laptop
(NVIDIA 615.71.09) 4 to 7 us and 0.4 to 48 us (0.22 ms slowest);
lavapipe a few microseconds.

Verified: tests::spares (CPU tests of the recent-uses and idle rules and a
device test that 64 command buffers at once fall back to 2 after 8 + 2 more
uses) pass on the 780M, lavapipe, Iris Xe and the 5080 (3 rounds); with
development's spares.rs, three of them fail (the device test holds 65+).
The 780M and lavapipe suites passed apart from the device test's first
form (2003/2004, 2006/2007), since fixed to give back past the 32 cap.

(cherry picked from commit 733db7a42c8a0088069a0016ae7d8cf1b0479f4b)
2026-11-09 12:40:50 -08:00
Anees Iqbal f1ffb00d3d Re-bless the authored compile census at d2640d5e7e
Its product fingerprint follows development's versions at d2640d5e7e. Blessed on the
M3 (s37-pl.sh censusbless --bless, dv-m3).

(cherry picked from commit 9c0dea86f1edc7b09c1327dc124a2dc368421694)
2026-11-09 12:40:50 -08:00
Anees Iqbal d2640d5e7e RUNTIME_VERSION 1984 and the runtime-sources pin for plain blocks sized by their making rate
0bec0583b0..076cc7b44e change the runtime's memory: where a plain block's making takes longer than
8 ms, the device's later pooled plain blocks become the largest power of two its measured rate
makes within 8 ms, never below 16 MiB (a placement past that size takes a pooled block of its own
power of two up to 32 MiB, a dedicated one past it); exportable and page blocks stay 64 MiB. On a
Radeon 780M a block's making holds the process's VM reservation, so every submission waited for
it (reims rafgap cause 1: 100-300 ms guest frame stalls on fragmented memory).

Verified by the branch (780M RADV PHOENIX, cold, kernel page pool drained): quiet turnarounds of
8 ms or more 13 -> 0; fragmented, none of 17 ms or more (slowest 14.3 vs 40.0 ms); slowest
creation call 0.6-3.4 vs 22.9-24.9 ms; a 4K render target's own block ~11 ms inline when
fragmented, its slowest creation call 16 vs 26 ms. Runtime lib 780M 2004/2004, lavapipe 2007/2007,
negatives fail. M3 cost --check rc 0 at the tip and with blocks forced to 16 MiB (12237);
device_memory_allocated is reported (BLOCK_SIZE), pooled_memory_blocks_made stays gated. ANV and
NVIDIA per-block costs unaudited (FAST-PATHS). Here: signatures --check, REFUSALS and coverage docs
regenerated, fmt.
2026-11-09 12:29:48 -08:00
Anees Iqbal 0c223395fd Memory: the pooled block sizes' test reader compiled for the device tests alone
Clippy over the runtime crate with no device cfg (as CI runs it) found
Memory::pooled_block_sizes unused: only the device test of plain_blocks.rs
reads it. It is now compiled under the device cfgs, as the module's other
device-test readers are.

(cherry picked from commit 076cc7b44ebb37ca7197a37fb4e9164ea003ea8b)
2026-11-09 12:29:03 -08:00
Anees Iqbal 7a50011e74 Memory: the plain-block rule's ledger row; the cost gate reports device_memory_allocated
docs/FAST-PATHS.md gains the known-gaps row for the measured-rate size of plain blocks: what a
making holds on RADV, the rule, the 780M's numbers against the base (turnarounds, creation calls,
vkQueueSubmit per call, block counts), what a single slow making costs for the device's life, the
drivers left unaudited, and the M3 Max's makings over the conformance cost measurement.

The conformance cost gate reports device_memory_allocated (a new race-rule reason, BLOCK_SIZE)
rather than gating it, because the bytes a case allocates now follow how long the device's
earlier makings took. Measured on the M3 Max, `conformance cost --check` over eight runs of the
whole set (1233 cases): at this tip rc 0, no 64 MiB making past 1.61 ms, the rule never fired;
with the size held at its 16 MiB floor, rc 1 on one case's device_memory_allocated
(201326592 in the record, 50331648 measured), with no gated bound or ceiling of
pooled_memory_blocks_made moving and no case over a bound, so that count stays gated. The
fold test that used device_memory_allocated as a count with no MONOTONE row now uses
owned_kernel_spirv_bytes.

(cherry picked from commit a4246707ec6da2b49342feca48bf9a931e152675)
2026-11-09 12:29:03 -08:00
Anees Iqbal 2daafe221e Memory: plain blocks made smaller where their making is slow
On RADV a block of plain memory (allocated with no export: the blocks of images, of heaps, of
buffers that declare their padding unobserved) shares the reservation of the process's buffer
objects, and its vkAllocateMemory holds every submission of the process while the kernel fills
its pages. On a Radeon 780M with the kernel's page pools empty, a 64 MiB block took 8.9 to 9.6 ms
at the median on a quiet host and up to 23.1 ms (slowest 30.4 ms) with its free memory in single
pages, and a texture made every frame left 13 to 33 turnarounds of 8 ms or more a phase (the
slowest 42.3 ms).

Now a making of such a block that took longer than MAKING_BOUND (8 ms, half a frame at 60 Hz)
makes the device's later pooled blocks of plain memory the largest power of two that making's
rate makes within the bound, at least 16 MiB (Memory::plain_block_made); a placement larger than
such a block takes a pooled block of the power of two that holds it (up to half of BLOCK_BYTES,
past which it is dedicated as before). The size is never made larger again. Exportable blocks
keep 64 MiB: each is a buffer object of its own reservation, whose making holds nothing.

Each made Block records how long its making took (Block::took, zero for imports); add_block
feeds the plain ones to plain_block_made. place, keep_room, ready_if_growing, ready_ahead and
sweep_stale size a pool's blocks through pooled_bytes, and add_ready takes the size of the block
it adds.

tests::plain_blocks: the size rule and the pooled block sizes on the bookkeeping alone, and on a
device told of a slow making, 1 MiB textures in 16 MiB blocks and 20 MiB ones in 32 MiB blocks.
tests::reclaim_submit_bench: an images arm (a 1024x1024 texture a frame) and a mixed one (with
2560x1440 and 3840x2160 textures), the blocks of images made, pooled and dedicated, and the plain
block size reached.

(cherry picked from commit 0bec0583b042c1f2c05b98e97d080e6426d13619)
2026-11-09 12:29:02 -08:00
Anees Iqbal c6243bbd5e blocks_ahead: the hurried-making test holds a use of the queues open
The test of a creation call that cuts a making's wait for quiet short kept the device's queues
in use with three threads that each committed a one-word fill and waited for it. A making's wait
reads the holds of the device's queue locks (device/queue_quiet.rs), not the GPU's work, so a
pause of 1 ms between two of those threads' submissions ends it; on a loaded host the threads
leave such pauses, each making's wait ended before a call needed its block, and the test gave
up after three makings it waited for with none hurried. Pin 30's 5080 runtime half 1 (run
beside half 2) failed so: 0 hurried, 3 made ahead, 28.35 ms at the longest.

Now the test holds one use open (QueueQuiet::began, ended as its guard drops) from before its
first creation, so nothing but the bound (QUIET_MOST) ends a making's wait, and settles the
device's submission checks first, as the first test does, so that no creation call in it makes
the first block of a pool of the runtime's own pages. It stops at the first making a call
hurried, or after three whose wait reached its bound, which only a host slower than 50 ms over
the few creation calls between a making's start and its block's need reaches; it prints those
and the makings waited for.

The exportable pools made ahead (9e663b770c) are not a factor: the test makes no exportable
buffer, so no pool of them grows and that commit's makings never start, and the old test at its
parent failed the same way under load (below).

Verified (debug, --cfg m2v_gpu; load = a busy loop on each of 16 logical CPUs, or four runners
of the whole runtime suite, each test alone):
- Radeon 780M (RADV PHOENIX, Mesa 26.2.6, gem10, MESA_VK_DEVICE_SELECT '1002:15bf!'; job
  m3-max-12248): this test 3 of 3 alone, 10 of 10 under the busy loops, 8 of 8 beside the suite,
  each run 1 making hurried, 0 past its wait, creation calls 2.4 ms at the longest. The old test
  at 9e663b770c's parent failed 1 of 10 under the busy loops (0 hurried, 3 made ahead), and at
  development passed 10 of 10 and 8 of 8. Negative control, ready.rs's wait for quiet ended by
  STOP alone rather than by a call's wait: 0 of 3 (0 hurried, 3 past their wait, 49.6 to
  59.3 ms).
- lavapipe (llvmpipe, LLVM 23.1.4) under --cfg m2v_cpu_icd (job m3-max-12250): 2 of 2 alone,
  10 of 10 under the busy loops; the negative 0 of 2.

Correction at landing: the creation calls took 2.4 ms at the longest in every run but one, an
otherwise idle host's, at 8.0 ms. RTX 5080 (b5080 nvreds-ahead-5080-120327): the new test 3/3
alone, 20/20 beside a suite, 10/10 under busy loops; the old test failed 10 of 20 beside a
suite there (0 hurried, 3 made ahead).
(cherry picked from commit 3691633773)
2026-11-09 12:26:07 -08:00
Anees Iqbal 9b00cd81d6 RUNTIME_VERSION 1983 and the runtime-sources pin for listed plans that ask the driver first
77f336e98c changes the runtime's guest RAM: run-list imports consult the device's remembered
dma-buf refusal (and remember the driver's own refusal of a list), and a use whose plan would be
listed first asks the driver with one page of the RAM (Device::ram_takes_dma_bufs), listing only
where the driver took it, so a taxed NVIDIA keeps 64 MiB chunks by pointer. The host_ram_dma_buf
tests force the tax held and read the plan the device chose. Pin 30's 5080 red
copies_over_a_listed_ram_make_no_untouched_page_of_it_resident was this.

Verified by the branch: RTX 5080 (b5080 exitcrash-follow-112525) dma-buf module 10/10 twice, the
driver refusing the use's question for real; the old tests with the tax forced held fail 3 of 4
there; gem10 lavapipe 12205 (suite 2007/2007, clippy x3, rustdoc), 12213 fast_paths/docs 27/27;
780M 12209 module 10/10 twice (listed, run lists used). Negative controls for each part fail.
Here: signatures --check, REFUSALS and coverage docs regenerated, fmt.
2026-11-09 11:40:32 -08:00
Anees Iqbal 7d17fb1882 Guest RAM: a refused dma-buf keeps run lists and listed plans off the driver
Three follow-ups to remembering a driver's refusal of a guest RAM's dma-buf
(3fe18c4efd):

1. Run-list imports consult the remembered refusal. ram_runs_as_dma_buf now
   returns not-importable, the source of run lists unasked, once the device
   remembers a refusal, and remembers the driver's own refusal of a list's
   dma-buf the same way a span's is (the source's failures stay the list's
   alone). Before, every copy over a chunk not imported asked the source of
   run lists again and paid a udmabuf and a failed import.

2. A RAM's plan asks the driver before it lists the RAM. Plan::listed means
   the RAM's chunks are its dma-bufs; it was chosen from the import tax alone,
   so on a taxed driver that refuses udmabufs (NVIDIA 615.71.09) the RAM got
   512 MiB chunks imported by pointer, none ahead. ram_plan now, where the plan
   would be listed, asks the driver with the RAM's first host page
   (Device::ram_takes_dma_bufs: ram_span_as_dma_buf over one page, released at
   once, the precedent being shared_refused's one-page question), and lists the
   RAM only where the driver took it. A refusal there is counted and
   remembered, so the RAM and every RAM after it keep 64 MiB chunks imported
   ahead by pointer. Re-choosing a live RAM's plan was rejected: its chunk
   geometry and its thread are fixed when the use begins. discard_import takes
   the raw VkBuffer so the question's import can be released.

3. The listed tests (where_each_listed_import_costs..., where_the_ram_fits...,
   the two tile tests through copies_by_lists) no longer expect dma-buf imports
   wherever the measured tax holds. They force the tax held, so the listed path
   runs on every device in every run, and read the plan the device chose
   (Device::host_ram_chunks), asserting it is listed exactly where the device
   imports dma-bufs and the driver took the use's page. The resident test now
   allows the use its one page.

Tests:
- a_driver_s_refused_dma_buf_sends_copies_past_the_source_of_run_lists (new):
  stand-in refusal set after a listed use; the first copy asks the source of
  run lists once and the source of dma-bufs not at all, the second asks
  neither (fails without the consult or without remembering a list's refusal).
- a_driver_s_refusal_as_the_use_begins_keeps_the_ram_s_chunks_short (new):
  stand-in refusal before the use; the RAM is not listed, the source asked for
  the first page only, the refusal counted once (fails without 2).
- a_driver_s_refused_dma_buf_sends_the_device_s_later_chunks_to_their_pointer:
  the stand-in now refuses after the use; a RAM used after the refusal is not
  listed and its source is unasked.
- The route test reads the use's question and the plan.

Docs: host_ram module, use_host_ram, WorkCounts, HOWTO and the FAST-PATHS
NVIDIA dma-buf row describe the question and the remembered refusal.

Verification: in the follow-up message (gem10 lavapipe suite and negative
controls; 5080 release).

(cherry picked from commit 77f336e98c2a31aa56e45c5eb7659fa28f6f3ad6)
2026-11-09 11:39:45 -08:00
Anees Iqbal 0d45d4f9d5 RUNTIME_VERSION 1982 and the runtime-sources pin for a kernel end stamped at the submit call
58e674d802 changes the runtime's kernelEndTime: the host time read right before the last batch's
vkQueueSubmit is called, not after it returned. Pin 30's lavapipe replay (6efa9fe7b9, beside the
suites' load) read gpu-ends-no-earlier-than-the-kernel false once: a scheduler thread parked after
the call let the GPU finish before the stamp. Exact 10/10 alone (gem10 12182).

Verified by the branch: kernel_end_device's paused-scheduler test 12/12 on lavapipe (gem10 12184:
suite 2003/2003, clippy x3, rustdoc), its negative control failing (GPU end 199.6 ms before the
kernel end); M3 MoltenVK 3/3 and the gpu_time, unsubmitted, completion and command_buffer tests
82/82 (12187). Not run on NVIDIA. Here: signatures --check, REFUSALS and coverage docs regenerated,
fmt.
2026-11-09 11:11:20 -08:00
Anees Iqbal 4499666bd6 Kernel end: the host time the last batch's vkQueueSubmit was called, never after it returned
Pin 30's lavapipe replay (6efa9fe7b9, on msi beside the suites and lint) answered
command-buffer-facts' gpu-ends-no-earlier-than-the-kernel false where Metal answers true: a command
buffer's GPU end before its kernel end. The scheduler took the kernel end after Group::submit
returned (submit.rs, and group.rs for the held batches), so a driver that runs the work before the
call returns, or a scheduler thread held once it returned while the GPU ran the work, put the
kernel end past the GPU's (calibrated) end. tests/completion.rs already records an RTX 3090 whose
submission returned 57 to 64 ms after its work ran.

The time is now taken inside the submission's closure, just before raw.queue_submit, and returned
by Group::submit and submit_alone; the direct path and the group's held batches stamp their kernel
end with it, only on success. Nothing reaches the GPU before the call, so its end is never earlier.
The held-in-a-group, unsubmitted and hang paths already stamp before any submission. The start,
the GPU times' placement and the other ordering facts are unchanged; the docs of kernel_end_time,
KernelTimes and gpu_time.rs's kernel times say what the end is now.

Test: kernel_end_device::the_gpu_end_is_never_before_the_kernel_end_when_the_scheduler_pauses_after_the_call
pauses the scheduler 200 ms each time a submission returned (completion::trace::pause_after_submit,
a test stand-in under the device tests' cfg, called in submit.rs after the call) while a 1 MiB fill
runs, and asserts GPU end >= kernel end and GPU start >= kernel start over four command buffers.

(cherry picked from commit 58e674d802a70a7e5573edd900fcb96e2d9ed7ca)
2026-11-09 11:10:36 -08:00
Anees Iqbal c148f594ff RUNTIME_VERSION 1981 and the runtime-sources pin for guest RAM's remembered dma-buf refusals
a6ccb78810..abddf2d2f1 change the runtime: a guest RAM span's dma-buf that fails on a device that
imports dma-bufs is counted (WorkCounts::host_ram_dma_buf_imports_failed); a driver's refusal of
one is remembered for the device's life, so its later chunks take their pointer without asking the
source (NVIDIA refuses every udmabuf import and lets go of one descriptor each time); and an import
tax Holds short of TAX_MARGIN answers Fails for the device's life, unrecorded, as split tries
short of it do since 4acfbee03b. Pin 29's 5080 runtime half failed the route test when that
process measured the tax held (the driver refused, the pointer took it, nothing counted it).

Verified by the branch: gem10 lavapipe 12177 (suite 2004/2004, the translator's surface and
fast_paths tests, clippy x3, rustdoc; the new test fails with the remembering removed, the source
asked twice); RTX 5080 release (b5080 exitcrash-taxroute2-104522): the route test with NVIDIA's
refusal 15/15 (3 quiet, 12 loaded beside 35 host-RAM tests a loop), every loaded device measuring
the tax not held; before the fix the forced route failed 2/2 (ERROR_OUT_OF_DEVICE_MEMORY). Here:
signatures --check, REFUSALS and coverage docs regenerated, fmt.
Open: run-list imports and a RAM's Plan::listed do not consult the remembered refusal; three other
host_ram_dma_buf tests still expect dma-buf imports wherever the measured tax holds.
2026-11-09 11:06:03 -08:00
Anees Iqbal 3fe18c4efd Guest RAM: a driver's refusal of a span's dma-buf is remembered for the device's life
Counting the refusal left its cost: on a device whose import tax holds and whose driver refuses
every udmabuf (NVIDIA 615.71.09, FAST-PATHS), every guest-RAM chunk asked the source for a dma-buf,
failed vkAllocateMemory, let go of one descriptor (the driver closes the clone it was handed) and
only then took its pointer.

ram_span_as_dma_buf now tells the source's failures (an error, or an answer of other lengths:
that span's alone, counted) from the driver's (anything once the source answered one dma-buf of
the span: its memory types, the buffer, the import, the bind). A driver's refusal is counted once
and remembered in the device's RamSource; every later span is refused at once, unasked and
uncounted, and takes its pointer. The decision reads the device's own answer, never its identity.
A transient failure of the driver's (memory that ran out) is remembered the same way, recorded in
FAST-PATHS' NVIDIA row.

Tests: a_driver_s_refused_dma_buf_sends_the_device_s_later_chunks_to_their_pointer forces the tax
held and refuses every dma-buf import through a test stand-in for the driver (Memory::import_refusal,
cfg(test), answered where the driver's import would run), on every device that imports dma-bufs:
two chunks, the source asked once, the failed count 1, the second chunk by its pointer. The route
test, where the driver itself refused (NVIDIA's), makes a buffer over the RAM's second chunk and
asserts the same with the real driver. Without the remembering both ask the source a second time.

(cherry picked from commit abddf2d2f1ed16a5ee6407cae04f7e10dfffb736)
2026-11-09 11:05:12 -08:00
Anees Iqbal c6be8ef2d8 Submission checks' report: an import tax Holds short of its margin is named
The report showed only the Fails it answered, beside floors that may pass the bound; the flag says
the margin's rule ran (the evidence for the change before this one's path).

(cherry picked from commit deccce5b26744b591df0dc9988d4827adef30b16)
2026-11-09 11:05:12 -08:00
Anees Iqbal a7dde1cba9 where_the_import_tax_holds_a_chunk_takes_its_dma_buf_first: the report read before the force
The report printed after the force named the forced Holds beside the measured floors (lavapipe
12153: "measured not held: ... import tax Holds (0.7 ... against 0.7 us)").

(cherry picked from commit 72e91bb5df25293f1a5257ebe29ea427d01bd35c)
2026-11-09 11:05:12 -08:00
Anees Iqbal 178ace2529 where_the_import_tax_holds_a_chunk_takes_its_dma_buf_first: print the checks' report beside the measured verdict
The verdict the device measured, with its floors, is the evidence of which route its process
would have taken; the forced route no longer shows it.

(cherry picked from commit a7afbb370f689fd3d75e664099083905a3a2fd6f)
2026-11-09 11:05:12 -08:00
Anees Iqbal ee7a6e2e22 Import tax: a Holds short of its margin answers Fails for the device's life, unrecorded
A loaded process concluded a tax its quiet ones never see. On the RTX 5080 Laptop GPU (615.71.09),
the route test run 3 times quiet and 5 times beside a loop of the host-RAM and host-residency
device tests (b5080 t entry exitcrash-dmabuf-100324, probe 3f3ca70d32): every quiet device answered
Fails, 2.1 to 2.2 us a submission with the 32 imports held and without alike; the first loaded one
answered Holds from 3.4 against 1.9 us, both halves agreeing, past the 1 us bound but short of
TAX_MARGIN (2 us), and so took the routes of a taxed device (its guest RAM dma-buf first) for its
life. lavapipe's loaded Holds (1.4 against 0.2 us, in the module docs) was the same shape. The
margin already kept such answers out of the records; now a Holds short of it answers Fails, as the
taxsplit change made tries that all split short of it answer, and the next device measures again.
A Holds past the margin stands, recorded only where its repeats pass it again, as before. The taxes
the probe measured (RADV, ANV with 32 imports held) pass the bound six times over and more.

The unit test an_import_tax_holds_short_of_its_margin_answers_fails_unrecorded takes the 5080's and
lavapipe's loaded floors; without this change both answer Holds. The lavapipe case leaves
an_import_tax_holds_is_recorded_only_past_its_margin_and_repeated, which asserted the old answer.
Module docs, TAX_MARGIN's and tax_tried's docs updated; no record changes (CHECK_VERSION stays).

(cherry picked from commit 4c2760204e17687d07fdf7a3cd40b5653f4565d2)
2026-11-09 11:05:12 -08:00
Anees Iqbal 98729ad0de Guest RAM: a chunk's dma-buf the driver refuses is counted; the route test forces the tax held
On the RTX 5080 (NVIDIA 615.71.09) pin 29's runtime half failed
host_ram_dma_buf::a_ram_with_a_source_takes_the_route_its_device_s_checks_choose: that process's
import tax answered Holds, the chunk went dma-buf first, the source was asked, and no dma-buf was
imported. A probe printed the refusal: vkGetMemoryFdPropertiesKHR gives the udmabuf types 0x9,
the buffer takes 0x1f, and vkAllocateMemory answers ERROR_OUT_OF_DEVICE_MEMORY (the refusal
FAST-PATHS already records for NVIDIA). import_chunk dropped that error and took the pointer, as
it should, but nothing counted it, and the test held every taxed device to a dma-buf import.

- WorkCounts::host_ram_dma_buf_imports_failed counts a guest RAM span's dma-buf that failed on a
  device that imports dma-bufs (the source failed or answered other lengths, or the driver
  refused it); ram_span_as_dma_buf counts it past its device check.
- The route test (now where_the_import_tax_holds_a_chunk_takes_its_dma_buf_first) forces the tax
  held, as the pointer-first test forces it not held, so the taxed route runs on every device in
  every run, not only in a process whose check measured a tax. It asserts the source asked once
  for the chunk, and the dma-buf imported or refused and counted, the pointer then taking it; it
  prints the verdict the device measured beside it.
- HOWTO, FAST-PATHS' NVIDIA dma-buf row, host_ram's docs and the API signature table name the
  count.

Verified: the probe at 3f3ca70d32 on the 5080 (b5080 t entry exitcrash-dmabuf-100324): with the tax
forced held, 2 of 2 runs failed the old assertion with the refusal above; quiet runs measured the
tax not held (3 of 3). This commit's own runs are in the next evidence.

(cherry picked from commit a6ccb78810867a4d567892feee4b3b56ba1af834)
2026-11-09 11:05:12 -08:00
Anees Iqbal 8c36a3e1e5 Re-bless the authored compile census at 6efa9fe7b9
Its product fingerprint follows development's versions at 6efa9fe7b9. Blessed on the
M3 (s37-pl.sh censusbless --bless, dv-m3).

(cherry picked from commit e7d054f4c02a6de837056aad659cb800e8b0a7c9)
2026-11-09 10:57:55 -08:00
Anees Iqbal 6efa9fe7b9 RUNTIME_VERSION 1980, the runtime-sources pin and the API table for recovery 1c
1c (eac07b1f9a..e64d7a7e7a, 14 commits) puts the program's host-visible buffers in blocks of the
runtime's own pages where the device's checks give them what plain blocks do (the import tax
answered Fails and the fresh pages' texture verdicts hold), and a recovery carries those blocks to
the new VkDevice, so pooled Shared and Managed buffers are no longer refused as MadeBeforeRecovery
there. While a verdict is pending, and under exact_answers' Shadow policy, plain blocks serve.

API table: two WorkCounts fields added, page_buffer_blocks_made and page_buffer_blocks_plain
(additions only; nothing a consumer used moved).

Verified by the branch at 951f9244cc (the same product code on 47e072ccd3): M3 percall gate with
holds green at base and 1c, allocs/call identical, both-orders A/B with no row past 15% in both
orders (m3-max-12032); RTX 5080 percall gate green in all four runs, allocs/call identical but one
first-run row, padding_unobserved / hand_out_waits / device_recovery_carry pass; one more pooled
block at rest (the page block beside the plain one, lavapipe 12062). Open: on the 5080
use_resource_read_write and use_resources_read_1 read x1.25 and x1.32 in both orders, unexplained;
an M3 runtime-suite window test failed once in 10 runs at 1c (hunt running). Here: signatures
blessed, REFUSALS and coverage docs regenerated, fmt.
2026-11-09 09:52:56 -08:00
Anees Iqbal 76d5571193 padding_unobserved: print where each undeclared buffer lies and the checks that decide it
On the M3 the test's undeclared Shared buffers lay in plain blocks at every pitch (m3-max-12032)
while the recovery test's pooled buffer lay in a block of the runtime's own pages. The line each
pitch prints now names the block the undeclared buffer lies in, and a line before them says
whether the device's submission check found a held import costs nothing and whether it takes
those blocks. Diagnostics only.

(cherry picked from commit e64d7a7e7aa8189f3b878299afb2268d12f66920)
2026-11-09 09:51:55 -08:00