A pipeline making in progress when the process's exit began could let a driver compiler (LLVM's, under
lavapipe; NVIDIA's libnvidia-glvkspirv on the 5080) register destructors after the hook's last
registration, which then ran before the hook, beside the making: exit_guard's documented hole, the
class of reims's exit SIGSEGVs after 'test result: ok'. While a making is in progress in a section,
a runtime thread now registers the hook again every 2 ms, at most 16384 times a process (exitcrash,
a3bd94ba66). The exits lane gains the released-import and first-making cases, a case without the
validation layer, and ends every child's exit at the mark after its first device once the hook ran
(64a00697f4..4b91b2ba92). Runtime sources re-pinned.
Verified: the doc checks in the landing tree. The change's own evidence: exit_guard 47/47 x3 on gem10
with the new an_exit_mid_making_waits_for_it_before_a_destructor_the_making_registered, failing (43)
with the registration removed; the 5080 tip run is a check on development.
What: every child registers after_the_later_devices right after its first device (before, only
instance_after_handler_exit and making_exit did), and the mark prints whether the hook ran by then
(hook_ran). exits_cleanly counts an exit up to the mark where the hook ran before it, and the
first device's driver's and layer's handlers after it are printed, not bounded; where the hook ran
after the mark (no registration of it followed the device), the exit is counted to its end, as
before.
Why: on the RTX 5080 laptop, three exits tests failed in the exits module run beside another
entry (perdraw6-exitmark: an_exit_runs_no_handler_beside_a_cpu_device_s_work,
an_exit_while_a_host_step_waits_is_clean, an_exit_while_submitting_is_clean), and in 200 exits of
the lane's children 12 at once (entry exitcrash-four-and-loop-1) host_step_pending_exit,
submitting_exit and handler_learns_exit ended their handlers 1.53 to 1.60 s after their last line,
past EXIT_LIMIT. The handlers registered as the device was made, NVIDIA's and the layer's, took
495 ms of instance_after_handler_exit's exit alone and 7.1 s in that loop, and 1.5 to 5.9 s of
making_exit's beside the runtime suite (a1edaca06b), where the rest of the exit took 2 to 41 ms.
That is the driver's own exit, which the hook neither waits for nor shortens.
How verified: the lane's exits on the RTX 5080 and lavapipe follow (the mark's split per case).
(cherry picked from commit 4b91b2ba925892f7176c4cba988b4c7eb77d8f33)
What: a thread of the runtime's, the registrar, started at the process's first making in a
section (a pool's piece's, a host step's) and parked while none is in progress, registers the
exit hook again every MAKING_INTERVAL (2 ms) while one is, at most MAKING_REGISTRATIONS (16384,
512 KiB of the C library's list of exit handlers) times in a process, until the guard closes.
Registrations counts them (during_makings), and the lane's bound on the sections' registrations
leaves them out.
Why: a driver's compiler makes statics at its first use of a path, and registers their
destructors then, inside the making. The hook was registered again only after a making returned,
so an exit that began mid-making ran those destructors before the hook, while the making still
compiled. Measured with an LD_PRELOAD shim that logs every exit handler registered after the
hook's first registration and the order they run in (lavapipe, Mesa 26.2.4, LLVM 23, the exits
lane's first_making_exit): in 1 of 3 exits, three destructors LLVM registered on a driver's
thread 1 to 2 ms before the exit ran first, and that thread registered three more once the exit
began. That is the module docs' hole ("a static first made by a making in progress as the exit
begins"), and the shape of the consumer's NVIDIA exit faults in libnvidia-glvkspirv. Now such a
destructor runs after the hook once 2 ms passed, and the hook waits for the making first. The
hole left is the last interval before the exit, makings past the bound, and the program's own
makings, which the hook does not wait for.
How verified: the new unit test
an_exit_mid_making_waits_for_it_before_a_destructor_the_making_registered forks a child whose
piece registers a destructor inside its making and exits once the registrar registered after it;
without the registrar the destructor runs beside the making (43). Build and test runs follow on
Linux (gem10) and the RTX 5080.
(cherry picked from commit a3bd94ba669c67fa1c34b9d9a4974f37b5e8979c)
reims-vgpu's pin-22 run on the RTX 5080 Laptop GPU ended one test process with SIGSEGV
after its test had passed (a_released_surface_texture_keeps_the_surfaces_memory_while_
imported): a texture over a surface's pages released while a command buffer that binds the
device's heap set ran, then the process's exit with the runtime still releasing.
Two child cases in that shape: a texture over a no-copy buffer of fresh host pages (its
deallocator unmaps them), released once a command buffer of fills (about 60 ms on a GPU)
and a dispatch that reads another texture through its ID is scheduled; twice. Then either
the device is kept for the process's life and the rest let go of as main returns
(released_import_exit), or the second command buffer's completed handler tells the
program, which let go of everything, and it exits at once, the device's last reference
going on the handler thread (released_import_teardown_exit). The parent test
exits_after_a_released_import_are_clean runs both, alone in the suite like the other
exit-timing tests.
Not yet run: built and looped under load next.
(cherry picked from commit 64a00697f47a7c7047c60b75d11ea7a537cbcfd6)
On plans that are not listed, copy_take now answers ThroughCpu for a gather over a chunk the device's
thread will import, so no gather imports its own ranges on the encoding thread (radvruns, 40d18ec325 +
3dbab04a58). On the RTX 5080 such an import (a host-pointer vkAllocateMemory) held the caller for tens
to hundreds of milliseconds, and with three clips several such imports and every other thread's
submissions met behind the driver's lock: reims's 4K fills took 3.4-327 ms, and 1.4-2.1 s with three
clips. Scatters, listed plans and gathers the CPU path cannot take keep the imports' path. Runtime
sources re-pinned.
Verified: the doc checks in the landing tree. The change's own evidence: gem10 8968 (clippy x3,
rustdoc, a_first_gather_of_few_ranges_imports_nothing_on_the_encoding_thread passing, its negative
control failing, lavapipe 1907/1908 with the owned-kernel test fixed on development by 290748e457).
The 5080 before/after is a check on development.
copy_take answered Now for a gather over a chunk not imported yet whenever
its ranges, joined where under 2 MiB apart, were at most 16 and none was
the whole chunk. The copy then imported those ranges alone on the encoding
thread. With runs scattered over a chunk, the joined ranges cover nearly
all of it. On the RTX 5080 Laptop GPU a 24 MiB cache of 2,477 runs over
five chunks, its runs joined where under 1 MiB apart, pinned 317 MiB in
61 ms (irisperf's first-fill bench), where the CPU copied the same runs
in 2.8 ms. The bench's first call took 105 to 107 ms with import waits of
0, so the staged path (RT 1893) never ran: it covered only gathers that
would otherwise wait. The consumer's mid-playback fills of new 4K
surfaces took 3.4 to 327 ms with one clip and 1.4 to 2.1 s with three.
Now, on a plan that is not listed and with the device's thread running,
a gather over such a chunk is ThroughCpu however few its ranges. It is
staged through the command buffer's arena, filled by the CPU at its
batch's host step, and the chunk is asked of the thread. A gather the
CPU path cannot take (its bytes possibly written by another use, no
staging memory) still takes the imports' path. So do scatters and
listed plans, as before.
Docs: copy_take, the copy module's first-touch bullet, the staging
check, and HOWTO's copy section.
Test: host_ram_copy_device::a_first_gather_of_few_ranges_imports_nothing_on_the_encoding_thread.
It gathers three pages within 2 MiB in one chunk and one in another,
which before this change was an import of the ranges alone. It asserts
no run import is live once the gather is encoded, the gather is staged,
it waits for no import, and it reads the pages. The negative control is
the old match order; it should fail on any device without
AliasedImportBlitsUnordered. Not run yet.
(cherry picked from commit 3dbab04a5849524c694c74aaea52b776cbef6dd2)
host_ram_contended_fill_bench (ignored, release, --cfg m2v_gpu) uses a
4 GiB fresh memfd RAM. Three threads each fill seven new surfaces; each
surface is either a 4K NV12 frame's 3040 single pages or a P010 frame's
6080, over three chunks no surface took before. Each fill is one
copy_from_host_ram into a new Private buffer, committed and waited for,
as the consumer's decoder fills each new output surface. A fourth thread
meanwhile imports and frees a no-copy buffer over 32 MiB of fresh
anonymous pages every 20 ms. CONTENDED-FILL lines print the calls' and
completions' median, p90 and slowest per surface kind, plus the copies'
staged, import-wait and chunk-import counts and times.
The consumer measured 3.4 to 327 ms for such a call with one clip, and
1355 and 2055 ms with three, on the RTX 5080 Laptop GPU. Fresh::of
takes the RAM's length.
(cherry picked from commit 40d18ec32589c55e6b56b783d479f6cdd5447b4e)
The RTX 5080's measurement of its own (an exclusive window, 12 blocks a
size): vkAllocateMemory of a pool block's memory takes about 0.16 ms a
MiB, idle or beside another process's GPU work (medians 5.5, 11.0, 20.4
and 40.6 ms for 32, 64, 128 and 254.7 MiB), vkFreeMemory about 0.035 ms
a MiB, and every vkQueueSubmit another thread calls during either
returns once it does. Frames every 16.7 ms met a 254.7 MiB making 28.6
to 48.6 ms late on their own thread (23 of 23 over 1 ms), and up to 67.5
ms with the making on another thread, spread over the frame or right
after a submission (11 of 23 either way). So no block is made ahead on
a thread of the device's own: it would not keep frames from the hold.
A smaller block would shorten it in proportion, at the cost of each
command buffer's pool capacity, which is the orchestrator's call.
Verified: docs only; the numbers are entry
poolwait-poolwait-sizes-063031-063031 (7eb0aab5e5's allocation_holds).
(cherry picked from commit f3e209f7ea255d79ef6b524bd1dcd176e9792589)
b4bf228df9 (radvruns): CommandQueue::with_vk_queue calls f(&ash::Device, vk::Queue, u32), the
device the serving generation's, read under the queue's lock, so a caller that made objects with an
earlier generation's handles (Device::raw) sees a recovery atomically and makes them again (reims's
vaplanes copier met the new generation's queue with the lost one's command buffers). The runtime
submits nothing differently.
Verified: signatures --check exit 0 and the pin in the landing tree. The change's own evidence:
gem10 8912 (clippy x3, rustdoc, lavapipe 1907/1908 with the owned-kernel test failure fixed on
development by 290748e457, the new device_recovery test), um790 780M 8911 (device_recovery 9/9).
`CommandQueue::with_vk_queue` now calls `f(&ash::Device, vk::Queue, u32)`. The
device is the serving generation's, read under the queue's lock with the
VkQueue. After a recovery the queue lends the new VkDevice's VkQueue. Until
now a caller could get the device only from `Device::raw` handles it had
cached, and after a recovery those name the lost VkDevice. The consumer's
copier did exactly that: it submitted command buffers from a pool made on the
lost device to the new device's queue, and the process died inside RADV
(a segfault at null+0x50 in libvulkan_radeon.so, right after our "VkDevice
was lost and made again" log). No call let it see the change atomically.
Every call site in the runtime, its examples and the validation lanes takes
the new argument. The runtime README's interop and "A lost device" sections,
`Device::raw`'s docs and docs/API.md's device-recovered entry say what the
closure gets. api_signatures.tsv is re-blessed (one signature changed).
Test: device_recovery::a_lent_queue_names_the_vk_device_it_belongs_to_across_a_recovery.
It reads the lent queue's device before and after recover_for_test. The two
differ, and the second equals what Device::raw answers after the recovery.
The test also asserts the old route is wrong: the raw handle cached before the
recovery differs from the lent queue's device after it. That cached handle was
the only source of the device under the old signature.
(cherry picked from commit b4bf228df9db98a451c997f350c6014b027f7e31)
air11 (8fff014bca, c27da64aaf, b500dc8717): air.compile_options accepts an option that repeats what it
already stated (a linked module's merged list; macOS 11's Core Image kernels), and the bitcode reader
reads module version 1 (names from the module VALUE_SYMTAB, both of its layouts; one macOS 11
framework's clear pipeline). Both were refused before, so translation outcomes change for those
inputs.
Verified: the doc checks in the landing tree (signatures --check exit 0, refusal surface,
conformance coverage). The change's own evidence: msi m3-max-8930/8935 (metal2vulkan-air 526 passed;
every public fixture re-emitted as version 1 decodes alike, 658 compared; engine fixtures translate to
identical SPIR-V, 1046 alike and 369 refused alike; goldens unchanged; clippy clean).
The module-level symbol table reader (bitcode/module.rs, Names::read)
refuses a summary-index entry (VST_COMBINED_ENTRY) as
Unsupported(BitcodeRecord), a new construction site of that variant.
Generated with python3 scripts/refusal-surface/refusal_surface.py.
(cherry picked from commit b500dc8717a4dd60f84eb775fa0a70446db44cd6)
A framework pipeline (`clear_vertex`/`clear_fragment`) on reims-vgpu's
macOS 11.7.11 guest was refused 31 times with
`UnsupportedBitcodeVersion { version: 1 }`: the reader took only module
version 2.
LLVM's version 1 numbers values relatively, as version 2 does, but has
no string table: its GLOBALVAR and FUNCTION records carry no name fields
(LLVM's reader strips them with `readNameFromStrtab` only when
`UseStrtab`), and the module-level VALUE_SYMTAB names each global and
function by value id: `VST_ENTRY [valueid, namechar x N]` and
`VST_FNENTRY [valueid, offset, namechar x N]`. LLVM 3.8 and later write
that table after the function blocks with `VSTOFFSET`; earlier writers
put it ahead of them, with no offsets.
The decoder's first pass over the top level now also reads a version-1
module's symbol table (the module-level records read past, every other
block skipped by its length word), so names are known when the records
are decoded: the intrinsic classification of a declaration happens at
its record, before the bodies that call it. The record parsers index
their fields from `type`, after the version-2 name fields when there
are any. The cross-check of function blocks against the table keeps
version 2's rules; in version 1 a defined function without a
`VST_FNENTRY` (an unnamed one, which LLVM's version-1 writer gives no
entry; or every function before 3.8) is found by record order, as LLVM's
reader finds it, and a table with offsets still needs `VSTOFFSET`.
Malformed tables are typed refusals at their record: two names for one
value, a name for no global or function, a NUL or a non-byte in a name,
a block name at module level, a function offset on a global or a
declaration, two module tables; a summary-index entry is `Unsupported`.
Names are charged to the meter before they are copied. Version 0
(absolute value ids) stays refused.
Tests: air's synthetic version-1 twins of the module-level and body
modules (`a_version_1_module_decodes_as_its_version_2_twin`,
`a_version_1_body_decodes_as_its_version_2_twin`, both layouts, an
unnamed function), the error cases, mutation of both; the translator's
`module_version_1` re-emits every public fixture in version 1 (as LLVM's
version-1 writer laid it out) and requires the same decoded module and
ABI, and for every engine fixture's entries the same SPIR-V words,
passing spirv-val.
(cherry picked from commit c27da64aafa87194547223d8b70e052cf5ff795f)
`!air.compile_options` refused any option read twice, an equal repeat
included (`slot.replace(value).is_some()`, and a second
`denorms_disable`). Core Image on macOS 11 links its kernels at run time,
and the linked module's merged option list repeats options: reims-vgpu's
macOS 11.7.11 guest got 15 pipeline-create refusals for `ciKernelMain`,
`Abi(BadValue)` at `air.compile_options`.
A repeat now states nothing new and is accepted. An option stated both
enabled and disabled keeps its typed refusal (`BadValue`): the format
gives neither precedence.
Tests: `a_repeated_compile_option_states_it_once` (every option repeated,
whole list twice and adjacent repeats), and `closed_module_level_sets`
now also refuses a conflict that follows an equal repeat.
(cherry picked from commit 8fff014bca534bfeaf2cb550bb26a11ffc53745e)
0008710e8e counts the YCbCr conversion's kernel builds at a texture's first conversion, where
d119fdeca7 moved them; 9493894b26 records the short last row's shadow among FAST-PATHS's known gaps
and in InPlaceRefusal::Placement's doc. Verified: the pin recomputed and signatures --check in the
landing tree; the test's own evidence (um870 lavapipe 8933, 3/3 x3) in its commit.
A texture over host pages whose buffer ends inside its last row's pitch is a shadow
(Refused(Placement)): a linear image's last row takes the whole pitch, so the image's memory
requirements reach past the buffer's bytes, over an import of the caller's pages and over a copied
host buffer's copy alike, whose placement is the buffer's length. Metal reads such a texture in
place, so it is a runtime cost above the driver's: docs/FAST-PATHS.md's known gaps now say so, and
InPlaceRefusal::Placement's doc names the case.
Seen on the Iris Xe (ANV) and the 780M and RX 550 (RADV) by a probe at the guest's shape, which
stays on a branch of its own.
Verified: cargo fmt; scripts/api-signatures --check (signatures unchanged; a doc change).
(cherry picked from commit 9493894b26cee3b1a525d9a0916a83f3fc6a594f)
d119fdeca7 made a two-plane YCbCr texture's conversion (its staging buffer, sets and refresh, and
with them the conversion's kernels) at the texture's first conversion instead of at its making, so
the test, which counted them at the making, read 0 kernels and failed on every device.
The test now counts each step apart: the making builds no kernel and takes no scratch; the first
conversion (a read() of the texture, which reads the converted image) builds the kernels and takes
the texture's scratch; the next conversion builds and takes none; a second texture over the same
surface builds none at its first conversion and takes scratch of its own. ycbcr_in_place_loop's
read is split into reader (the pipeline state, made outside the counts) and read_with (a grid of
texels), which the test shares.
Verified: cargo fmt; the device test runs as a potluck job after this commit.
(cherry picked from commit 0008710e8ece5cadf96ce3761419a0cb009e2edb)
Its product fingerprint follows development's versions at 0164fee7da. Blessed on the
M3 (s37-pl.sh censusbless --bless, dv-m3).
(cherry picked from commit bd9d9b89f85f1b30660bd0451a473fdc119725af)
Translation changed at f84816ddec (SEMANTICS_VERSION 1993). Blessed on the M3
(s37-pl.sh bless, dv-golden).
(cherry picked from commit 0164fee7da0c9e51459b2c8465c8b7df73c8d1e0)
A no-copy buffer's or texture's dma-buf import (dma_buf.rs import_chunks, and textures over
dma-buf pages) called vkAllocateMemory with the device's memory lock held, so every other making,
placement or free on any thread waited for the driver's import: 62 to 273 ms on the Radeon 780M in
reims's boots (8588, 8866). It now chooses the type under the lock, imports without it and records
the import under it, as pointer imports already did (radvruns, 66f69a827a..93437d2586). Runtime
sources re-pinned.
Verified: the doc checks in the landing tree. The change's own evidence: 780M gem10 8861
makings_beside_a_dma_buf_import_in_the_driver_wait_for_none_of_it (a placement 0.170 ms, a pointer
import 0.248 ms beside a held import; the negative control waits past 5 s), 91/91 in the dma-buf,
residency, in-place, export, host RAM and YCbCr suites; clippy x3 and rustdoc (8829).
The 780M run of the timed test at 97594efec3 (job 8861) showed the same
placements with the lock held across the import and with it released:
median 0.003 ms, slowest 0.87 ms against 0.79 ms. Its placements were
4 KiB buffers dropped at once, so each later one was a parked buffer of
the same making (recycle.rs). That path takes no memory lock, so the run
never measured the wait the fix removes.
The placing thread now times each wait for lock(&shared.memory) itself.
It also keeps the buffers it places, at most 4096, so none is taken from
the parked and each placement takes the lock. Printed: the import times,
the lock waits (median, slowest, count past 1 ms) and the placements'
(median, slowest, count past 10 ms). The job's negative control, with the
lock held across the import, gives the before figure.
(cherry picked from commit aba88f26431d9232c842aee11b65fb3f59afd2c2)
The test's stand-in for a slow driver import held every dma-buf import of the
device while set, the device's own checks' among them, which could hold one
and leave the making's waiting a minute. It now holds only the import made on
the making's thread (named for the test).
(cherry picked from commit 97594efec3564e2db6b99636651a3e0bae8816b3)
A no-copy buffer's import of its dma-bufs (dma_buf.rs, Device::import_chunks)
and a texture's over dma-buf pages each called Memory::import_dma_buf through
lock(&shared.memory), so the device's memory mutex was held across the
driver's vkAllocateMemory with VkImportMemoryFdInfoKHR. A consumer measured
no-copy buffers over dma-bufs on the Radeon 780M taking 120 to 273 ms to make
while their mapping took 0.14 to 1.8 ms, with two other threads' makings stuck
beside them; every placement, import and free of the device takes that lock.
memory::import_dma_buf is now a function of the memory's mutex, as
import_host is: the types and the device-address flag are chosen under the
lock, the driver's import runs with it released, and the import is logged
under it once made. Pool blocks, imports of pointers and of the runtime's own
pages, and the exported pages already allocated with it released; no other
vkAllocateMemory runs under it.
Tests (tests/host_residency.rs): with the memory's test stand-in for a driver
slow to import (Memory::import_hold, cfg(test) only, called where the
driver's import runs), a placement and an import of a pointer made while a
no-copy buffer's dma-buf import is held must each be done within 5 s, and the
held import then makes its buffer, which reads the file's bytes; and a timed
test prints how long placements wait beside three real 256 MiB dma-buf
imports.
(cherry picked from commit 66f69a827a9de23c7b65443e2974906728fa58ce)
A texture made over a host buffer the runtime copied (the copy's memory its own) was refused as
Refused(Placement) and made a shadow of the copy: two trips a use, the Iris's 491
refused-placement shadows in reims's census. It is now a linear image bound in the copy's memory
at the texels' offset where the in-place check passed: the host-allocation image under the Fresh
verdicts for a copy in fresh pages; for a copy in device memory the driver's linear image
(PREINITIALIZED), or a DRM_FORMAT_MOD_LINEAR image at Metal's pitch, under the caller's pages'
verdicts (the pooled check only for the pitched image). A rebind re-makes the image over the new
memory (perdraw, 1cf4730839 + da896c5a1f). New count copied_textures_in_place. Runtime sources
re-pinned.
Verified: the doc checks in the landing tree. The change's own evidence: lavapipe (gem10 8867:
clippy x3, rustdoc, 57/57 focused, 40/40 lanes, suite 1900/1901 with the one failure present at
its base), 780M 8878 46/46, RX 550 8881 46/46, Iris 8825 46/46, negative control 8840 failing.
On RADV (the RX 550, job 8832) every texture over a copied host buffer whose copy lies in memory
the device allocates stayed a shadow: the route asked the runtime's pooled class's verdicts, which
the check leaves unchecked there, though the image over such a copy is mostly the driver's own
linear image, which starts PREINITIALIZED and so keeps the copy's bytes at its first move. The
pooled class judges only the DRM_FORMAT_MOD_LINEAR image made UNDEFINED at Metal's pitch where the
driver lays its rows otherwise.
So the route asks the caller's pages' class (Pointer) for texels as they lie in the copy and as they
lie in the pages (a rebind may import them), and fresh pages' where the copy lies in them;
copy_unplaced refuses the pitched image for its pitch where the pooled check did not pass for its
accesses. The wider plans of a texture over a copy (the usages its descriptor lacks) take the
caller's pages' verdicts too, as the route does. Texels::over_caller_pages answers only over a
copied buffer.
The device test now asserts an image over the copy where both checks passed and none where the
pages' did not.
Verified: cargo fmt; builds and tests run as potluck jobs after this commit.
(cherry picked from commit 7911bb167b88661f3d4b8b6a4431145ff22a143c)
Every texture made over a copied host buffer (a no-copy buffer whose import the caller's gate
refused, or that failed) was a shadow, refused as `Refused(Placement)` ("a copy of the caller's
pages in memory of the device's own"), whatever its usage: each command buffer copied the copy's
texels into the shadow's image, and merged writes back, on top of the copy's own copy-in and merge.
A consumer whose views of guest memory pass the host's mapping budget gets copies of its large
window surfaces (reims's Iris census: 112 gate copies, 1.9 GB), and every texture over them is
such a double copy: the boots' 491 refused-placement shadows.
The GPU uses the copy in the pages' stead, so a texture's image can lie there, as a rebind onto a
copy already makes one (`in_place_over_copy`):
- route.rs: a copied buffer's class is its copy's memory's (Fresh in fresh pages the runtime
imported, else Pooled); the in-place decision asks that class's verdicts and the caller's pages'
(Pointer: a rebind may import them), each for texels that lie in lines as they lie there
(`Texels::line_start` reads the copy's offset in its memory; `over_caller_pages` the pages').
- in_place_image.rs: `unplaced` over a copy makes the image in the copy's memory: in fresh pages
the host-allocation one, as over the pages; in memory the device allocates `own_unbound`, the
driver's linear image (PREINITIALIZED) where it lays the rows at the pitch, else the
DRM_FORMAT_MOD_LINEAR one of no external memory (`unbound_in` serves both, and
`in_place_unbound`). The image is watched for rebinds and its first move holds the pages, for any
no-copy buffer's pages (the class no longer decides it). A rebind onto a device-allocated copy
takes the DRM_FORMAT_MOD_LINEAR image too where the pooled class passed for its accesses
(`class_takes`, from `fresh_pages_take`).
- The image's identity is the buffer's, so its uses name the copy: commits copy the CPU's writes
in, completions merge the GPU's back, as for the buffer.
- Counted: `WorkCounts::copied_textures_in_place` (also in `host_textures_in_place`); a shadow's
notice names the copy.
Tests (copied_device.rs): a sampled and a rendered texture over a gate-refused copy take an image
over the copy exactly where the verdicts of the copy's memory and the pages pass (before this,
every one was a shadow, so on a device whose check passes the test fails), read the caller's
texels and a CPU write before a commit, and their blit and clear reach the texels' bytes in the
pages alone; such a texture follows rebinds to another copy and back to an import.
Docs: copied.rs, in_place.rs, in_place_image.rs, route.rs, HOWTO (copied host buffers),
FAST-PATHS (the in-place row), TexturePlacement::InPlace; api_signatures blessed.
(cherry picked from commit e6573e3f1b942d11bda3063f5477745018cf9239)
A block that goes (its queue went, or it sat unleased for QUIET) becomes the device's spare of its
kind where the device has none, and a queue's first lease takes the spare before it makes one
(cbnotice, dcc2bc0cb4 + 79e85cc69f). A device makes no more blocks of a kind than the most queues
that held one at once; it keeps at most one block per kind beyond them (254.7 MiB of device memory
on the RTX 5080, 1 GiB of wired host memory on the M3 Max). FAST-PATHS's known gap narrows to
makings past that peak. Runtime sources re-pinned.
Verified: the doc checks in the landing tree (signatures --check exit 0, refusal surface,
conformance coverage). The change's own evidence: gem10 m3-max-8873 (gpu_pools 6/6, negative
control 4/6 failing, lavapipe index_pools 4/4 x6, clippy x3, rustdoc); M3 m3-max-8894 (index_pools
4/4 x3, the handler test told 36/36 rounds).
The two closures of one chain both borrowed the queue blocks mutably
(E0524). Collect the queues' blocks first, then keep or release each.
Verified: cargo fmt only, here; the build follows as potluck jobs.
(cherry picked from commit 79e85cc69f5b2ec9f98ae682d0a4a775f0d4fff0)
A queue's pool block that went (its queue went, or no lease held it for
QUIET) was released, and the next queue to need a block of that kind
made one again: on the RTX 5080 a 254.7 MiB vkAllocateMemory of 4.9 to
189.5 ms beside other GPU work, during which the driver holds every
vkQueueSubmit of the process (docs/FAST-PATHS.md, known gaps).
Now the block becomes the device's spare of its kind where the device
holds none (else it is released, as before), a made-meanwhile block too,
and a queue holding no block takes the spare at its first lease before
it makes one. A device so makes no more blocks of a kind than the most
queues that held one at once, and none as queues come and go or rest.
The cost is one block of each kind beyond the queues' own until a queue
takes it or the device goes: 254.7 MiB of device memory on the RTX 5080
Laptop GPU, 1 GiB of host memory kept wired on the M3 Max. The spare is
safe to hand on: no lease holds a block that goes, so no command uses
it, and nothing reads a pool's bytes before its own command buffer wrote
them.
QueueBlocks::drain pops the slots instead of taking the map.
Tests: the pool CPU tests cover the spare from both releases, the
made-meanwhile block, the teardown and queue churn (eight queues one
after another make one block); the device tests see a later queue and a
rested one take the spare without a making, and the handler test makes
each round's block after a holder queue took the spare.
Verified: cargo fmt only, here; the runtime and validation suites, clippy
and the device runs follow as potluck jobs.
(cherry picked from commit dcc2bc0cb49f391b7d14c135d7aae97f1a93795b)
The probe commits cherry-picked with it are removed again in 795d860397, so the runtime's code is
as before; only gpu_pools.rs's module doc differs. Verified: the pin recomputed in the landing tree.
On the RTX 5080 the test passed 20 of 20 beside another lane while
telling almost nothing: in 240 rounds only 8 told, and its negative
control (the completion path waiting on a lock the making holds) failed
0 of 3. The round committed its command buffer and began the making at
once, so the scheduler's vkQueueSubmit mostly came after the making's
vkAllocateMemory began and the driver held it to the making's end; the
command buffer then completed after the making, where a handler that
waits for the making and one that does not look the same.
Each round now waits for the command buffer to be scheduled (its
submission returned, the completion watch begun) before the making
begins, so the allocation holds none of it, and its draw takes about
3 ms of GPU time (instances doubled from one until a measured command
buffer took that long, at most 1 << 24), so it completes early in the
making. A round tells only where the completion fell in the making's
first half (no longer where it came before the making began).
Verified: cargo fmt only, here; the build, clippy, the 5080 runs beside
load with the negative control, and lavapipe follow as potluck jobs.
(cherry picked from commit 319a3632e44804f381002fa2ea88f24cfbbcdca6)
runtime_lane::index_pools::a_completed_handler_waits_for_no_pool_block_made_meanwhile
failed on the RTX 5080 (round 5ce05e1908, lane ln07): the handler ran 37.2 ms
after its command buffer completed, during a 50.5 ms making of the other
queue's index pool block.
What it waited on is the driver, not the completion path. A probe on the
5080 (NVIDIA 615.71.09; 40 rounds of the lane's draw, with and without the
validation layer, completion trace, b5080 entry poolwait-probe1) found:
- the making is nearly all vkAllocateMemory of the 254.7 MiB block, 3.1 to
35.7 ms beside another process's GPU work;
- in 25 rounds the scheduler thread's vkQueueSubmit of the first command
buffer was called during that allocation and returned 0.01 to 0.25 ms after
it, twice after the GPU had ended the batch (23.9 ms into a 29.4 ms making;
0.3 ms into a 3.7 ms one: the failure's shape). The runtime watches a batch
from its submission's return on, so it completed as the making ended;
- in the other 15 the submission returned before the allocation began, and
the handler ran during the allocation in all 15;
- in all 40, the handler ran 0.07 to 1.44 ms after the later of the GPU end
and the submission's return;
- raw, another thread's vkWaitSemaphores (no wait), vkGetSemaphoreCounterValue
and vkGetFenceStatus took at most 0.03 ms during allocations of that size
(1.9 to 213.6 ms): host waits are not held, submissions are.
So the claim is now exact: the lag counts from the later of the GPU end and
the kernel end time (the last vkQueueSubmit's return), and a round tells only
where both fall in the making's first half. One round told about one time in
four on the 5080, so the test runs 12, each with a queue of its own, and
prints each. The driver's hold of the submission is a known gap
(docs/FAST-PATHS.md), and gpu_pools.rs says what a making costs there.
(cherry picked from commit 438b4ec928dc1d44d2003a20537fea77a768d731)
The probe (23e11f529f and the two commits before it) answered its question on
the RTX 5080: the next commit states the finding where its test and docs live.
Its runs: b5080 entries poolwait-probe1 (5080), m3-max-8354 (lavapipe),
m3-max-8388 (RX 7900 XTX).
(cherry picked from commit 795d860397d36cd3ffc50da78ff65e124d38f284)
A test-only probe (ignored, run by name) and test-only trace marks on the
pool block's making, the completion turn and the handler thread, to find
what the 5080's index_pools failure waited on. Not for landing as is.
(cherry picked from commit 1299b5a3ea5c01cf70e78a5f1e6fd47d759c988a)
HostRam::with_dma_buf_of_runs (radvruns, 0f36724d0f..384ce01a32): on Plan::listed (RADV), a copy
over chunks not imported takes one UDMABUF_CREATE_LIST dma-buf per list of up to list_limit runs
across every chunk it touches, freed once its command buffer completes. Without the source, copies
take their chunks as before. New work count host_ram_run_list_import_nanos. Runtime sources
re-pinned.
Verified: the doc checks in the landing tree (signatures --check exit 0, refusal surface,
conformance coverage). The change's own evidence: 780M (gem10, m3-max-8822) host_ram_dma_buf 7/7 and
60/60 host RAM device tests; lavapipe 67/67, clippy x3 and rustdoc (m3-max-8786).
HOWTO section 6 gains HostRam::with_dma_buf_of_runs: what the source answers,
where copies take lists, what they differ from (a chunk's import pins every
page of it, for good, and later copies import nothing; lists pin the copy's
pages while it runs, and every copy pays its imports), and the Radeon 780M's
numbers from tests/host_ram_listed_bench.rs at 4f30c38a77 (before the rebase
onto development; the list path is unchanged by it): 4028 MiB of an 8 GiB
guest's file held where whole chunks would make 8192 MiB resident, 8300 of
16384 for 16 GiB; a surface-shaped tile 4.1 to 4.5 ms from the commit to the
completion, a scattered one 0.9 to 1.25 ms, against 0.39 to 0.48 ms over an
imported chunk. The copy paragraph says where lists replace the staged and
alone paths. The runtime README names the call; FAST-PATHS's row on idle
dma-buf imports gains the trade (memory for per-copy time, the consumer's
choice, no accuracy).
(cherry picked from commit c6f08a396cc2e4713dedfae06ad0648019e9e22d)
A list of a copy's runs is the copy's own import of its pages, made on the
encoding thread as a range's alone is, so its time goes in a counter of its
own, WorkCounts::host_ram_run_list_import_nanos (the source's dma-buf and the
device's import, made or failed), not in host_ram_chunk_import_nanos (a
chunk's imports) nor in host_ram_copy_import_wait_nanos (a copy's waits for a
chunk's import). The waits of the chunks no list takes still reach that
counter, through CopyImports. The tile test fails where lists are imported
in no time counted, and prints the time.
Also drops copy.rs's Duration import, which the rebase left unused.
(cherry picked from commit 84f83a5672b392c6c5182a30b0c089dd6fd966e1)
The 780M bench at c4077928ac showed a tile of 1,800 guest pages spread over an 8 GiB RAM taking 16
lists a copy and over a 16 GiB RAM 32: one per 512 MiB chunk it touched, each its own udmabuf
and import (call 1.0 to 2.5 ms, commit to completion 1.5 to 5.2 ms). A list's runs need not share a
chunk: udmabuf's list names a file and offset per run.
RamOnDevice::copy_imports now gathers a copy's imports for every chunk it touches: where lists are
taken (Plan::listed, a source of run lists, ordered blits through aliases, room in the allocation
limit) each imported chunk's own import, then RamOnDevice::run_lists over the runs of every other
chunk, by address across them (page runs cut at chunk ends), split at the source's count of runs
and a chunk's bytes; a list serves each chunk it holds pages of (CopyImports::of_chunk). Chunks
with a run that is the whole chunk, and every chunk where lists are not taken, take
RamOnDevice::for_copy, which is development's again (no list branch). The residency test's RAM
is two 64 MiB chunks where listed, so its 90 clusters across both are one list, which the
per-chunk lists made two.
Verified: cargo fmt only; the 780M runs follow.
(cherry picked from commit 66146a596638850ce0649317928306fb4892686a)
clippy's single_range_in_vec_init refused a one-element array of a Range in the lists test.
Verified: cargo fmt only; clippy follows.
(cherry picked from commit 5e1fe73b374193ba3a412fec13151e0a8661586d)
HostRam::with_dma_buf_of_runs(source, most_runs) gives a RAM a DmaBufRunsSource: one dma-buf of
a list of runs of its pages, their pages one after another (udmabuf's UDMABUF_CREATE_LIST on
Linux, at most list_limit runs a list). Only copies by runs call it, and only where the plan is
Plan::listed (each held import costs every submission and the RAM's chunks are the device's
dma-bufs of its source: RADV) and the device's barriers order blits through two imports of the
same pages. There RamOnDevice::for_copy, for a chunk not imported, takes RamOnDevice::run_lists:
the copy's ranges of the chunk by address, widened to whole host pages and joined where those
share or touch a page (copy::page_runs), split into lists of at most most_runs runs and one
dma-buf's bytes (copy::run_lists), each imported as one dma-buf of the source
(Device::ram_runs_as_dma_buf, Imported::Runs), held by the command buffer until it completed and
freed then. The chunk is neither imported nor asked for, so copies pin their own pages while they
run and never a chunk's untouched pages, which udmabuf allocates for good. Without the source, a
source that fails or answers a dma-buf of another length, the margin of the allocation limit, a
run that is the whole chunk or passes one dma-buf, the copy takes the chunk as before.
A list's VkBuffer holds each run from where the runs before it end: RamChunk keeps the runs and
their offsets (RamChunk::offset_of, RamChunk::bytes), and the copy maps each piece through it;
regions take their host bytes from the pieces, not the import's span. alone_ranges takes one
chunk's sorted ranges (chunk_ranges with no cap) and joins them as before, so every other plan
(ANV, NVIDIA, lavapipe, MoltenVK, RADV without the source) copies as before.
Counted: WorkCounts::host_ram_run_list_imports (new), live in run_imports_live. Tests: copy.rs
units for page_runs and run_lists; host_ram_dma_buf's tile tests over a RAM with a udmabuf list
source (lists of at most 1,024 runs, no chunk, nothing asked, no untouched page resident) and,
without it, the chunk; elsewhere the list source never asked. The bench takes the list source and
prints first and repeated copies, sorted runs and lists per copy, over surface-shaped and
scattered tiles. api_signatures blessed (three added: DmaBufRunsSource, with_dma_buf_of_runs,
the counter; nothing removed); docs/REFUSALS.md regenerated (a DmaBuf site).
Verified: cargo fmt and the signature and refusal scripts only; the 780M runs follow.
(cherry picked from commit f2e5c143dd314835fd58cd6f8430c5c7c620e52a)
Reverts be6e2759e9 and fb3c488788. Importing each of a tile's ranges alone as a dma-buf of its
own kept residency bounded (8 GiB guest: 4028 MiB stays 4028; 16 GiB: 8300 stays 8300) but cost
35 to 45 us an import on the Radeon 780M, 13 to 19 ms for a tile of 1,800 scattered pages, every
copy, where over an imported chunk a copy takes 0.15 ms to encode and 0.5 ms to complete. That
is a speed regression for any caller copying today. The bounded path comes back as an opt-in
source of one dma-buf for a list of runs (UDMABUF_CREATE_LIST), in the next commit.
Verified: cargo fmt only; host_ram.rs and host_ram/copy.rs equal development's (2e381ae1f0).
(cherry picked from commit 5df2d2c71df35ea9be08fd377dced78680a68447)
udmabuf makes no dma-buf of a memfd not sealed against shrinking, so the bench's first copy
was refused (Unsupported, HostMemory: the source failed and RADV refused the shared pointer).
QEMU's memory-backend-memfd seals its file so; the bench's RAM is sealed as the dma-buf tests'
is. Also times the 5 MiB cache's copies over a RAM of one 512 MiB chunk an object imported:
what a copy costs with no import of its own.
Verified: cargo fmt; the 780M run follows.
(cherry picked from commit d89c82e6e85c3488b268015b8842728af99801fd)
tests::host_ram_device::the_ahead_thread_leaves_the_allocation_limit_to_the_objects failed on
the Radeon 780M (homelab-um790-xtx-1, RADV, Mesa 26.2.6) in a run of 41 host RAM tests in
parallel, at its check that the device's live allocations stand at the limit less its margin
once the thread stopped (host_ram_device.rs:575), and passed alone five times and with
host_ram_device's 20 tests. The test picks the allocation limit from the live allocations it
reads first; the device's submission checks (submit_check.rs) hold imports of their own while
they run (TAX_IMPORTS), off the test's thread, and a test that read the live count while they
held them saw the count drop once they let go. ahead_device now waits for the checks to answer,
as host_residency's device does, so no test of the file reads counts or a limit the checks move.
Verified: cargo fmt; the 780M runs follow.
(cherry picked from commit 6ccb33ed88c3650b6014666a7e386c2b3312550c)
copy_from_host_ram: where a chunk is not imported, the pages are imported alone; on a device
whose held imports add to every submission's cost (RADV with a source) always so, joined only
across pages in memory, the chunk not imported for it; elsewhere for at most 16 ranges. What is
refused: pages the device cannot import alone nor as their chunk, with RADV's case named (a RAM
of shared memory with no source). use_host_ram: a copy over a listed RAM's chunk asks for
nothing; a RAM of shared memory with no source refuses copies too. with_dma_buf: the source may
be asked once for each of a copy's ranges. host_ram.rs module docs: the copies bullet.
Verified: cargo fmt only.
(cherry picked from commit 477925f329a4dabff7716f2847d7c248f42d9e40)
Where each listed import costs every submission (RADV with the RAM's source of dma-bufs,
Plan::listed), a copy by runs over a chunk not imported no longer takes the chunk for its pages:
- RamOnDevice::for_copy imports its ranges alone however many they are (no copy::MOST_ALONE
cap there), joins two ranges less than 2 MiB apart only where every page between them is in
memory already (host_ram::resident, mincore), and asks the device's thread for nothing
(run_alone's new ask flag), so the copy pins its runs' pages and pages the guest's file holds
already. A chunk's import pinned every page of a chunk of up to 512 MiB, and udmabuf
allocated each page the guest never wrote, for good.
- The chunk's import stays where the chunk is made already, the device's barriers do not order
blits through two imports of the same pages (AliasedImportBlitsUnordered), the allocations
are within the margin the device's thread leaves, a range is the whole chunk, or a range's
import fails.
- Every other plan (ANV, NVIDIA, lavapipe, MoltenVK, and RADV without a source) is unchanged:
copy::alone_ranges takes the join test as a closure, which answers yes there, over the same
sorted ranges (chunk_ranges with no cap, then the 2 MiB joins as before).
Verified: cargo fmt only; the 780M runs follow.
(cherry picked from commit 9093fc6093d8880b51b920c3b2029449a769048d)