| 1 | /* @title: Test perturbers */ |
| 2 | #pragma once |
| 3 | #include <stddef.h> |
| 4 | #include <stdint.h> |
| 5 | #include <test/conc.h> |
| 6 | #include <types/types.h> |
| 7 | |
| 8 | /* Background noise to create IPIs/DPCs and other stuff */ |
| 9 | #define TEST_PERTURB_VICTIM_BIAS 4 |
| 10 | |
| 11 | /* No victim CPU given */ |
| 12 | #define TEST_PERTURB_VICTIM_ANY (-1) |
| 13 | |
| 14 | struct test_perturb_env { |
| 15 | struct test_conc *conc; |
| 16 | size_t subject_count; |
| 17 | int64_t victim_cpu; /* TEST_PERTURB_VICTIM_ANY or a CPU id */ |
| 18 | |
| 19 | void (*finding)(const char *kind, const char *msg); |
| 20 | }; |
| 21 | |
| 22 | typedef void (*test_perturb_fn)(const struct test_perturb_env *env, |
| 23 | struct test_conc_worker *self); |
| 24 | |
| 25 | struct test_perturb_desc { |
| 26 | const char *name; |
| 27 | test_perturb_fn fn; |
| 28 | }; |
| 29 | |
| 30 | /* 0 = default */ |
| 31 | struct test_perturb_config { |
| 32 | const char *name; |
| 33 | time_ns_t interval_us; |
| 34 | time_ns_t period_ms; |
| 35 | time_ns_t gap_ms; |
| 36 | }; |
| 37 | |
| 38 | const struct test_perturb_desc *test_perturb_lookup(const char *name); |
| 39 | |
| 40 | struct test_perturb_config *test_perturb_config_lookup(const char *name); |
| 41 | struct test_perturb_config *test_perturb_config_lookup_n(const char *name, |
| 42 | size_t len); |
| 43 | |
| 44 | void test_perturb_migrator(const struct test_perturb_env *env, |
| 45 | struct test_conc_worker *self); |
| 46 | void test_perturb_waker(const struct test_perturb_env *env, |
| 47 | struct test_conc_worker *self); |
| 48 | void test_perturb_apc_spammer(const struct test_perturb_env *env, |
| 49 | struct test_conc_worker *self); |
| 50 | void test_perturb_alloc_pressure(const struct test_perturb_env *env, |
| 51 | struct test_conc_worker *self); |
| 52 | void test_perturb_inject_armer(const struct test_perturb_env *env, |
| 53 | struct test_conc_worker *self); |
| 54 | void test_perturb_ipi_storm(const struct test_perturb_env *env, |
| 55 | struct test_conc_worker *self); |
| 56 | void test_perturb_dpc_storm(const struct test_perturb_env *env, |
| 57 | struct test_conc_worker *self); |
| 58 | |