Tests: grouped completion wakes and a committing pass's end take no queue turns

Two tests failed on lavapipe since RUNTIME 2490 (8f1e4157d8, fair queue turns). Both still
passed at 44505b3807, and both fail at b874899768 and 20844a0232:
- runtime_lane::grouped_submissions::completions_wake_the_scheduler_only_once_a_head_may_go
  failed 3/3 with "5 wakings by completions" (wakes <= 1).
- tests::submission_turns::a_committing_pass_ends_at_its_own_submission_handlers_grouped failed
  with (Some(3), 1) vs (Some(3), 0): one scheduler slice rescue.

Cause (a diagnostic run printing the turn counters, lavapipe, msi job m3-max-38335, 3 runs):
- lavapipe has one graphics VkQueue, so each test's two command queues share it, and under the
  default `QueueTurnPolicy::Fair` the scheduler holds a queue's batch for its turn while its own
  work is in flight there.
- grouped_submissions: 6-7 heads held for queue turns (`heads_held_for_queue_turns`), 3-5 let go
  idle, 1-2 slice rescues; 4-5 completion wakes. Those wakes are the turns letting the fills'
  queue go on, not the checked head's.
- submission_turns: 2 heads held for queue turns, 0 completion wakes, 1 slice rescue. The later
  batches the committing pass left were held for their turns, not sent at its wake.

Neither test is about the turns: one checks when completions wake the scheduler for a head
waiting on a GPU signal, the other the wake a committing pass gives for the batches it leaves.
So both now make their device with `QueueTurnPolicy::CommitOrder`, as queue_share_device's tests
do for the sharing they measure; `tests::queue_turns` tests the turns themselves.

The slice rescue under Fair (a turn-held head let go by the sleep slice, no wake having come) is
reported to the turns' owner, not hidden here.

Verified: lavapipe runs of this commit (named in the tip report).
This commit is contained in:
Anees Iqbal committed 2026-11-16 17:12:04 -08:00
1 parent b2e4d9811f
commit b9f584ffc1
2 files changed
+17 -6

No files matched your search

@@ -71,7 +71,7 @@ use crate::{
host_time, Buffer, CommandBuffer, CommandBufferStatus, CommandQueue, Device, DeviceKind,
DeviceOptions, ResourceOptions,
};
use metal2vulkan::device::CompletionPolicy;
use metal2vulkan::device::{CompletionPolicy, QueueTurnPolicy};
use std::sync::{mpsc, Arc, Mutex};
use std::time::Duration;
@@ -561,11 +561,17 @@ type Noted = Arc<Mutex<Vec<(&'static str, u64)>>>;
/// The module docs' check of a committing pass's end, under `completion`.
fn a_committing_pass_ends_at_its_own(completion: CompletionPolicy) {
// Its two queues, each on the device's plan.
let options = DeviceOptions {
// Its two queues, each on the device's plan, taking no turns on a `VkQueue` they share
// (`QueueTurnPolicy::CommitOrder`): the check is of the wake the committing pass gives the
// scheduler's thread for the three batches it leaves, each ready. Under `Fair`, where the two
// queues share one (lavapipe, RADV, ANV), a later batch of a queue whose work is in flight there
// is held for its turn instead, and goes when the thread looks again after that, not at that
// wake.
let mut options = DeviceOptions {
queue_limits: None,
..DeviceOptions::default()
};
options.policy.queue_turns = QueueTurnPolicy::CommitOrder;
let device = device_with(completion, options);
let [first, second] = [(); 2].map(|()| device.new_command_queue().unwrap());
let targets = [(); 2].map(|()| (device.new_buffer(FILL, ResourceOptions::private())).unwrap());
@@ -69,7 +69,7 @@ use super::{
ScratchCache, WAIT,
};
use crate::gpu::TEST_DEVICE;
use metal2vulkan::device::CompletionPolicy;
use metal2vulkan::device::{CompletionPolicy, QueueTurnPolicy};
use metal2vulkan_runtime::{
Buffer, CommandBuffer, CommandBufferStatus, CommandQueue, Degradation, DeviceOptions, EventRef,
ResourceOptions, ShaderCacheOptions, WorkCounts,
@@ -321,8 +321,12 @@ const LARGE_FILL: u64 = 64 << 20;
/// waits for is met, not at each batch that completes. The first fill waits for a gate the host
/// raises once the checked command buffer is committed, so the scheduler holds the check before
/// any fill completes; a wake at every completion while a head waits would count about one a
/// fill. Under `CompletionPolicy::Exact`, so each fill is a submission of its own; every command
/// buffer completes, and the layer reports nothing.
/// fill. Under `CompletionPolicy::Exact`, so each fill is a submission of its own, and with the
/// queues taking no turns on a `VkQueue` they share (`QueueTurnPolicy::CommitOrder`), so every
/// fill is submitted as it is ready: under `Fair`, where the two queues share one (lavapipe, RADV,
/// ANV), the fills' queue is held for its turn behind its own fills in flight, and each of those
/// that completes wakes the thread to let the next go, the turns' own wakes, which
/// `tests::queue_turns` covers. Every command buffer completes, and the layer reports nothing.
#[test]
fn completions_wake_the_scheduler_only_once_a_head_may_go() {
let messages = Messages::default();
@@ -330,6 +334,7 @@ fn completions_wake_the_scheduler_only_once_a_head_may_go() {
let (seen, wakes) = {
let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), |options| {
options.policy.completion = CompletionPolicy::Exact;
options.policy.queue_turns = QueueTurnPolicy::CommitOrder;
at_plan(options)
})
.unwrap();