observe: a timed-out stamp is dropped, and nothing said which of two losses it was
Component: crates/reims-vgpu, Vulkan completion rail. Pathway: x86 macOS / Linux Vulkan. Rail: macos-15. API contract. `IOGPUEventMachine::waitForStamp(index, target)` reads the stamp word out of the page this device writes, compares `target - current <= 0` signed, and when the target has not been reached sleeps on the word's own address with a one-second deadline, re-reading the word on every wake. The interrupt is the wakeup, not the notification. So the word is the whole delivery: a wakeup that arrives without one is not a partial delivery, it is none, and the guest's deadline is a re-read timer rather than a give-up. Owning invariant: the completion word for a FIFO submission becomes guest visible when that submission completes, and a device that has advertised a timeline point owes its word to whatever is asleep on it. Behavior changed: none. This is observation only. Why. A candidate battery hung, and comparing preserved device logs by their last non-OFF record showed what that means. Five healthy runs do device work until the battery ends (t=111.7k, 113.3k, 112.8k, 111.7k, 112.7k). The hung run does its last work at t=55073 and then idles 575 s further with packets=0, ring_reads=0, draws=0, duty=0.002 and no typed failure: the guest stops sending entirely. Its final three records are three consecutive 5 s fence deadlines covering ~39.3 s to 55 s, during which the timeline never reached 919. Reading the completion thread against that: the TIMEOUT arm withholds the word, which is right on its own terms, because publishing a stamp for work that has not executed tells the guest its results are ready and its inputs are free. But it also pops the entry, so a submission that completes a millisecond later has nothing left that could store its word. That is survivable whenever more work follows, since the wait is `>=` and stamps are monotonic, so a later stamp covers an abandoned one -- which is why control runs carry two of these records each and finish. It is unsurvivable for the last stamp, and a guest asleep in waitForStamp is exactly a guest that has stopped producing the later work. A second candidate for the same wedge: `latest_queued` advances at enqueue rather than at submit, so a point that was reserved and never handed to the queue owner is named as the newest queue point and nothing will ever signal it. Nothing preserved says which of the two happened, and they have opposite repairs, so this records the discriminator instead of guessing. Per timeout it now reports the semaphore's actual counter against the reserved and queued high-water marks and classifies `stamp_timeout_queued_not_run` (handed over, GPU has not run it) against `stamp_timeout_never_submitted` (reserved, never handed over). `stamp_word_abandoned` sizes the population of words the guest can never be told about. Both are summable store_routes counters; the per-occurrence line stays always-on. Verification actually run: cargo fmt --all and --check; clippy -D warnings on all three main arms (aarch64-apple-darwin backend-metal, host backend-vulkan,host-window, x86_64-unknown-linux-gnu backend-vulkan,host-window); the full reims-vgpu suite serially, 2391 passed / 0 failed. Six control conformance batteries were started against the pinned control binary; three completed clean before the loop was killed by process-group cleanup (293/293 cases, 19/19 driver, 0 unexplained, 2 stamp_wait_timeout each, none hung). Not verified: no boot has yet run this instrument, so neither class has been observed. The hang is not reproduced here and its mechanism is not established -- only that the two candidates are distinguishable and were not distinguished before. Metal arm cross-compiles only; its tests did not run. No other pathway or rail was exercised.
This commit is contained in:
1 parent
289efa8efe
commit
44905c6021
1 file changed
+59
-6
@@ -590,12 +590,7 @@ fn run(device: &ash::Device, semaphore: vk::Semaphore, shared: &Shared) {
|
||||
match unsafe { device.wait_semaphores(&info, super::context::FENCE_TIMEOUT_NS) } {
|
||||
Ok(()) => true,
|
||||
Err(vk::Result::TIMEOUT) => {
|
||||
crate::observe::fail(format!(
|
||||
"stamp_wait_timeout reason=stamp_wait_timeout index={} value={} \
|
||||
(the submission carrying this stamp's word has not executed within the \
|
||||
fence deadline; announcing it anyway so the guest is not left asleep)",
|
||||
waiting.index, timeline
|
||||
));
|
||||
note_wait_timeout(device, semaphore, shared, &waiting, timeline);
|
||||
false
|
||||
}
|
||||
Err(e) => {
|
||||
@@ -618,6 +613,15 @@ fn run(device: &ash::Device, semaphore: vk::Semaphore, shared: &Shared) {
|
||||
}
|
||||
};
|
||||
let stopping = shared.stop.load(Ordering::Acquire);
|
||||
if !completed && !stopping {
|
||||
// Size the population the guest can never be told about. The word
|
||||
// is dropped here and the entry is popped below, so this stamp is
|
||||
// gone: a guest sleeping on it wakes on the announcement, re-reads
|
||||
// an unchanged word, and sleeps again on its own one-second
|
||||
// deadline, forever, unless some *later* stamp for the same slot
|
||||
// publishes a value that covers it.
|
||||
crate::runtime::drain::census::note_store_route("stamp_word_abandoned");
|
||||
}
|
||||
if should_publish(completed, stopping) && !publish_stamp_word(&waiting) {
|
||||
crate::observe::fail(format!(
|
||||
"stamp_cpu_store_failed reason=stamp_cpu_store_failed index={} value={:#x} \
|
||||
@@ -641,6 +645,55 @@ fn run(device: &ash::Device, semaphore: vk::Semaphore, shared: &Shared) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Report a stamp whose timeline point did not arrive within the fence
|
||||
/// deadline, and say **which of the two very different things** happened.
|
||||
///
|
||||
/// The deadline alone does not distinguish them, and they have opposite
|
||||
/// repairs:
|
||||
///
|
||||
/// * `counter` has not reached `value`, but `queued` has — the submission was
|
||||
/// handed to the ordered queue owner and the GPU has not run it yet. That is
|
||||
/// a slow or wedged queue, and waiting longer would eventually publish a
|
||||
/// correct word.
|
||||
/// * `counter` has not reached `value` and neither has `queued` — the point was
|
||||
/// *reserved* and never handed to the owner at all. Nothing in flight will
|
||||
/// ever signal it. `submit_guest_work`'s contract says "a later successful
|
||||
/// value may legally skip the unused reservation", and that is sound only
|
||||
/// while later work keeps arriving: `vkWaitSemaphores` is a `>=` wait, so any
|
||||
/// higher signal releases the waiter. A guest blocked in `waitForStamp` is
|
||||
/// precisely a guest that has stopped producing that later work, so for the
|
||||
/// stamp that wedges it the skip is not repaired by anything.
|
||||
///
|
||||
/// Recorded rather than repaired, because the repair differs per branch and no
|
||||
/// preserved run yet names which one wedged it. The counters are summable
|
||||
/// `store_routes` entries; the line is per-occurrence and always-on.
|
||||
fn note_wait_timeout(
|
||||
device: &ash::Device,
|
||||
semaphore: vk::Semaphore,
|
||||
shared: &Shared,
|
||||
waiting: &Waiting,
|
||||
timeline: u64,
|
||||
) {
|
||||
let counter = unsafe { device.get_semaphore_counter_value(semaphore) }.ok();
|
||||
let reserved = shared.next_value.load(Ordering::Acquire);
|
||||
let queued = shared.latest_queued.load(Ordering::Acquire);
|
||||
let route = if queued >= timeline {
|
||||
"stamp_timeout_queued_not_run"
|
||||
} else {
|
||||
"stamp_timeout_never_submitted"
|
||||
};
|
||||
crate::runtime::drain::census::note_store_route(route);
|
||||
crate::observe::fail(format!(
|
||||
"stamp_wait_timeout reason=stamp_wait_timeout index={} value={timeline} counter={} \
|
||||
reserved={reserved} queued={queued} class={route} \
|
||||
(the submission carrying this stamp's word has not executed within the fence \
|
||||
deadline; announcing it anyway so the guest is not left asleep, but the word is \
|
||||
NOT published and this entry is dropped, so no later completion can still deliver it)",
|
||||
waiting.index,
|
||||
counter.map_or_else(|| "unknown".to_string(), |v| v.to_string()),
|
||||
));
|
||||
}
|
||||
|
||||
fn should_publish(completed: bool, stopping: bool) -> bool {
|
||||
completed && !stopping
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user