Fix io_uring tests for running on Kokoro

Some of the multi-threaded tests had race conditions that show up when
running inside the Kokoro Test VMs.

To wake up and complete all running threads, no-ops are inserted into
the uring. However, each thread can grab a list of results. On the
test VMs, all no-ops are read by one thread, leaving the others running,
blocking the test from completing.

Since this is just a test.. let's just leave the threads hanging and
let the OS take care of them.

BUG=b:181673923
TEST=./test_all

Change-Id: I504b6db9cf934e2454d27c1155667b4b0f7fbc77
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2750783
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
This commit is contained in:
Dennis Kempin 2021-03-10 16:39:46 -08:00 committed by Commit Bot
parent dcf540be92
commit 84b2d93c70
2 changed files with 13 additions and 28 deletions

View file

@ -1338,15 +1338,7 @@ mod tests {
}
mem::drop(c);
// Now add NOPs to wake up any threads blocked on the syscall.
for i in 0..NUM_THREADS {
uring.add_nop((num_entries * 3 + i) as UserData).unwrap();
}
uring.submit().unwrap();
for t in threads {
t.join().unwrap();
}
// Let the OS clean up the still-waiting threads after the test run.
}
#[test]
@ -1512,30 +1504,18 @@ mod tests {
t.join().unwrap();
}
// Now that all submitters are finished, add NOPs to wake up any completers blocked on the
// syscall.
for i in 0..NUM_COMPLETERS {
uring
.add_nop((NUM_SUBMITTERS * ITERATIONS + i) as UserData)
.unwrap();
}
uring.submit().unwrap();
for t in threads {
t.join().unwrap();
}
// Make sure we didn't submit more entries than expected. Only the last few NOPs added to
// wake up the completer threads may still be in the completion ring.
assert!(uring.complete_ring.num_ready() <= NUM_COMPLETERS as u32);
// Make sure we didn't submit more entries than expected.
assert_eq!(uring.complete_ring.num_ready(), 0);
assert_eq!(
in_flight.lock().abs() as u32 + uring.complete_ring.num_ready(),
NUM_COMPLETERS as u32
0
);
assert_eq!(uring.submit_ring.lock().added, 0);
assert_eq!(
uring.stats.total_ops.load(Ordering::Relaxed),
(NUM_SUBMITTERS * ITERATIONS + NUM_COMPLETERS) as u64
(NUM_SUBMITTERS * ITERATIONS) as u64
);
// Leave the completer threads hanging to be cleaned up by the OS.
}
}

View file

@ -11,6 +11,7 @@ from typing import List, Dict
from ci.test_runner import Requirements, main
# A list of all crates and their requirements
# See ci/test_runner.py for documentation on the requirements
CRATE_REQUIREMENTS: Dict[str, List[Requirements]] = {
"aarch64": [Requirements.AARCH64],
"crosvm": [Requirements.DISABLED],
@ -35,7 +36,11 @@ CRATE_REQUIREMENTS: Dict[str, List[Requirements]] = {
"fuzz": [Requirements.DISABLED],
"gpu_display": [],
"hypervisor": [Requirements.PRIVILEGED, Requirements.X86_64],
"io_uring": [Requirements.DISABLED],
"io_uring": [
Requirements.SEPARATE_WORKSPACE,
Requirements.PRIVILEGED,
Requirements.SINGLE_THREADED,
],
"kernel_cmdline": [],
"kernel_loader": [Requirements.PRIVILEGED],
"kvm_sys": [Requirements.PRIVILEGED],