Submission checks stop at a device loss: nothing submitted again, nothing recorded
With the relayed loss fixed (the hang answers GpuHang), the M3 Max's lane test a_gpu_fault_fails_its_command_buffer_and_the_queue_runs_on went on to its next claim and failed there (m3-max-13972, m3-max-13988): under MVK_CONFIG_RESUME_LOST_DEVICE off the validation layer reported VUID-vkQueueSubmit-fence-00064 and VUID-vkQueueSubmit-pCommandBuffers-00071, both on the m2v-submit-check thread (a diagnostic run printed the backtraces: submit_check::measure -> tax -> submit_one -> submit -> vkQueueSubmit). The device was lost while its submission checks ran: a wait for the checks' fence or a submission answered the loss, the check took it as a refused call (Unchecked, which a record keeps), and the next check submitted the same fence and command buffer again on the lost device, which the layer reads as still pending. A record of verdicts from a lost device would also have kept Unchecked for the driver's release, so later devices run no check. Now a VK_ERROR_DEVICE_LOST from a submission or a wait stops the checks as the device's teardown does (None): nothing is submitted again, the tax releases the imports it holds first, the checks' objects go, and nothing is recorded (what had not answered reads Unchecked for the device's life). The loader word's step is ended before the stop as before a refused call. Another refused call or failed wait answers as before. Test: tests::submit_check_device::a_loss_stops_the_checks_with_nothing_submitted_again_or_recorded holds the checks at a step, injects a lost-device answer at their next fence wait (SubmitChecks::lost_at_wait, a device-test hook), and holds them to one submission's calls from the hold, no run to their end, no Pending verdict and no record. Fails without the fix (the checks go on submitting). Evidence in the report to the orchestrator. submit_check.rs is bugs-a's area; the change is the loss path of submit()/wait() and the tax's stop.
This commit is contained in:
1 parent
67510b5aca
commit
c60041daa5
2 files changed
+114
-19
No files matched your search
@@ -138,15 +138,18 @@
|
||||
//! handle, so the device's last handle never goes on it. It reads the stop between its steps
|
||||
//! (each round, each phase, each copy): the device's teardown stops it there and waits for the
|
||||
//! step in progress, the release of its objects and of its parts, and the checks end
|
||||
//! unrecorded, what had not answered `Unchecked`. Each step's Vulkan work runs inside a section
|
||||
//! of the exit guard (`exit_guard.rs`). Its submissions are counted apart
|
||||
//! (`WorkCounts::submit_check_calls`), not among the device's, with the relay's mark after each
|
||||
//! of its uses of the queue where the device relays its queues' failures (`device/relay.rs`,
|
||||
//! `By::Checks`); the commands it records go through the driver's own entry points, counted
|
||||
//! among none of the device's (`WorkCounts::commands_recorded`, `recorder::unrouted`); its
|
||||
//! allocations, buffers, bindings and releases are counted as the checks'
|
||||
//! (`WorkCounts::device_checks`), not among the process's (`object_churn`). Its submission calls
|
||||
//! hold the device's loader word (`loader_word.rs`).
|
||||
//! unrecorded, what had not answered `Unchecked`. So does the device's loss, at the call that
|
||||
//! answers it (`VK_ERROR_DEVICE_LOST`, from a submission or a wait): nothing is submitted again,
|
||||
//! since a later submission of the same fence and command buffers would find them pending (as
|
||||
//! the validation layer reads a loss), and nothing a lost device measured is recorded. Each
|
||||
//! step's Vulkan work runs inside a section of the exit guard (`exit_guard.rs`). Its
|
||||
//! submissions are counted apart (`WorkCounts::submit_check_calls`), not among the device's,
|
||||
//! with the relay's mark after each of its uses of the queue where the device relays its queues'
|
||||
//! failures (`device/relay.rs`, `By::Checks`); the commands it records go through the driver's
|
||||
//! own entry points, counted among none of the device's (`WorkCounts::commands_recorded`,
|
||||
//! `recorder::unrouted`); its allocations, buffers, bindings and releases are counted as the
|
||||
//! checks' (`WorkCounts::device_checks`), not among the process's (`object_churn`). Its
|
||||
//! submission calls hold the device's loader word (`loader_word.rs`).
|
||||
|
||||
use crate::allocations::Allocations;
|
||||
use crate::command_buffer::fences::Fences;
|
||||
@@ -355,6 +358,10 @@ pub(crate) struct SubmitChecks {
|
||||
/// (`tests/teardown_threads.rs`).
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
pub(crate) held: crate::freed_memory::held::Held,
|
||||
/// The next wait for the checks' fence answers as a lost device's (`VK_ERROR_DEVICE_LOST`),
|
||||
/// whatever the driver answered: a device test's injection (`tests::submit_check_device`).
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
pub(crate) lost_at_wait: AtomicBool,
|
||||
}
|
||||
|
||||
impl SubmitChecks {
|
||||
@@ -380,6 +387,8 @@ impl SubmitChecks {
|
||||
ending: Condvar::new(),
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
held: Default::default(),
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
lost_at_wait: AtomicBool::new(false),
|
||||
};
|
||||
if merge_assumed {
|
||||
checks.set(Check::Merge, Verdict::Holds);
|
||||
@@ -1112,8 +1121,8 @@ fn run(parts: &Parts, made: Made) {
|
||||
|
||||
/// Each check in turn, its verdict set as it is known: what they measured, and whether their
|
||||
/// verdicts may be recorded (no timed check's tries all disagreed, an import tax `Holds` earned
|
||||
/// its record: [`tax_tried`]); `None` where the process is exiting or the device's teardown
|
||||
/// stopped the checks.
|
||||
/// its record: [`tax_tried`]); `None` where the process is exiting, or the device's teardown or
|
||||
/// its loss stopped the checks.
|
||||
fn measure(parts: &Parts, objects: &Objects) -> Option<(Measured, bool)> {
|
||||
let checks = &parts.checks;
|
||||
let (merges, (merged, apart), merge_kept) = merge_tried(checks, || merge(parts, objects))?;
|
||||
@@ -1290,7 +1299,10 @@ fn tax(parts: &Parts, objects: &Objects) -> Option<Option<Timed>> {
|
||||
let mut refused = false;
|
||||
for submission in 0..=TAX_SUBMITS {
|
||||
parts.step();
|
||||
match objects.submit_one(parts)? {
|
||||
let Some(submitted) = objects.submit_one(parts) else {
|
||||
return release_all(parts, imports.drain(..)).and(None);
|
||||
};
|
||||
match submitted {
|
||||
Some(nanos) if submission > 0 => times.push(nanos),
|
||||
Some(_) => {}
|
||||
None => {
|
||||
@@ -1742,7 +1754,7 @@ impl Objects {
|
||||
/// Submit `infos` to the device's first `VkQueue`, the last signalling the fence, in one call
|
||||
/// where `together`, else one call each, and wait for the fence: the nanoseconds inside the
|
||||
/// calls. `Some(None)` where a call was refused or the wait failed; `None` where the process
|
||||
/// is exiting.
|
||||
/// is exiting or the device was lost (the module docs, "Its thread").
|
||||
fn submit(
|
||||
&self,
|
||||
parts: &Parts,
|
||||
@@ -1808,6 +1820,10 @@ impl Objects {
|
||||
};
|
||||
let nanos = match submitted {
|
||||
Ok(spent) => spent,
|
||||
Err(vk::Result::ERROR_DEVICE_LOST) => {
|
||||
parts.loader_word.end_step(step, mark);
|
||||
return None;
|
||||
}
|
||||
Err(_) => {
|
||||
parts.loader_word.end_step(step, mark);
|
||||
// A refused call among several: those before it, and so the fence, were not all
|
||||
@@ -1818,9 +1834,9 @@ impl Objects {
|
||||
};
|
||||
}
|
||||
};
|
||||
let waited = self.wait(parts)?;
|
||||
let waited = self.wait(parts);
|
||||
parts.loader_word.end_step(step, mark);
|
||||
if !waited {
|
||||
if !waited? {
|
||||
return Some(None);
|
||||
}
|
||||
Some(Some(i64::try_from(nanos.as_nanos()).unwrap_or(i64::MAX)))
|
||||
@@ -1838,7 +1854,7 @@ impl Objects {
|
||||
|
||||
/// Record and submit a copy of [`COPIED`] bytes from the start of `import`'s buffer to
|
||||
/// `page` bytes in, then a barrier to the host's reads, and wait for it: whether it ran.
|
||||
/// `None` where the process is exiting.
|
||||
/// `None` where the process is exiting or the device was lost.
|
||||
#[cfg(target_os = "linux")]
|
||||
fn copy(&self, parts: &Parts, import: &Import, page: u64) -> Option<bool> {
|
||||
{
|
||||
@@ -1883,7 +1899,7 @@ impl Objects {
|
||||
}
|
||||
|
||||
/// Wait for the fence, a slice at a time, each a section, then reset it: whether it was
|
||||
/// signalled. `None` where the process is exiting.
|
||||
/// signalled. `None` where the process is exiting or the device was lost.
|
||||
fn wait(&self, parts: &Parts) -> Option<bool> {
|
||||
loop {
|
||||
let _busy = exit_guard::enter()?;
|
||||
@@ -1892,6 +1908,11 @@ impl Objects {
|
||||
let waited =
|
||||
unsafe { raw.wait_for_fences(&[self.fence], true, WAIT_SLICE.as_nanos() as u64) };
|
||||
exit_guard::called(Call::WaitForFences);
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
let waited = match parts.checks.lost_at_wait.swap(false, Ordering::AcqRel) {
|
||||
true => Err(vk::Result::ERROR_DEVICE_LOST),
|
||||
false => waited,
|
||||
};
|
||||
match waited {
|
||||
Ok(()) => {
|
||||
// SAFETY: the fence is signalled, in no pending submission.
|
||||
@@ -1900,6 +1921,7 @@ impl Objects {
|
||||
return Some(reset.is_ok());
|
||||
}
|
||||
Err(vk::Result::TIMEOUT) => continue,
|
||||
Err(vk::Result::ERROR_DEVICE_LOST) => return None,
|
||||
Err(_) => return Some(false),
|
||||
}
|
||||
}
|
||||
@@ -1935,7 +1957,7 @@ impl Objects {
|
||||
|
||||
/// Let the objects go, inside a section: whether it ran (`false` once the process is
|
||||
/// exiting, the objects then left to its end). No submission naming them is pending: each
|
||||
/// was waited for.
|
||||
/// was waited for, or the device was lost, which Vulkan counts as their completion.
|
||||
fn release(&self, parts: &Parts) -> bool {
|
||||
let _held = parts.step_held();
|
||||
let Some(_busy) = exit_guard::enter() else {
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
use super::blit_holds::{Scratch, WAIT};
|
||||
use crate::fresh_pages::FRESH_PAGES_PAST;
|
||||
use crate::submit_check::{record_name, Check, Verdict, TAX_IMPORTS};
|
||||
use crate::submit_check::{record_name, Check, Verdict, MERGED, TAX_IMPORTS};
|
||||
use crate::tests::SETTLE;
|
||||
use crate::{
|
||||
CommandBufferStatus, Device, DeviceKind, DeviceOptions, EventRef, LayerSetting,
|
||||
@@ -32,6 +32,9 @@ use crate::{
|
||||
};
|
||||
use metal2vulkan::vk::DriverId;
|
||||
use std::path::Path;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
/// The device the cfg selects, its shader cache in `cache`.
|
||||
fn device(cache: &Path) -> Device {
|
||||
@@ -173,6 +176,76 @@ fn the_checks_answer_once_and_a_second_device_recalls_them() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A loss of the device the checks meet stops them at the call that answers it, here a wait for
|
||||
/// their fence answering `VK_ERROR_DEVICE_LOST` (injected, `SubmitChecks::lost_at_wait`): nothing
|
||||
/// is submitted after it, so no fence or command buffer of theirs goes to the lost device again,
|
||||
/// and they record nothing, each check that had not answered `Unchecked` for the device's life.
|
||||
/// On the M3 Max (MoltenVK 1.4.2), a real loss under the program's own
|
||||
/// `MVK_CONFIG_RESUME_LOST_DEVICE` off had them submit their fence and command buffer again, which
|
||||
/// the validation layer read as still pending (`VUID-vkQueueSubmit-fence-00064`,
|
||||
/// `VUID-vkQueueSubmit-pCommandBuffers-00071`).
|
||||
#[test]
|
||||
fn a_loss_stops_the_checks_with_nothing_submitted_again_or_recorded() {
|
||||
let scratch = Scratch::new("submit-check-loss");
|
||||
let device = device(&scratch.0);
|
||||
let checks = Arc::clone(&device.shared().submit_checks);
|
||||
checks.held.hold();
|
||||
// The checks started as the device was made: they wait at their next step, or ended.
|
||||
let deadline = Instant::now() + WAIT;
|
||||
while checks.held.waiting() == 0 && !device.settle_submit_checks(Duration::ZERO) {
|
||||
assert!(
|
||||
Instant::now() < deadline,
|
||||
"the checks neither held nor ended"
|
||||
);
|
||||
std::thread::sleep(Duration::from_millis(1));
|
||||
}
|
||||
if checks.held.waiting() == 0 {
|
||||
checks.held.release();
|
||||
println!(
|
||||
"SKIPPED {}: the device's submission checks ended before the hold",
|
||||
device.name()
|
||||
);
|
||||
return;
|
||||
}
|
||||
let before = device.work_counts().submit_check_calls;
|
||||
checks.lost_at_wait.store(true, Ordering::Release);
|
||||
checks.held.release();
|
||||
assert!(
|
||||
device.settle_submit_checks(SETTLE),
|
||||
"the checks never ended"
|
||||
);
|
||||
let counts = device.work_counts();
|
||||
let calls = counts.submit_check_calls - before;
|
||||
let answered = verdicts(&device);
|
||||
println!(
|
||||
"{}: {calls} calls from the hold, verdicts {answered:?}",
|
||||
device.name()
|
||||
);
|
||||
assert!(
|
||||
!checks.lost_at_wait.load(Ordering::Acquire),
|
||||
"the checks waited for no fence after the hold"
|
||||
);
|
||||
// One submission's calls, the one whose wait met the loss: a merge round's apart form
|
||||
// makes [`MERGED`].
|
||||
assert!(
|
||||
(1..=MERGED as u64).contains(&calls),
|
||||
"{calls} calls from the hold: the checks submitted again after the loss"
|
||||
);
|
||||
assert_eq!(counts.submit_checks_run, 0, "the checks ran to their end");
|
||||
assert!(
|
||||
!answered.contains(&Verdict::Pending),
|
||||
"the stopped checks left {answered:?}"
|
||||
);
|
||||
// The device goes, its cache thread writing what it queued as it goes: no record among it.
|
||||
let name = record_name(&device.driver_identity());
|
||||
drop(device);
|
||||
let found = files_named(&scratch.0, &name);
|
||||
assert!(
|
||||
found.is_empty(),
|
||||
"a lost device's checks recorded {found:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The paths the verdicts choose: grouped batches, fresh pages, releasable pointer imports.
|
||||
#[test]
|
||||
fn the_paths_follow_the_verdicts() {
|
||||
|
||||
Reference in new issue
Block a user