Shared test concurrency core
include/test/conc.h View source View on GitHubConcurrency stuff that tests really like to use, primarily for thread fleets and other things. Nightmare tests and regular tests can use these. Some features:
-
Cooperative stops, so deadlines can tell workers to quit instead of abandoning them
-
Quiesce/park so coordinators can bring workers to a stop
-
Per-CPU progress counters for stall detection
Structs
Section titled “Structs”test_rng
Section titled “test_rng”test_progress_counter
Section titled “test_progress_counter” struct test_progress_counter (1 field) source
§
atomic_uint64_t count test_stall_evidence
Section titled “test_stall_evidence”test_conc_worker
Section titled “test_conc_worker” struct test_conc_worker (6 fields) source
test_conc
Section titled “test_conc” struct test_conc (8 fields) source
§
atomic_bool active §
atomic_bool quiesce_requested §
atomic_size_t parked_count §
struct test_conc_worker *workers cc_counted_by(worker_count) §
size_t worker_count An extra thread that should be alerted on stop but isn’t a worker, NULL if unused
test_liveness_state
Section titled “test_liveness_state” struct test_liveness_state (11 fields) source
§
struct watchdog_callback callback §
atomic(enum test_liveness_phase) phase §
uint64_t last_progress §
bool was_quiesced §
struct test_stall_evidence pending §
enum test_on_stall policy §
bool registered test_stop
Section titled “test_stop” enum test_stop : uint8_t (5 variants) source
test_on_stall
Section titled “test_on_stall”test_liveness_phase
Section titled “test_liveness_phase” enum test_liveness_phase : uint8_t (4 variants) source
Functions
Section titled “Functions”test_rng_seed_for
Section titled “test_rng_seed_for”uint64_t test_rng_seed_for(uint64_t base_seed, size_t index) source test_conc_init
Section titled “test_conc_init”void test_conc_init(
struct test_conc *c,
struct test_conc_worker *workers,
size_t worker_count
) source test_conc_publish_stop
Section titled “test_conc_publish_stop”test_conc_park
Section titled “test_conc_park”void test_conc_park(struct test_conc *c, struct test_conc_worker *w) source test_conc_unpark_self
Section titled “test_conc_unpark_self”void test_conc_unpark_self(
struct test_conc *c,
struct test_conc_worker *w
) source test_conc_progress_sum
Section titled “test_conc_progress_sum”uint64_t test_conc_progress_sum(void) source This is a percpu heuristic, migrations are fine
test_liveness_start
Section titled “test_liveness_start”bool test_liveness_start(
struct test_liveness_state *state,
struct test_conc *conc,
time_ms_t threshold_ms,
enum test_on_stall policy
) source test_liveness_stop
Section titled “test_liveness_stop”void test_liveness_stop(struct test_liveness_state *state) source test_liveness_take
Section titled “test_liveness_take”bool test_liveness_take(
struct test_liveness_state *state,
struct test_stall_evidence *out
) source Return stall evidence when pending, false if nothing to report
test_conc_progress_tick
Section titled “test_conc_progress_tick”void test_conc_progress_tick(void) source test_rng_next
Section titled “test_rng_next”test_conc_must_stop
Section titled “test_conc_must_stop”test_conc_stop_reason
Section titled “test_conc_stop_reason”test_conc_must_park
Section titled “test_conc_must_park”Macros
Section titled “Macros”TEST_PROGRESS
Section titled “TEST_PROGRESS”#define TEST_PROGRESS() source Expansion
#define TEST_PROGRESS() test_conc_progress_tick()