Skip to content

Commit 835399a

Browse files
committed
[runtime/iouring/waker] cleanup
1 parent 74b2adf commit 835399a

1 file changed

Lines changed: 48 additions & 24 deletions

File tree

runtime/src/iouring/waker.rs

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,11 +1322,6 @@ mod loom_tests {
13221322
}
13231323
}
13241324

1325-
// Number of deterministic `ProducerOp` programs to generate per test.
1326-
const GENERATED_CASES: usize = 8;
1327-
// Number of operations in each generated `ProducerOp` program.
1328-
const OPS_PER_PROGRAM: usize = 3;
1329-
13301325
#[test]
13311326
fn publish_pending_pairing() {
13321327
// `publish` must make the producer's earlier enqueue-side write visible
@@ -1868,7 +1863,7 @@ mod loom_tests {
18681863
#[test]
18691864
fn generated_producer_only_programs() {
18701865
// Generate deterministic producer-only programs before entering loom,
1871-
// then model each case with four concurrent producers. Each producer
1866+
// then model each case with two concurrent producers. Each producer
18721867
// runs a short sequence of `publish()` and out-of-band `wake()` calls
18731868
// without any loop thread consuming them.
18741869
//
@@ -1878,14 +1873,15 @@ mod loom_tests {
18781873
// never armed in this test, producers must also leave no wait target
18791874
// armed and must not queue modeled eventfd readiness. A sticky wake bit
18801875
// may remain because there is intentionally no loop to consume it.
1876+
const CASES: usize = 24;
1877+
const OPS_PER_PROGRAM: usize = 5;
1878+
18811879
let mut rng = test_rng();
1882-
let programs = (0..GENERATED_CASES)
1880+
let programs = (0..CASES)
18831881
.map(|_| {
18841882
[
18851883
ProducerOp::generate_program(&mut rng, OPS_PER_PROGRAM),
18861884
ProducerOp::generate_program(&mut rng, OPS_PER_PROGRAM),
1887-
ProducerOp::generate_program(&mut rng, OPS_PER_PROGRAM),
1888-
ProducerOp::generate_program(&mut rng, OPS_PER_PROGRAM),
18891885
]
18901886
})
18911887
.collect::<Vec<_>>();
@@ -1933,21 +1929,14 @@ mod loom_tests {
19331929
}
19341930
}
19351931

1936-
#[test]
1937-
fn generated_eventfd_loop_programs() {
1938-
// Generate deterministic single-producer programs before entering loom,
1939-
// then model each case with one producer and the eventfd loop simulator.
1940-
// The producer may interleave out-of-band `wake()` calls before,
1941-
// between, or after its generated `publish()` calls.
1942-
//
1943-
// The loop simulator must eventually observe exactly the generated
1944-
// publish count, regardless of whether progress arrives through
1945-
// `pending()` or through the arm, eventfd readiness, and `clear_wait()`
1946-
// path. Pure wakes are allowed to resume the loop, but they must not
1947-
// create sequence progress or disturb producer accounting.
1932+
fn generated_loop_programs(
1933+
cases: usize,
1934+
ops_per_program: usize,
1935+
simulate_loop_until: fn(&Waker, u32, u32) -> u32,
1936+
) {
19481937
let mut rng = test_rng();
1949-
let programs = (0..GENERATED_CASES)
1950-
.map(|_| ProducerOp::generate_program(&mut rng, OPS_PER_PROGRAM))
1938+
let programs = (0..cases)
1939+
.map(|_| ProducerOp::generate_program(&mut rng, ops_per_program))
19511940
.collect::<Vec<_>>();
19521941

19531942
for (iter, program) in programs.into_iter().enumerate() {
@@ -1971,7 +1960,7 @@ mod loom_tests {
19711960
}
19721961
});
19731962

1974-
let processed = simulate_eventfd_loop_until(&waker, 0, publish_count);
1963+
let processed = simulate_loop_until(&waker, 0, publish_count);
19751964
producer.join().unwrap();
19761965

19771966
assert_eq!(
@@ -1992,4 +1981,39 @@ mod loom_tests {
19921981
});
19931982
}
19941983
}
1984+
1985+
#[test]
1986+
fn generated_eventfd_loop_programs() {
1987+
// Generate deterministic single-producer programs before entering loom,
1988+
// then model each case with one producer and the eventfd loop simulator.
1989+
// The producer may interleave out-of-band `wake()` calls before,
1990+
// between, or after its generated `publish()` calls.
1991+
//
1992+
// The loop simulator must eventually observe exactly the generated
1993+
// publish count, regardless of whether progress arrives through
1994+
// `pending()` or through the arm, eventfd readiness, and `clear_wait()`
1995+
// path. Pure wakes are allowed to resume the loop, but they must not
1996+
// create sequence progress or disturb producer accounting.
1997+
const CASES: usize = 96;
1998+
const OPS_PER_PROGRAM: usize = 3;
1999+
2000+
generated_loop_programs(CASES, OPS_PER_PROGRAM, simulate_eventfd_loop_until);
2001+
}
2002+
2003+
#[test]
2004+
fn generated_futex_loop_programs() {
2005+
// Generate deterministic single-producer programs before entering loom,
2006+
// then model each case with one producer and the futex idle loop
2007+
// simulator. The producer may interleave out-of-band `wake()` calls
2008+
// before, between, or after its generated `publish()` calls.
2009+
//
2010+
// This is the futex-path counterpart to `generated_eventfd_loop_programs`.
2011+
// The loop simulator must drain exactly the generated publish count
2012+
// through `pending()` or `park_idle()`, while pure wakes may resume the
2013+
// futex wait without creating sequence progress.
2014+
const CASES: usize = 16;
2015+
const OPS_PER_PROGRAM: usize = 3;
2016+
2017+
generated_loop_programs(CASES, OPS_PER_PROGRAM, simulate_futex_loop_until);
2018+
}
19952019
}

0 commit comments

Comments
 (0)