🐎 Take Private blocks from the source on a worker per context
PRIVATE_TAKE was carried out on the context's lane. On metal2vulkan-rt each take is one of rt's Private blocks, a driver allocation, and NVIDIA's driver holds the device's other calls while it allocates. On an RTX 3090 a boot took 7 blocks of 256 MiB, 52.7 ms in all and 11.5 ms at most, each on the control ring's lane, which held every context's next messages behind it. A take of the source's now goes to its context's worker (reims-vgpu.graphics-private-take), as POOL_TAKE's does. The worker takes the block from the source and answers. A context's takes are answered in its own order, so a take waits only behind its own context's earlier takes. A take that its context's close, the device's reset or its release ended is never answered, and the block its worker was taking goes back to the source. The device's release waits for the workers, so none calls the source past it; a worker that the exit gate parks counts as gone. Where the platform gives no Private blocks, the host's pick is still answered at once on the lane. The source decides this, never the driver or the device. What the guest observes: only when PRIVATE_BLOCK comes. It may now come after the answers to messages the context posted after the take. Its status, address and length are unchanged. The kext waits for PRIVATE_BLOCK with no deadline, on the thread whose create found no room, so no other wait changes. The degradation counts carry the takes by cause: - private-take-queued: a take that waited behind its context's earlier take; - private-take-sourced: a take its worker took from the source, with private-take-sourced-us, the source's time for those takes; - private-take-lane-us-most: the longest a take held the thread that carried it out. No block is made ahead: a 256 MiB Private make holds an NVIDIA device for 6.5 ms (RTX 3090) to 8 ms (RTX 2080) on any thread, while 16 MiB units stay at the baseline (a no-boot probe). Smaller blocks are the guest's change, in its own commit.
This commit is contained in:
1 parent
e3017f70b7
commit
cf6bc1e7c0
6 files changed
+811
-127
No files matched your search
@@ -540,8 +540,9 @@ pub trait Host: Send + Sync + 'static {
|
||||
/// block's first byte, never 0, and its length, `take.length` rounded up to
|
||||
/// [`RGFX_PRIVATE_BLOCK_ALIGN`]; [`RGFX_STATUS_INVALID_ARGUMENT`] for a length of 0 or past
|
||||
/// [`RGFX_PRIVATE_TAKE_MAX`]; or [`RGFX_STATUS_REFUSED`] where it has no block or address
|
||||
/// left for it. It answers none of a context closed or a device reset since, whose block it
|
||||
/// gives back itself. Called on the context's lane, in ring order; it waits for nothing there.
|
||||
/// left for it. It answers each context's takes in their order, and none of a context closed
|
||||
/// or a device reset since, whose block it gives back itself. Called on the context's lane, in
|
||||
/// ring order; it waits for nothing there.
|
||||
/// The default refuses at once, for a host that gives no blocks.
|
||||
fn private_take(&self, take: &RgfxPrivateTake, answer: PrivateAnswer) {
|
||||
let _ = take;
|
||||
|
||||
@@ -2714,7 +2714,11 @@ pub fn out_of_host_memory_count() -> u64 {
|
||||
/// live at once and imported by the kind of make ([`MadeCodes`], [`count_made`]), and, on a
|
||||
/// platform that keeps a pin only in its known blocks, the pins not kept by the kind of object
|
||||
/// (`rt-gpu-address-unpinned-<kind>`) and the textures placed at the guest's own pick
|
||||
/// (`rt-texture-address-guest-pick`).
|
||||
/// (`rt-texture-address-guest-pick`); and its contexts' Private takes by cause, those that
|
||||
/// waited behind their context's earlier take (`private-take-queued`) and those their worker
|
||||
/// took from the source (`private-take-sourced`, with the source's time in microseconds,
|
||||
/// `private-take-sourced-us`), with the longest a take held the thread that carried it out
|
||||
/// (`private-take-lane-us-most`).
|
||||
static COUNTED: crate::core::sync::Mutex<Vec<(&'static str, u64)>> =
|
||||
crate::core::sync::Mutex::new(Vec::new());
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ use crate::memory::{GuestMemoryLease, MemoryMap};
|
||||
use crate::platform::{ApiPlatform, api_state};
|
||||
use crate::pool::{
|
||||
Give, HostBlocks, Pool, PoolAddFn, PoolConfig, PoolHost, PoolLedger, PoolRemoveFn,
|
||||
PrivateBlocks, PrivateGive, PrivateTakeError, TAKE_MAX,
|
||||
PrivateBlocks, PrivateGive, PrivateTakeAnswer, PrivateTakeError, TAKE_MAX,
|
||||
};
|
||||
use crate::window::WindowLink;
|
||||
|
||||
@@ -921,7 +921,10 @@ impl<P: ApiPlatform> GraphicsDevice<P> {
|
||||
reset_gate: Arc::default(),
|
||||
inline_walk_max: AtomicUsize::new(INLINE_WALK_MAX),
|
||||
shared_pool: pool_ledger,
|
||||
private_blocks: PrivateBlocks::new(block_source),
|
||||
private_blocks: {
|
||||
let clock = Arc::clone(&platform);
|
||||
PrivateBlocks::new(block_source, Box::new(move || clock.clock().now_mono()))
|
||||
},
|
||||
});
|
||||
let cursors: Vec<Arc<HostCursor>> = (0..count)
|
||||
.map(|display| {
|
||||
@@ -1241,6 +1244,11 @@ impl<P: ApiPlatform> Drop for GraphicsDevice<P> {
|
||||
// each block goes back to the source once no thread of the device's holds it, and the
|
||||
// source frees them.
|
||||
drop(self.pool.take());
|
||||
// The contexts' Private takes in flight end unanswered, and their workers go, each
|
||||
// giving back the block it was taking: none calls the source past the release.
|
||||
if let Some(control) = self.ending.upgrade() {
|
||||
control.private_blocks.close();
|
||||
}
|
||||
let ending: Weak<dyn std::any::Any + Send + Sync> = self.ending.clone();
|
||||
let mut ended = ENDING.lock();
|
||||
ended.retain(|state| state.strong_count() > 0);
|
||||
@@ -2045,18 +2053,19 @@ impl<P: ApiPlatform> GraphicsControl<P> {
|
||||
}
|
||||
|
||||
/// `PRIVATE_TAKE` (`Host::private_take`): context `take.context`'s new Private block
|
||||
/// ([`PrivateBlocks::take`]), answered at once; invalid for a length of 0 or past the wire's
|
||||
/// longest, refused where no address is left for it.
|
||||
/// ([`PrivateBlocks::take`]): the host's pick answered at once, the source's block on the
|
||||
/// context's take worker, after its earlier takes; invalid for a length of 0 or past the
|
||||
/// wire's longest, refused where no block or address is left for it.
|
||||
fn take_private_block(&self, take: &RgfxPrivateTake, answer: PrivateAnswer) {
|
||||
match self.private_blocks.take(take.context, take.length) {
|
||||
let (context, asked) = (take.context, take.length);
|
||||
let answer: PrivateTakeAnswer = Box::new(move |taken| match taken {
|
||||
Ok((gpu_address, length)) => {
|
||||
static TOLD: AtomicBool = AtomicBool::new(false);
|
||||
if !TOLD.swap(true, Ordering::Relaxed) {
|
||||
log::info!(
|
||||
target: "reims_vgpu::graphics",
|
||||
"the first Private block: context {}'s, {length:#x} bytes at \
|
||||
{gpu_address:#x}",
|
||||
take.context
|
||||
"the first Private block: context {context}'s, {length:#x} bytes at \
|
||||
{gpu_address:#x}"
|
||||
);
|
||||
}
|
||||
answer.answer(RGFX_STATUS_OK, gpu_address, length);
|
||||
@@ -2065,13 +2074,13 @@ impl<P: ApiPlatform> GraphicsControl<P> {
|
||||
Err(PrivateTakeError::Refused) => {
|
||||
log::warn!(
|
||||
target: "reims_vgpu::graphics",
|
||||
"context {} asked for a Private block of {:#x} bytes, for which no address is \
|
||||
left: refused",
|
||||
take.context, take.length
|
||||
"context {context} asked for a Private block of {asked:#x} bytes, for which \
|
||||
no block or address is left: refused"
|
||||
);
|
||||
answer.answer(RGFX_STATUS_REFUSED, 0, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
self.private_blocks.take(context, asked, answer);
|
||||
}
|
||||
|
||||
/// `PRIVATE_GIVE` (`Host::private_give`): not found where context `give.context` holds no
|
||||
|
||||
@@ -83,7 +83,9 @@ pub(crate) use addresses::{
|
||||
HOST_BASE, HOST_END, IMPORT_BASE, IMPORT_END, PRIVATE_BASE, PRIVATE_END,
|
||||
};
|
||||
pub(crate) use host_blocks::HostBlocks;
|
||||
pub(crate) use private_blocks::{PrivateBlocks, PrivateGive, TakeError as PrivateTakeError};
|
||||
pub(crate) use private_blocks::{
|
||||
PrivateBlocks, PrivateGive, TakeAnswer as PrivateTakeAnswer, TakeError as PrivateTakeError,
|
||||
};
|
||||
#[cfg(feature = "rt")]
|
||||
pub(crate) use rt_blocks::RtBlocks;
|
||||
pub(crate) use takes::{Give, PoolLedger, TAKE_MAX};
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
+6
-1
@@ -142,7 +142,12 @@ repeats the ones code cites.
|
||||
docs/graphics-kext/design.md, "A buffer's escaped identity"), and the
|
||||
Vulkan platform's command predication's
|
||||
(`predication-loop-overrun`, a command buffer whose loop ran past the
|
||||
iterations laid down for it, which fails); a boot's degradations are
|
||||
iterations laid down for it, which fails), and the contexts' Private
|
||||
takes' (`private-take-queued`, a take that waited behind its context's
|
||||
earlier one; `private-take-sourced`, one its worker took from the
|
||||
source, and `private-take-sourced-us`, the source's time for them in
|
||||
microseconds; `private-take-lane-us-most`, the longest a take held the
|
||||
thread that carried it out); a boot's degradations are
|
||||
read from its last such line. `reims-vgpu INFO reims_vgpu_vulkan::core::logging: lines
|
||||
repeated since the last count: <n> more of <file>:<line>[ [<kind>]]
|
||||
(<target>: <the first line's message>); …` is how many lines of each
|
||||
|
||||
Reference in new issue
Block a user