No-copy memory with no dma-buf source is a copy on a device without VK_EXT_external_memory_host
On a device that imports no host pointer but imports dma-bufs (Honeykrisp on Asahi lists no VK_EXT_external_memory_host), a no-copy buffer or heap over memory with no source of dma-bufs was refused, naming the extension. Metal makes such a buffer, and in place is impossible there, so it now takes the copy a refused pointer with no source takes on RADV (CopiedFor::DeviceRefused): announced as copied-host-pages, counted in copied_host_buffers_device_refused, with every copy's coherence. How: host_window marks such pages pointerless (the device imports no pointer, the memory is not dma-buf-only). buffer_over_host_parts no longer takes the no-route refusal for them, so they reach import_by_pointer, whose not_importable answer is the device's refusal; a source that fails counts as the device's refusal there too, as on RADV. Rebinds to such memory, a guest RAM with no source, and every no-copy object on a device with neither route stay refused, naming the extension. The in-place check no longer makes its pointer-class buffer on a device that imports no pointer (it would be an announced copy now); its verdict there stays lasting, as before. Docs: the copied-host-pages detail, CopiedFor, CopiedBecause and the counter, copied.rs, host_memory.rs, the no-copy buffer and heap calls, imports_shared_host_pointers, host_ram/copy.rs, the runtime README, the API catalogue and HOWTO section 6. docs/REFUSALS.md regenerated: unchanged, as the extension's refusal sites all remain. Verified by the device test in the previous commit (lavapipe and the 780M, see the hand-off).
This commit is contained in:
1 parent
472c71ade8
commit
1f7b2a67cf
12 files changed
+111
-74
No files matched your search
@@ -382,16 +382,18 @@ the record the pass is making.
|
||||
([HOWTO](../../docs/HOWTO.md#6-host-memory-a-driver-refuses)), and a no-copy buffer or heap
|
||||
over memory made without a source is a copy of its pages, as below. A device that enables no
|
||||
`VK_EXT_external_memory_host` but imports dma-bufs imports only those: memory made with a
|
||||
source is imported from its dma-bufs, and memory made without one is refused
|
||||
(`Unsupported`, naming the extension); on NVIDIA's driver the runtime
|
||||
source is imported from its dma-bufs, and a no-copy buffer or heap over memory made without
|
||||
one is a copy of its pages, as where a driver refuses the pointer (a rebind to such memory is
|
||||
refused, `Unsupported`, naming the extension); on NVIDIA's driver the runtime
|
||||
never hands the driver pages the kernel cannot pin (a dma-buf's mapping): they take the source,
|
||||
and else, or where its import fails, a copy, as below. A no-copy buffer's import of such
|
||||
dma-bufs that only blits have read may be released while idle and imported again at its next
|
||||
blit, which then costs time: RADV lists every import in every submission. Nothing of Metal's
|
||||
observes it. A no-copy buffer, heap, or buffer's or heap's rebind whose import the caller's gate
|
||||
refuses (`HostMemory::with_import_gate`), or whose admitted import fails, and a no-copy buffer
|
||||
or heap whose pointer the device refuses with no dma-buf of its pages serving it (no source
|
||||
given, or one that failed or whose dma-bufs the device refused), is made over a copy of
|
||||
or heap whose pointer the device refuses, or on a device that imports no pointer, with no
|
||||
dma-buf of its pages serving it (no source given, or one that failed or whose dma-bufs the
|
||||
device refused), is made over a copy of
|
||||
its bytes in memory of the device's own, announced (`copied-host-pages`,
|
||||
[HOWTO](../../docs/HOWTO.md#copied-host-buffers)), wherever the process maps the pages
|
||||
readable (a dma-buf's mapping among them); over pages not mapped readable it is refused. A
|
||||
|
||||
@@ -495,8 +495,10 @@ impl Device {
|
||||
/// command buffers already submitted read what the GPU wrote, and each batch's completion
|
||||
/// puts the copy back to the caller's bytes, which the GPU never writes.
|
||||
///
|
||||
/// Where the caller's gate refuses the import ([`HostMemory::with_import_gate`]), or the import
|
||||
/// the device and the gate admitted fails (out of memory, another Vulkan error), of the pointer
|
||||
/// Where the caller's gate refuses the import ([`HostMemory::with_import_gate`]), where the
|
||||
/// device refuses the pointer or imports none and no dma-buf of the pages serves (no source
|
||||
/// given, or one that failed or whose dma-bufs the device refused), or where the import the
|
||||
/// device and the gate admitted fails (out of memory, another Vulkan error), of the pointer
|
||||
/// or of the dma-bufs, the buffer is made over a copy of the bytes in memory of the device's
|
||||
/// own instead, its `contents` still the pointer, announced (`copied-host-pages`): each commit
|
||||
/// copies in the bytes the CPU changed, and each batch's completion merges back the bytes the
|
||||
@@ -505,12 +507,11 @@ impl Device {
|
||||
/// are never copied, and keep the import's refusal.
|
||||
///
|
||||
/// Refused: a length of 0 or past `max_buffer_length` (`Nil`, as plain Metal answers nil);
|
||||
/// `Private` or `Memoryless` storage, as Metal stops them, and an undefined
|
||||
/// option (`Invalid`); on a device without `VK_EXT_external_memory_host`, memory that comes
|
||||
/// with no dma-buf source it imports and lies in no chunk of a guest RAM it uses
|
||||
/// (`Device::use_host_ram`, `HostMemory::with_runs`) (`Unsupported`, naming it); memory this
|
||||
/// device cannot import exactly, by its pointer or by its dma-bufs (`Unsupported`,
|
||||
/// `HostMemory`), among it on Linux a page this process cannot write ([`HostMemory::new`]);
|
||||
/// `Private` or `Memoryless` storage, as Metal stops them, and an undefined option
|
||||
/// (`Invalid`); on a device that imports neither pointers (`VK_EXT_external_memory_host`) nor
|
||||
/// dma-bufs, every memory (`Unsupported`, naming the extension); memory this device cannot
|
||||
/// import exactly, by its pointer or by its dma-bufs (`Unsupported`, `HostMemory`), among it
|
||||
/// on Linux a page this process cannot write ([`HostMemory::new`]);
|
||||
/// dma-bufs that break the source's contract (`Invalid`, `Problem::DmaBuf`); pages past the
|
||||
/// device's allocation size (`OutOfMemory`). Pages not mapped, or mapped without access, which
|
||||
/// Metal makes no buffer over (nil), are refused here too, typed as the check or the import
|
||||
@@ -751,8 +752,9 @@ impl Device {
|
||||
let source = (source, dma_buf_only);
|
||||
let host = host_window(call, importer, pointer, length, source, drops_writes)?;
|
||||
// Pages with no route of their own are refused here, but where their runs may lie in a
|
||||
// guest RAM's chunk (below), refused there where they do not.
|
||||
let no_route = match (host.no_route(importer), &runs) {
|
||||
// guest RAM's chunk (below), refused there where they do not; on a device that imports no
|
||||
// pointer, they are a copy instead (below), as where a device refuses their pointer.
|
||||
let no_route = match (host.no_route(importer).filter(|_| !host.pointerless), &runs) {
|
||||
(Some(refusal), None) => return Err(refusal),
|
||||
(no_route, _) => no_route,
|
||||
};
|
||||
@@ -919,9 +921,10 @@ impl Device {
|
||||
// idle and import them again (`host_residency.rs`), as it may its own import of the
|
||||
// pointer where the driver's pointer imports follow their address; a heap's import
|
||||
// stays, as does an import of a read-only view.
|
||||
// Whether the device was asked the pointer, whose refusal a failed source leaves
|
||||
// standing (the window takes it, and the memory is no dma-buf-only memory).
|
||||
let by_pointer = host.by_pointer;
|
||||
// Whether the device was asked the pointer, or imports none, whose refusal a
|
||||
// failed source leaves standing (the window takes it, and the memory is no
|
||||
// dma-buf-only memory).
|
||||
let pointer_refused = host.by_pointer || host.pointerless;
|
||||
let imported =
|
||||
match unsafe { self.import_by_pointer(importer, pointer, length, host, class) }
|
||||
{
|
||||
@@ -947,7 +950,7 @@ impl Device {
|
||||
// device refused its dma-bufs): the device's refusal of the pointer,
|
||||
// as where no source is given.
|
||||
let by_device =
|
||||
by_pointer && refused(&failed) && refusal == not_importable();
|
||||
pointer_refused && refused(&failed) && refusal == not_importable();
|
||||
(source_failure(failed, refusal), by_device)
|
||||
}),
|
||||
// The device's refusal of the pointer, with no source of dma-bufs of the
|
||||
@@ -976,9 +979,10 @@ impl Device {
|
||||
return copied.map(|buffer| noted(kept(buffer, log, kept_runs, made_of)));
|
||||
}
|
||||
// Pages whose pointer the device refuses (RADV refuses shared memory, a
|
||||
// `memfd` mapping among it), with no dma-buf of them served (no source given,
|
||||
// a source that failed, dma-bufs the device refused): a copy, announced, as
|
||||
// Metal makes a no-copy buffer over any page.
|
||||
// `memfd` mapping among it; a device without `VK_EXT_external_memory_host`
|
||||
// every pointer), with no dma-buf of them served (no source given, a source
|
||||
// that failed, dma-bufs the device refused): a copy, announced, as Metal makes
|
||||
// a no-copy buffer over any page.
|
||||
Err((_, true)) if copyable => {
|
||||
let why = CopiedFor::DeviceRefused;
|
||||
// SAFETY: the caller's contract.
|
||||
@@ -1611,6 +1615,7 @@ impl Device {
|
||||
by_pointer,
|
||||
source,
|
||||
drops_writes,
|
||||
pointerless: _,
|
||||
} = host;
|
||||
let refusal = match (by_pointer, importer.pointers()) {
|
||||
// SAFETY: the caller's.
|
||||
@@ -1888,7 +1893,8 @@ impl Device {
|
||||
}
|
||||
CopiedBecause::DeviceRefused => {
|
||||
"the device refused their pointer's import (VK_EXT_external_memory_host), as \
|
||||
RADV refuses shared memory, and no dma-buf of them served it: no source of \
|
||||
RADV refuses shared memory, or imports no pointer (it enables no \
|
||||
VK_EXT_external_memory_host), and no dma-buf of them served it: no source of \
|
||||
them was given (HostMemory::with_dma_buf), or it failed, or the device \
|
||||
refused its dma-bufs"
|
||||
}
|
||||
@@ -2340,6 +2346,11 @@ struct HostWindow {
|
||||
by_pointer: bool,
|
||||
/// The caller's dma-buf source, where it gave one and the device imports dma-bufs.
|
||||
source: Option<Source>,
|
||||
/// The device imports no pointer (it enables no `VK_EXT_external_memory_host`), and the pages
|
||||
/// are not the source's dma-bufs alone (`HostMemory::dma_buf_only`): where no dma-buf of them
|
||||
/// serves, a no-copy buffer or heap over them is a copy (`copied.rs`), as where a device
|
||||
/// refuses their pointer.
|
||||
pointerless: bool,
|
||||
}
|
||||
|
||||
/// Whether a no-copy buffer, heap or rebind whose pages the caller resolves to runs of a guest RAM
|
||||
@@ -2387,9 +2398,10 @@ pub(super) fn no_copy_options(options: ResourceOptions) -> (ResourceOptions, boo
|
||||
enum CopiedFor {
|
||||
/// The caller's gate refused their import (`HostMemory::with_import_gate`).
|
||||
Refused,
|
||||
/// The device refused their pointer's import, and no dma-buf of them served it: the caller
|
||||
/// gave no source of them (`HostMemory::with_dma_buf`), or its source failed, or the device
|
||||
/// refused its dma-bufs.
|
||||
/// The device refused their pointer's import, or imports no pointer (it enables no
|
||||
/// `VK_EXT_external_memory_host`), and no dma-buf of them served it: the caller gave no
|
||||
/// source of them (`HostMemory::with_dma_buf`), or its source failed, or the device refused
|
||||
/// its dma-bufs.
|
||||
DeviceRefused,
|
||||
/// The import the device and the gate admitted failed, with this.
|
||||
Failed(Error),
|
||||
@@ -2447,11 +2459,13 @@ fn host_window(
|
||||
&& (importer.pointers()).is_some_and(|pointers| {
|
||||
import_window(at, length, importer.page, pointers.alignment).is_ok()
|
||||
});
|
||||
let pointerless = !dma_buf_only && importer.pointers().is_none();
|
||||
Ok(HostWindow {
|
||||
drops_writes,
|
||||
window,
|
||||
by_pointer,
|
||||
source,
|
||||
pointerless,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2462,7 +2476,9 @@ impl HostWindow {
|
||||
/// `VK_EXT_external_memory_host`, `Unsupported` naming it; elsewhere a range the import
|
||||
/// alignment cannot cover, or memory imported only as dma-bufs (`Unsupported`, `HostMemory`).
|
||||
/// `None` where they have a route. Such pages may still lie in a guest RAM's chunk
|
||||
/// (`HostMemory::with_runs`), which takes no import of their own.
|
||||
/// (`HostMemory::with_runs`), which takes no import of their own. A rebind to them takes this
|
||||
/// refusal; a no-copy buffer or heap over them is a copy instead where the device imports no
|
||||
/// pointer ([`HostWindow::pointerless`]).
|
||||
fn no_route(&self, importer: &Importer) -> Option<Error> {
|
||||
let copied = self.drops_writes && !crate::read_only_view::VIEWS_DROP_WRITES;
|
||||
(!self.by_pointer && self.source.is_none() && !copied).then(|| {
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
//! Copied host buffers: a no-copy buffer whose import of the caller's pages the caller's gate
|
||||
//! refused ([`HostMemory::with_import_gate`](crate::HostMemory)), whose pointer the device refused
|
||||
//! with no dma-buf of the pages serving it (no source of them given, or one that failed or whose
|
||||
//! dma-bufs the device refused; RADV refuses shared memory, a `memfd` mapping among it), or whose
|
||||
//! import the gate and the device admitted and that then failed (out of memory, another Vulkan
|
||||
//! error, or the runtime's refusal of pages the kernel cannot pin on a driver whose failed import
|
||||
//! of them breaks it, `RuntimeDriverDefect::UnpinnablePagesBreakHostMemory`, that no dma-buf of
|
||||
//! them served), is made all the same over a copy of its bytes (`Device::buffer_over_host_memory`),
|
||||
//! announced (`copied-host-pages`). No import maps the pages, so they take no kernel mapping.
|
||||
//! dma-bufs the device refused; RADV refuses shared memory, a `memfd` mapping among it, and a
|
||||
//! device without `VK_EXT_external_memory_host` every pointer), or whose import the gate and the
|
||||
//! device admitted and that then failed (out of memory, another Vulkan error, or the runtime's
|
||||
//! refusal of pages the kernel cannot pin on a driver whose failed import of them breaks it,
|
||||
//! `RuntimeDriverDefect::UnpinnablePagesBreakHostMemory`, that no dma-buf of them served), is made
|
||||
//! all the same over a copy of its bytes (`Device::buffer_over_host_memory`), announced
|
||||
//! (`copied-host-pages`). No import maps the pages, so they take no kernel mapping.
|
||||
//!
|
||||
//! - **The copy.** A `VkBuffer` of the buffer's length in host-visible, coherent memory of the
|
||||
//! runtime's own ([`MemoryClass::Shared`](crate::memory::MemoryClass)), which the GPU uses; the
|
||||
|
||||
@@ -2053,7 +2053,8 @@ degradations! {
|
||||
/// (`HostMemory::with_import_gate`) refused the pages' import, or the device refused the
|
||||
/// pointer's import and no dma-buf of the pages served it, the caller giving no source of
|
||||
/// them (`HostMemory::with_dma_buf`) or one that failed or whose dma-bufs the device
|
||||
/// refused (RADV refuses shared memory, a `memfd` mapping among it,
|
||||
/// refused (RADV refuses shared memory, a `memfd` mapping among it, and a device without
|
||||
/// `VK_EXT_external_memory_host` every pointer,
|
||||
/// `WorkCounts::copied_host_buffers_device_refused`), or the import the device
|
||||
/// and the gate admitted failed, of the pointer or of the caller's dma-bufs (out of
|
||||
/// memory, or another Vulkan error, such as a driver out of the mappings the host kernel
|
||||
|
||||
@@ -583,22 +583,22 @@ impl Device {
|
||||
/// ([`Device::new_buffer_with_bytes_no_copy`]).
|
||||
///
|
||||
/// Where the caller's gate refuses the import
|
||||
/// ([`HostMemory::with_import_gate`](crate::HostMemory::with_import_gate)), or the import the
|
||||
/// device and the gate admitted fails (out of memory, another Vulkan error), the heap's own
|
||||
/// buffer is a copy of the pages in memory of the device's own instead, its buffers lying in
|
||||
/// the copy and its textures shadows of its bytes, announced (`copied-host-pages`,
|
||||
/// `copied.rs`).
|
||||
/// ([`HostMemory::with_import_gate`](crate::HostMemory::with_import_gate)), where the device
|
||||
/// refuses the pointer or imports none (it enables no `VK_EXT_external_memory_host`) and no
|
||||
/// dma-buf of the pages serves, or where the import the device and the gate admitted fails
|
||||
/// (out of memory, another Vulkan error), the heap's own buffer is a copy of the pages in
|
||||
/// memory of the device's own instead, its buffers lying in the copy and its textures shadows
|
||||
/// of its bytes, announced (`copied-host-pages`, `copied.rs`).
|
||||
///
|
||||
/// Refused: a size of 0 (`Nil`, as [`Device::new_heap`] answers it); storage other than
|
||||
/// `Shared`, a sparse heap, an undefined option (`Invalid`); memory whose first byte is not a multiple of the import's unit
|
||||
/// (`Invalid`, [`HeapProblem::HostMemoryAlignment`]); and as
|
||||
/// [`Device::new_buffer_with_bytes_no_copy`] refuses the memory: on a device without
|
||||
/// `VK_EXT_external_memory_host`, memory that comes with no dma-buf source it imports and lies
|
||||
/// in no chunk of a guest RAM it uses (`Unsupported`, naming it), memory it cannot import
|
||||
/// exactly
|
||||
/// (`Unsupported`, `HostMemory`), a size past the device's allocation (`OutOfMemory`) or
|
||||
/// `maxBufferSize` (`NotImplemented(HeapPastMaxBufferSize)`); a pinned address the space
|
||||
/// cannot honour (`PlacementConflict`).
|
||||
/// `Shared`, a sparse heap, an undefined option (`Invalid`); memory whose first byte is not a
|
||||
/// multiple of the import's unit (`Invalid`, [`HeapProblem::HostMemoryAlignment`]); and as
|
||||
/// [`Device::new_buffer_with_bytes_no_copy`] refuses the memory: on a device that imports
|
||||
/// neither pointers (`VK_EXT_external_memory_host`) nor dma-bufs, every memory (`Unsupported`,
|
||||
/// naming the extension), memory it cannot import exactly (`Unsupported`, `HostMemory`), a
|
||||
/// size past the device's allocation (`OutOfMemory`) or `maxBufferSize`
|
||||
/// (`NotImplemented(HeapPastMaxBufferSize)`); a pinned address the space cannot honour
|
||||
/// (`PlacementConflict`).
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
//! the buffer reads them past its length, the caller's bytes, as plain Metal reads them
|
||||
//! (`Buffer::copy_reach`). The import is never a dedicated allocation in Vulkan's sense
|
||||
//! (`VkMemoryDedicatedAllocateInfo`), which host memory cannot be.
|
||||
//! - **What it refuses**, typed: memory with no dma-buf source the device imports, on a device
|
||||
//! without the extension (`Unsupported` naming it), and what this device cannot import exactly
|
||||
//! - **What it refuses**, typed: every memory on a device that imports neither pointers nor
|
||||
//! dma-bufs (`Unsupported` naming the extension), and what this device cannot import exactly
|
||||
//! (`Unsupported`, `not_representable`): an import
|
||||
//! alignment above the host page whose rounding would take pages the range does not touch, an
|
||||
//! offset in the pages that misses the buffer's memory alignment, no memory type both allow, or
|
||||
@@ -53,9 +53,12 @@
|
||||
//! takes by its pointer is made exactly as before, with no call more. A device that enables no
|
||||
//! `VK_EXT_external_memory_host` (a driver that lists none, or a device made withholding it,
|
||||
//! `DeviceOptions::withheld_extensions`) but imports dma-bufs takes this route alone: no pointer
|
||||
//! is asked of it ([`Importer::pointers`]), the pages are rounded out to the host page, and
|
||||
//! memory that comes with no source is refused, naming the extension
|
||||
//! ([`Importer::pointer_import`]).
|
||||
//! is asked of it ([`Importer::pointers`]), and the pages are rounded out to the host page. A
|
||||
//! no-copy buffer or heap over memory that comes with no source it can use, or whose source
|
||||
//! fails, is a copy of the pages (`copied.rs`, announced as `copied-host-pages`, counted as
|
||||
//! the device's refusal, `WorkCounts::copied_host_buffers_device_refused`), as where a device
|
||||
//! refuses the pointer; a rebind to such memory is refused, as is a guest RAM with no source
|
||||
//! (`Device::use_host_ram`), naming the extension ([`Importer::pointer_import`]).
|
||||
//! - **When**. The pages are imported when the buffer is made, on every platform, as Metal wires
|
||||
//! them then: the GPU uses the pages mapped at the pointer when the buffer was made, whatever is
|
||||
//! mapped there later, but on a driver whose pointer imports follow their address (as the
|
||||
|
||||
@@ -161,7 +161,8 @@
|
||||
//! use; of runs one after another, bytes of the buffer that start off a 4-byte word of its memory
|
||||
//! (runs each at a byte of their own are copied by regions there); a copy by regions with a
|
||||
//! buffer over host pages its bytes' span overlaps. A device without
|
||||
//! `VK_EXT_external_memory_host` uses no RAM (`Unsupported`, naming it); the buffer's bytes past
|
||||
//! `VK_EXT_external_memory_host` uses no RAM that comes with no dma-buf source it imports
|
||||
//! (`Unsupported`, naming it); the buffer's bytes past
|
||||
//! its length are a range past it ([`Problem::RangeOutOfBounds`]: of runs each at a byte of their
|
||||
//! own, the first run's past it). A chunk the device cannot import fails the copy with the
|
||||
//! import's error.
|
||||
|
||||
@@ -28,14 +28,14 @@ impl Device {
|
||||
/// Where it is false, a no-copy buffer over shared memory is imported only from the caller's
|
||||
/// dma-buf source ([`HostMemory::with_dma_buf`](crate::HostMemory::with_dma_buf)), and without
|
||||
/// one that works is a copy of the pages, announced (`copied-host-pages`,
|
||||
/// `WorkCounts::copied_host_buffers_device_refused`); on a device that imports no pointer,
|
||||
/// memory that comes with no source is refused instead, naming the extension. A source is
|
||||
/// what such memory needs to be imported, whatever its pages' protection: pages the process
|
||||
/// maps read-only go to the source without their pointer's import being tried (a dma-buf pins
|
||||
/// nothing of the process's mapping), so a caller need not make a writable second mapping of
|
||||
/// them for the import. Measured: MoltenVK (an M3 Max) and lavapipe answer true, RADV (a
|
||||
/// Radeon 780M and an RX 7900 XTX, Mesa 26.2.4) false; NVIDIA's driver imported such memory
|
||||
/// where the no-copy buffers were measured, though this answer was not asked there.
|
||||
/// `WorkCounts::copied_host_buffers_device_refused`), as is any memory without one on a
|
||||
/// device that imports no pointer. A source is what such memory needs to be imported,
|
||||
/// whatever its pages' protection: pages the process maps read-only go to the source without
|
||||
/// their pointer's import being tried (a dma-buf pins nothing of the process's mapping), so a
|
||||
/// caller need not make a writable second mapping of them for the import. Measured: MoltenVK
|
||||
/// (an M3 Max) and lavapipe answer true, RADV (a Radeon 780M and an RX 7900 XTX, Mesa 26.2.4)
|
||||
/// false; NVIDIA's driver imported such memory where the no-copy buffers were measured,
|
||||
/// though this answer was not asked there.
|
||||
///
|
||||
/// Fails only where the answer cannot be found: out of host memory for the page, or the
|
||||
/// device lost. The device's refusal of the pointer is no failure but the answer, false.
|
||||
|
||||
@@ -1501,18 +1501,27 @@ fn contents(buffer: &Buffer) -> Result<NonNull<u8>, Unmade> {
|
||||
/// where the device imports no host pointer at all (`VK_EXT_external_memory_host`), else one that
|
||||
/// may pass (the import of these pages refused or failed, `copied.rs`).
|
||||
fn unimported(device: &Device, why: &str) -> Unmade {
|
||||
let pointers = (device.shared().host_import.as_ref()).is_ok_and(|i| i.pointers().is_some());
|
||||
match pointers {
|
||||
match imports_pointers(device) {
|
||||
true => Unmade::passing(why),
|
||||
false => Unmade::lasting(why),
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether `device` imports a host pointer (`VK_EXT_external_memory_host`).
|
||||
fn imports_pointers(device: &Device) -> bool {
|
||||
(device.shared().host_import.as_ref()).is_ok_and(|importer| importer.pointers().is_some())
|
||||
}
|
||||
|
||||
/// A no-copy buffer of `length` bytes over anonymous pages mapped for it, imported by their
|
||||
/// pointer, which its keep-alive unmaps ([`Anonymous`]). Why not, where the device makes none,
|
||||
/// or does not import the pointer (dma-bufs, or a copied host buffer, `copied.rs`).
|
||||
/// or does not import the pointer (dma-bufs, or a copied host buffer, `copied.rs`), the buffer
|
||||
/// unmade where the device imports no pointer at all (it would be a copy of the pages, announced).
|
||||
#[cfg(unix)]
|
||||
fn pointer_pages(device: &Device, length: u64) -> Result<ClassPages, Unmade> {
|
||||
if !imports_pointers(device) {
|
||||
let why = "the device imports no host pointer (VK_EXT_external_memory_host)";
|
||||
return Err(Unmade::lasting(why));
|
||||
}
|
||||
let start = map_anonymous(length).ok_or_else(|| {
|
||||
Unmade::passing(format!("no anonymous mapping of {length} bytes was made"))
|
||||
})?;
|
||||
|
||||
@@ -6891,10 +6891,11 @@ pub struct WorkCounts {
|
||||
pub copied_host_buffers_made: u64,
|
||||
/// Of those, the ones made because the caller's gate refused the import.
|
||||
pub copied_host_buffers_refused: u64,
|
||||
/// Of those, the ones made because the device refused the pointer's import and no dma-buf of
|
||||
/// the pages served it: the caller gave no source of them (`HostMemory::with_dma_buf`), or
|
||||
/// its source failed, or the device refused its dma-bufs. RADV refuses shared memory, a
|
||||
/// `memfd` mapping among it (`Device::imports_shared_host_pointers`).
|
||||
/// Of those, the ones made because the device refused the pointer's import, or imports no
|
||||
/// pointer (it enables no `VK_EXT_external_memory_host`), and no dma-buf of the pages served
|
||||
/// it: the caller gave no source of them (`HostMemory::with_dma_buf`), or its source failed,
|
||||
/// or the device refused its dma-bufs. RADV refuses shared memory, a `memfd` mapping among it
|
||||
/// (`Device::imports_shared_host_pointers`).
|
||||
pub copied_host_buffers_device_refused: u64,
|
||||
/// Of those, the ones made because an import the device and the gate admitted failed (out
|
||||
/// of memory, another Vulkan error), or because the runtime refused the pages for the driver
|
||||
@@ -9269,8 +9270,8 @@ impl Device {
|
||||
pub(crate) enum CopiedBecause {
|
||||
/// The caller's gate refused their import (`HostMemory::with_import_gate`).
|
||||
Refused,
|
||||
/// The device refused their pointer's import, and no dma-buf of them served it: no source of
|
||||
/// them was given, or it failed, or the device refused its dma-bufs.
|
||||
/// The device refused their pointer's import, or imports no pointer, and no dma-buf of them
|
||||
/// served it: no source of them was given, or it failed, or the device refused its dma-bufs.
|
||||
DeviceRefused,
|
||||
/// The import the device and the gate admitted failed.
|
||||
Failed,
|
||||
|
||||
+2
-1
@@ -3160,7 +3160,8 @@ bound.
|
||||
the caller's gate (`HostMemory::with_import_gate`) refused the pages' import, or the device
|
||||
refused the pointer's import and no dma-buf of the pages served it (no source given, or one that
|
||||
failed or whose dma-bufs the device refused; RADV refuses shared memory, a `memfd` mapping among
|
||||
it, `copied_host_buffers_device_refused`), or the import the device and the gate admitted failed, of the pointer or of the caller's dma-bufs (out of memory, or
|
||||
it, and a device without `VK_EXT_external_memory_host` every pointer,
|
||||
`copied_host_buffers_device_refused`), or the import the device and the gate admitted failed, of the pointer or of the caller's dma-bufs (out of memory, or
|
||||
another Vulkan error, such as a driver out of the mappings the host kernel allows), or the
|
||||
runtime kept pages the kernel cannot pin (a dma-buf's mapping) from NVIDIA's driver, whose failed
|
||||
import of them breaks it (`RuntimeDriverDefect::UnpinnablePagesBreakHostMemory`), and no dma-buf
|
||||
|
||||
+5
-3
@@ -210,9 +210,11 @@ source is refused with `Unsupported`, `HostMemory`.
|
||||
A device that enables no `VK_EXT_external_memory_host` (a driver that lists none, or a device made
|
||||
with it in `DeviceOptions::withheld_extensions`) but enables the dma-buf route imports no pointer
|
||||
at all: memory made with a source is imported from its dma-bufs, its pages rounded out to the host
|
||||
page, and memory made without one is refused (`Unsupported`, naming the extension), as is every
|
||||
no-copy object on a device with neither. A guest RAM there (`Device::use_host_ram`) needs a source
|
||||
too, and its chunks are its dma-bufs; an object whose runs lie in one of its chunks
|
||||
page. A no-copy buffer or heap over memory made without one, or with one that fails, is a copy of
|
||||
the pages, as where a driver refuses the pointer above (`copied_host_buffers_device_refused`); a
|
||||
rebind to such memory is refused (`Unsupported`, naming the extension), as is every no-copy object
|
||||
on a device with neither route. A guest RAM there (`Device::use_host_ram`) needs a source too, and
|
||||
its chunks are its dma-bufs; an object whose runs lie in one of its chunks
|
||||
(`HostMemory::with_runs`) is bound there with no source of its own.
|
||||
|
||||
No driver that pins imported pages imports a mapping the kernel cannot pin (`VM_IO` or `VM_PFNMAP`:
|
||||
|
||||
Reference in new issue
Block a user