From 84b2d93c70136aa56216a33c394dfec19539d508 Mon Sep 17 00:00:00 2001 From: Dennis Kempin Date: Wed, 10 Mar 2021 16:39:46 -0800 Subject: [PATCH] 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 Reviewed-by: Chirantan Ekbote Commit-Queue: Dennis Kempin --- io_uring/src/uring.rs | 34 +++++++--------------------------- run_tests | 7 ++++++- 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/io_uring/src/uring.rs b/io_uring/src/uring.rs index 6586a71b4b..130f057523 100644 --- a/io_uring/src/uring.rs +++ b/io_uring/src/uring.rs @@ -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. } } diff --git a/run_tests b/run_tests index 39f2f391cf..9185d93a28 100755 --- a/run_tests +++ b/run_tests @@ -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],