rt tests: each busy command buffer a held-group test runs behind is a submission of its own

The held-group tests commit IN_FLIGHT busy command buffers back to back and take the queue to
hold its next commit. Under load the submit thread can wake once for two of those commits and
send them as one group. The queue then has one submission fewer in flight than the test counts.
The next commit goes at once and nothing is held behind the busy ones.

On the RX 7900 XTX under the parallel suite (m3-max-46710, 4 of about 100 runs),
every_device_sends_the_held_group_a_command_buffer_without_a_submission_retires_behind read
`before + 3` submissions when its fill left Committed. At the 60 s timeout all five of its
command buffers were Completed and the count had not moved: four command buffers with GPU work in
three submissions. The empty command buffer behind them retired behind the work in flight with
no submission, as rt does when no group is held, so the wait for a new submission could never
end. rt was right; the test's precondition was not.

busy_alone commits a busy command buffer and returns once the submission counter has passed its
value before the commit. The next one is committed after that submission and cannot join its
group. behind_busy uses it, which covers three tests whose checks rest on IN_FLIGHT separate
submissions:
- every_device_sends_the_held_group_a_command_buffer_without_a_submission_retires_behind (the
  timeout above);
- every_device_sends_a_held_group_when_a_submission_completes (asserts AHEAD + 1 submissions);
- every_device_sends_a_held_group_at_the_wait_hint (counts AHEAD before the hint).
every_device_keeps_three_submissions_in_flight_and_holds_the_fourth (waits for exactly before + 3)
and every_device_counts_what_a_second_queue_adds (counts AHEAD lone submissions) commit their busy
ones through it too. Every other behind_busy test gets the same exact precondition.

Verified: the compile job (m2v_gpu clippy and the tests on lavapipe) and an XTX run under load,
named in the hand-off.
This commit is contained in:
Anees Iqbal committed 2026-11-18 07:57:53 -08:00
1 parent d392d453d6
commit 3309532960
1 file changed
+32 -9
+32 -9
View File
@@ -959,16 +959,34 @@ pub(crate) mod on_device {
command_buffer
}
/// [`busy`], returned once its submission is counted, so each busy one is a submission of its
/// own: committed after the one before it was submitted, it cannot join that one's group. A
/// submit thread that wakes late (a loaded host) otherwise takes two commits into one group;
/// the queue then has a submission fewer in flight than the test counts, holds nothing behind
/// them, and what the test waits for behind a held group never comes.
fn busy_alone(
name: &str,
device: &Device,
queue: &CommandQueue,
buffer: &Buffer,
fills: u32,
) -> CommandBuffer {
let before = device.counters().metrics().submissions;
let command_buffer = busy(queue, buffer, fills);
within(name, || device.counters().metrics().submissions > before);
command_buffer
}
/// The submissions a queue keeps in flight before it holds a group ([`IN_FLIGHT`]).
const AHEAD: u64 = IN_FLIGHT as u64;
/// Runs `body` with as many command buffers of busy work committed on `queue` as a queue
/// keeps in flight ([`IN_FLIGHT`]), so its next commit is held, each of more fills each time,
/// until `body` answers that it checked what it holds while they ran: that the work did not
/// end first. `body` takes the busy ones, the submissions counted before them, and the
/// progress the completion thread had seen before them (`Done::completed`): every earlier
/// command buffer's, so the progress stays there until it sees a busy one complete, and a held
/// group goes no earlier than that.
/// keeps in flight ([`IN_FLIGHT`]), each a submission of its own ([`busy_alone`]), so its next
/// commit is held, each of more fills each time, until `body` answers that it checked what it
/// holds while they ran: that the work did not end first. `body` takes the busy ones, the
/// submissions counted before them, and the progress the completion thread had seen before
/// them (`Done::completed`): every earlier command buffer's, so the progress stays there until
/// it sees a busy one complete, and a held group goes no earlier than that.
fn behind_busy(
name: &str,
device: &Device,
@@ -980,7 +998,7 @@ pub(crate) mod on_device {
let before = device.counters().metrics().submissions;
let seen = device.core().done.completed();
let running: Vec<CommandBuffer> = (0..IN_FLIGHT)
.map(|_| busy(queue, &buffer, fills))
.map(|_| busy_alone(name, device, queue, &buffer, fills))
.collect();
let checked = body(&running, before, seen);
for command_buffer in &running {
@@ -1010,7 +1028,9 @@ pub(crate) mod on_device {
let before = device.counters().metrics();
let running: Vec<CommandBuffer> = [&first, &second]
.into_iter()
.flat_map(|queue| (0..IN_FLIGHT).map(|_| busy(queue, &work, fills)))
.flat_map(|queue| {
(0..IN_FLIGHT).map(|_| busy_alone(name, &device, queue, &work, fills))
})
.collect();
let held = [
queue_fill(&first, &buffer, 1),
@@ -1131,7 +1151,10 @@ pub(crate) mod on_device {
let submissions = || device.counters().metrics().submissions;
let checked = [16, 64, 256, 1024].into_iter().any(|fills| {
let before = submissions();
let running = [busy(&queue, &work, fills), busy(&queue, &work, fills)];
let running = [
busy_alone(name, &device, &queue, &work, fills),
busy_alone(name, &device, &queue, &work, fills),
];
let alone = queue_fill(&queue, &buffer, 1);
within(name, || submissions() == before + 3);
let held = queue_fill(&queue, &buffer, 2);