rt tests: a fence wait's submissions are counted where no completion round runs, each named
every_device_runs_a_wait_on_a_fence_never_updated_at_once failed once in 35 lavapipe runs
(m3-max-63660 at abb3c82247: 2 submissions where it counted 1). By the code the second could only
be queue A's held group. The test's command buffer on B with nothing for the GPU retires in a round
of the completion thread, which marks Done::busy for the round, and the submit thread sends a held
group in any pass that sees busy (WorkState::unheld). That command buffer reads Completed inside the
round, so the count could begin while the round still ran, and a late pass sent A's group inside
the counted window. That is the submit thread's rule (a group is held only while the completion
thread waits on the GPU), not a broken order: nothing orders B's wait on a fence never updated
after A's update of another fence. The planner accepted a test-only fix.
The test now counts the wait's submissions first, in a window no completion round can run in, and
runs the encoder that only waits on a third queue after the count. A precondition reads A's busy
work in flight with its group held and nothing of B's. The failure names each submission after
the wait's commit: all of them; B's; A's group's, and whether A still holds it; the runtime's own
uploads sent alone; the runtime's own command buffers in them; and the completion thread's rounds,
so a real leak reads differently from a round's send. Two accessors compiled only for the device
tests give it that: Work::in_flight (a queue's submissions not seen complete, and whether it holds
a group) and Pool::rounds. No product behaviour changes.
Verified by the lane's compile job (fmt, clippy plain, --cfg m2v_gpu and --cfg m2v_cpu_icd,
workspace Rustdoc -D warnings) and the whole runtime suite on lavapipe with this test passing, on
this commit; the job ids are in the lane's report.
This commit is contained in:
1 parent
68eec69fb1
commit
583684ebeb
3 files changed
+57
-14
No files matched your search
@@ -985,6 +985,13 @@ impl Pool {
|
||||
}
|
||||
}
|
||||
|
||||
/// For the device tests: the completion thread's rounds of retirements so far
|
||||
/// ([`retired`](Self::retired)).
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
pub(crate) fn rounds(&self) -> u64 {
|
||||
self.rounds.load(Ordering::SeqCst)
|
||||
}
|
||||
|
||||
fn wait<'a>(&self, state: MutexGuard<'a, State>) -> MutexGuard<'a, State> {
|
||||
self.changed
|
||||
.wait(state)
|
||||
|
||||
@@ -1026,6 +1026,16 @@ impl Work {
|
||||
(state.region.as_ref()).map_or_else(Vec::new, |region| region.ring.live())
|
||||
}
|
||||
|
||||
/// For the device tests: `queue`'s submissions not seen complete when the submit thread last
|
||||
/// looked, and whether it holds a group not yet submitted.
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
pub(crate) fn in_flight(&self, queue: &QueueInner) -> (usize, bool) {
|
||||
let state = self.lock();
|
||||
(state.fifos.iter().find(|fifo| fifo.queue.is(queue))).map_or((0, false), |fifo| {
|
||||
(fifo.in_flight.len(), fifo.group.is_some())
|
||||
})
|
||||
}
|
||||
|
||||
/// For the device tests: the queues whose head's next segment the submit thread holds for an
|
||||
/// event's value ([`WorkState::mark_holds`]).
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
|
||||
mod on_device {
|
||||
use crate::submit::IN_FLIGHT;
|
||||
use crate::tests::blit::on_device::settled;
|
||||
use crate::tests::command::on_device::{behind_busy, each_device, finished, within, word};
|
||||
use crate::tests::draw::on_device::{pass, target};
|
||||
@@ -313,9 +314,11 @@ mod on_device {
|
||||
}
|
||||
|
||||
/// A wait on a fence no encoder updated waits for nothing, while queue A holds in a group an
|
||||
/// update of another fence: on queue B, an encoder that only waits on it completes at once,
|
||||
/// and a command buffer with work after the wait goes in one submission of its own, A's group
|
||||
/// staying held.
|
||||
/// update of another fence: on queue B, a command buffer with work after the wait goes in one
|
||||
/// submission of its own, A's group staying held, and on a third queue an encoder that only
|
||||
/// waits on it completes at once. The submissions are counted first: a command buffer with
|
||||
/// nothing for the GPU retires in a round of the completion thread, and a group held goes
|
||||
/// during such a round (`crate::submit`), so none runs while they are counted.
|
||||
#[test]
|
||||
fn every_device_runs_a_wait_on_a_fence_never_updated_at_once() {
|
||||
each_device("fence_never_updated", |name, _, device| {
|
||||
@@ -325,25 +328,48 @@ mod on_device {
|
||||
let counters = device.counters();
|
||||
let a = device.new_command_queue(8).expect("a queue");
|
||||
let b = device.new_command_queue(8).expect("a queue");
|
||||
let c = device.new_command_queue(8).expect("a queue");
|
||||
behind_busy(name, &device, &a, |busy, _, _| {
|
||||
let work = &device.core().work;
|
||||
let updater = update(&a, &written, &updated);
|
||||
staged(name, &updater);
|
||||
let empty = b.command_buffer().expect("a command buffer");
|
||||
let waiter = wait(&b, &written, ©, &never, None);
|
||||
assert_eq!(
|
||||
(
|
||||
work.in_flight(updater.queue()),
|
||||
work.in_flight(waiter.queue())
|
||||
),
|
||||
((IN_FLIGHT, true), (0, false)),
|
||||
"{name}: A's busy work in flight and its group held, nothing of B's"
|
||||
);
|
||||
let (before, rounds) = (counters.metrics(), device.core().pool.rounds());
|
||||
waiter.commit().expect("a commit");
|
||||
staged(name, &waiter);
|
||||
thread::sleep(Duration::from_millis(50));
|
||||
// Nothing is seen complete behind the busy work: each queue's submissions since
|
||||
// are all in flight, and the rest are the runtime's own uploads sent alone.
|
||||
let after = counters.metrics();
|
||||
let all = after.submissions - before.submissions;
|
||||
let (a_sent, a_held) = work.in_flight(updater.queue());
|
||||
let a_sent = a_sent.saturating_sub(IN_FLIGHT) as u64;
|
||||
let b_sent = work.in_flight(waiter.queue()).0 as u64;
|
||||
let alone = all.saturating_sub(a_sent + b_sent);
|
||||
let own = after.runtime_command_buffers - before.runtime_command_buffers;
|
||||
let rounds = device.core().pool.rounds() - rounds;
|
||||
assert_eq!(
|
||||
(all, b_sent, a_sent, a_held, alone, own, rounds),
|
||||
(1, 1, 0, true, 0, 0, 0),
|
||||
"{name}: after the wait's commit, the submissions: all of them; B's, the \
|
||||
wait's; A's group's, and whether A still holds it; the runtime's own uploads \
|
||||
sent alone; the runtime's own command buffers in them (uploads, copy-ins); \
|
||||
and the completion thread's rounds, during which a group held goes"
|
||||
);
|
||||
let empty = c.command_buffer().expect("a command buffer");
|
||||
let mut compute =
|
||||
(empty.compute_command_encoder(DispatchType::Serial)).expect("an encoder");
|
||||
compute.wait_for_fence(&never).expect("a wait");
|
||||
compute.end_encoding();
|
||||
run(name, &empty);
|
||||
let before = counters.metrics().submissions;
|
||||
let waiter = wait(&b, &written, ©, &never, None);
|
||||
waiter.commit().expect("a commit");
|
||||
staged(name, &waiter);
|
||||
thread::sleep(Duration::from_millis(50));
|
||||
assert_eq!(
|
||||
counters.metrics().submissions - before,
|
||||
1,
|
||||
"{name}: the wait's submission alone, the group A holds held"
|
||||
);
|
||||
busy.open();
|
||||
finished(name, &waiter);
|
||||
finished(name, &updater);
|
||||
|
||||
Reference in new issue
Block a user