tests: posix: improvements to pthread_pressure test
* allow `qemu_cortex_a53` * disallow `qemu_leon3 * remove `TEST_DURATION_S` range * additional report formatting Signed-off-by: Christopher Friedt <cfriedt@meta.com>
This commit is contained in:
parent
e1f8ea1ad7
commit
d9bae7ce65
|
@ -8,5 +8,3 @@ CONFIG_POSIX_MQUEUE=y
|
|||
CONFIG_HEAP_MEM_POOL_SIZE=4096
|
||||
CONFIG_MAX_THREAD_BYTES=4
|
||||
CONFIG_THREAD_NAME=y
|
||||
|
||||
CONFIG_SMP=n
|
||||
|
|
|
@ -9,21 +9,13 @@ config TEST_NUM_CPUS
|
|||
range 1 MP_NUM_CPUS
|
||||
default MP_NUM_CPUS
|
||||
help
|
||||
The number of parallel threads to run during the test. The test
|
||||
thread itself yields so that all cores have some probability of
|
||||
causing racey behaviour.
|
||||
The number of parallel threads to run during the test.
|
||||
|
||||
config TEST_DURATION_S
|
||||
int "Number of seconds to run the test"
|
||||
range 1 21600
|
||||
default 5
|
||||
help
|
||||
Duration for the test, in seconds. The range has a reblatively high
|
||||
upper bound because we should expect that pthread_create() and
|
||||
pthread_join() are stable enough to run for an arbitrarily long
|
||||
period of time without encountering any race conditions.
|
||||
|
||||
Some exceptions apply, notably Qemu SMP targets.
|
||||
Duration for the test, in seconds.
|
||||
|
||||
config TEST_DELAY_US
|
||||
int "Microseconds to delay between pthread join and create"
|
||||
|
@ -37,7 +29,7 @@ config TEST_STACK_SIZE
|
|||
default 512 if !64_BIT
|
||||
default 1024 if 64_BIT
|
||||
help
|
||||
The minimal stack size required to run a no-op thread.
|
||||
The minimal stack size required to run a minimal thread.
|
||||
|
||||
config TEST_KTHREADS
|
||||
bool "Test k_threads"
|
||||
|
@ -55,5 +47,4 @@ config TEST_EXTRA_ASSERTIONS
|
|||
bool "Add extra assertions into the hot path"
|
||||
default y
|
||||
help
|
||||
On Qemu SMP targets, this can potentially lead to "scheduler noise"
|
||||
leaking in from the host system, which can cause the test to fail.
|
||||
This can be disabled for benchmarking.
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
CONFIG_ZTEST=y
|
||||
CONFIG_ZTEST_NEW_API=y
|
||||
CONFIG_POSIX_API=y
|
||||
|
||||
## Note: for benchmarking purposes, uncomment the Kconfig below
|
||||
# CONFIG_TEST_DURATION_S=60
|
||||
# CONFIG_TEST_EXTRA_ASSERTIONS=n
|
||||
# CONFIG_ASSERT=n
|
||||
|
||||
## Optionally, uncomment this to only test pthreads:
|
||||
# CONFIG_TEST_KTHREADS=n
|
||||
|
|
|
@ -36,13 +36,16 @@ static bool alive[NUM_THREADS];
|
|||
static K_THREAD_STACK_ARRAY_DEFINE(thread_stacks, NUM_THREADS, STACK_SIZE);
|
||||
|
||||
static struct k_thread k_threads[NUM_THREADS];
|
||||
static size_t counters[NUM_THREADS];
|
||||
static uint64_t counters[NUM_THREADS];
|
||||
static uint64_t prev_counters[NUM_THREADS];
|
||||
|
||||
static void print_stats(uint64_t now, uint64_t end)
|
||||
{
|
||||
printk("now (ms): %llu end (ms): %llu\n", now, end);
|
||||
for (int i = 0; i < NUM_THREADS; ++i) {
|
||||
printk("Thread %d created and joined %zu times\n", i, counters[i]);
|
||||
printk("Thread %d created and joined %llu times (%llu joins/s)\n", i, counters[i],
|
||||
(counters[i] - prev_counters[i]) / UPDATE_INTERVAL_S);
|
||||
prev_counters[i] = counters[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,6 +58,7 @@ static void test_create_join_common(const char *tag, create_fn create, join_fn j
|
|||
uint64_t update_ms = now_ms + MSEC_PER_SEC * UPDATE_INTERVAL_S;
|
||||
|
||||
printk("BOARD: %s\n", CONFIG_BOARD);
|
||||
printk("CONFIG_SMP: %s\n", IS_ENABLED(CONFIG_SMP) ? "y" : "n");
|
||||
printk("NUM_THREADS: %u\n", NUM_THREADS);
|
||||
printk("TEST_NUM_CPUS: %u\n", CONFIG_TEST_NUM_CPUS);
|
||||
printk("TEST_DURATION_S: %u\n", CONFIG_TEST_DURATION_S);
|
||||
|
@ -62,6 +66,7 @@ static void test_create_join_common(const char *tag, create_fn create, join_fn j
|
|||
|
||||
for (i = 0; i < NUM_THREADS; ++i) {
|
||||
/* spawn thread i */
|
||||
prev_counters[i] = 0;
|
||||
ret = create(i);
|
||||
if (IS_ENABLED(CONFIG_TEST_EXTRA_ASSERTIONS)) {
|
||||
zassert_ok(ret, "%s_create(%d)[%zu] failed: %d", tag, i, counters[i], ret);
|
||||
|
|
|
@ -6,7 +6,6 @@ common:
|
|||
integration_platforms:
|
||||
- qemu_riscv64_smp
|
||||
platform_exclude:
|
||||
- qemu_cortex_a53
|
||||
- qemu_cortex_a53_smp
|
||||
- qemu_leon3
|
||||
tests:
|
||||
portability.posix.pthread_pressure: {}
|
||||
|
|
Loading…
Reference in a new issue