rt tests: stalled lowering writes stay in their queue, so a full queue drops the next one

every_device_writes_its_lowerings_off_the_creating_thread_and_drops_them_past_its_queue hung on
lavapipe after 7a9458f983 (capover's check m3-max-64386: SLOW past 300 s; it passed at 8bef47758f
in m3-max-64358). The stall made the reaper pop a file and then spin in write_kept, so the queue
could be empty when the test set its bound to the bytes waiting. Since 7a9458f983 an empty queue
takes a file of any size, so the second kernel's lowering was kept, not dropped; the assertion
failed with the writes still stalled, and the device's teardown waited forever on a reaper spinning
in write_kept.

Now the stall is taken where the reaper takes a write: next_write answers none while stalled, the
queue keeps every file handed over, and the test pokes the reaper when it lets them go. The
product path is unchanged (the stall is test-only).
This commit is contained in:
Anees Iqbal committed 2026-11-21 11:05:03 -08:00
1 parent 0219b3ae73
commit 3ce7cf118b
2 files changed
+13 -9

No files matched your search

+12 -9
View File
@@ -1197,7 +1197,9 @@ impl Caches {
self.blob.get().map(PathBuf::as_path)
}
/// Makes the reaper's writes of lowerings wait, or go on, for a test.
/// Keeps the lowerings waiting to be written in their queue, or lets the reaper take them, for
/// a test: the reaper takes none while they are stalled, so the queue holds every one handed
/// over. A test that lets them go pokes the reaper.
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
pub(crate) fn stall_writes(&self, stalled: bool) {
(self.writes_stalled).store(stalled, std::sync::atomic::Ordering::Release);
@@ -1307,21 +1309,22 @@ impl Caches {
kept.flatten()
}
/// The next lowering, refusal or record waiting for the reaper to write it.
/// The next lowering, refusal or record waiting for the reaper to write it; none while a test
/// stalls the writes, which then stay in the queue.
pub(crate) fn next_write(&self) -> Option<(String, Vec<u8>)> {
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
if self
.writes_stalled
.load(std::sync::atomic::Ordering::Acquire)
{
return None;
}
lock(&self.pending).pop()
}
/// On the reaper: writes `bytes` under `file` in the store, as [`keep_translation`] queued
/// them.
pub(crate) fn write_kept(&self, file: &str, bytes: &[u8], counters: &Counters) {
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
while self
.writes_stalled
.load(std::sync::atomic::Ordering::Acquire)
{
std::thread::sleep(Duration::from_millis(1));
}
if let Some(store) = &self.store {
if store.put(file, bytes) {
counters.cache_written(bytes.len() as u64);
@@ -2109,6 +2109,7 @@ mod on_device {
);
caches.set_pending_bound(crate::cache::PENDING_BYTES);
caches.stall_writes(false);
device.core().reaper.poke();
within("the writes", || counters.metrics().cache_bytes_written > 0);
drop((a, b));
drop(device);