From 135c666518edd90d87dc04f05149476dcabadd9f Mon Sep 17 00:00:00 2001 From: Janne Peltonen Date: Fri, 19 Jan 2024 09:59:01 +0200 Subject: [PATCH 1/2] validation: sched: run 2-thread order wait test with one worker too Run the 2-thread odp_schedule_order_wait() test regardless of the number of worker CPUs. The test anyway uses just single worker thread and the main (control) thread. This enables the test in systems with just one or two CPUs. Signed-off-by: Janne Peltonen Reviewed-by: Matias Elo --- test/validation/api/scheduler/scheduler.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/test/validation/api/scheduler/scheduler.c b/test/validation/api/scheduler/scheduler.c index 9beb6c72d0..87069f7fe8 100644 --- a/test/validation/api/scheduler/scheduler.c +++ b/test/validation/api/scheduler/scheduler.c @@ -2481,16 +2481,6 @@ static void scheduler_test_order_wait_2_threads(void) CU_ASSERT(odp_queue_destroy(queue) == 0); } -static int check_2_workers(void) -{ - if (globals->num_workers < 2) { - printf("\nTest: scheduler_test_order_wait_2_threads: SKIPPED\n"); - return ODP_TEST_INACTIVE; - } - - return ODP_TEST_ACTIVE; -} - static int sched_and_plain_thread(void *arg) { odp_event_t ev1, ev2; @@ -3689,7 +3679,7 @@ odp_testinfo_t scheduler_basic_suite[] = { ODP_TEST_INFO(scheduler_test_pause_enqueue), ODP_TEST_INFO(scheduler_test_ordered_lock), ODP_TEST_INFO(scheduler_test_order_wait_1_thread), - ODP_TEST_INFO_CONDITIONAL(scheduler_test_order_wait_2_threads, check_2_workers), + ODP_TEST_INFO(scheduler_test_order_wait_2_threads), ODP_TEST_INFO_CONDITIONAL(scheduler_test_flow_aware, check_flow_aware_support), ODP_TEST_INFO(scheduler_test_parallel), From 06bc848de031b6b3acc98d2c9cd4e8399c90a5b6 Mon Sep 17 00:00:00 2001 From: Janne Peltonen Date: Fri, 19 Jan 2024 09:59:02 +0200 Subject: [PATCH 2/2] validation: time: relax global time sync tolerance with 1 CPU When running the 2-thread time_test_global_sync_control() test in a system with only one CPU core, the control and worker threads run in the same core, which shows up as time differences of the order of the thread scheduling interval of the underlying OS. Increase the allowed error when the threads run in the same CPU core. Signed-off-by: Janne Peltonen Reviewed-by: Matias Elo --- test/validation/api/time/time.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/validation/api/time/time.c b/test/validation/api/time/time.c index ef406a0258..cfef7f6192 100644 --- a/test/validation/api/time/time.c +++ b/test/validation/api/time/time.c @@ -1,5 +1,5 @@ /* Copyright (c) 2015-2018, Linaro Limited - * Copyright (c) 2019-2023, Nokia + * Copyright (c) 2019-2024, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -24,6 +24,7 @@ #define TIME_SAMPLES 2 #define TIME_TOLERANCE_NS 1000000 #define TIME_TOLERANCE_CI_NS 40000000 +#define TIME_TOLERANCE_1CPU_NS 40000000 #define GLOBAL_SHM_NAME "GlobalTimeTest" #define YEAR_IN_NS (365 * 24 * ODP_TIME_HOUR_IN_NS) @@ -858,8 +859,7 @@ static void time_test_global_sync(const int ctrl) odph_thread_common_param_t thr_common; odph_thread_param_t thr_param; odph_thread_t thread_tbl[MAX_WORKERS]; - const uint64_t tolerance = - odp_cunit_ci() ? TIME_TOLERANCE_CI_NS : TIME_TOLERANCE_NS; + uint64_t tolerance = odp_cunit_ci() ? TIME_TOLERANCE_CI_NS : TIME_TOLERANCE_NS; const int num = ctrl ? 2 : global_mem->num_threads; if (num < 2) { @@ -879,14 +879,23 @@ static void time_test_global_sync(const int ctrl) if (ctrl) { /* Test sync between one control and one worker thread. */ + int control_cpu; + int worker_cpu; + odp_cpumask_default_control(&cpumask, 1); thr_common.cpumask = &cpumask; thr_param.thr_type = ODP_THREAD_CONTROL; + control_cpu = odp_cpumask_first(&cpumask); int r = odph_thread_create(&thread_tbl[thr++], &thr_common, &thr_param, 1); CU_ASSERT_FATAL(r == 1); odp_cpumask_default_worker(&cpumask, 1); + worker_cpu = odp_cpumask_first(&cpumask); + if (control_cpu == worker_cpu) { + printf(" single CPU, relaxing tolerance. "); + tolerance = TIME_TOLERANCE_1CPU_NS; + } } else { /* Test sync between num worker threads. */ odp_cpumask_default_worker(&cpumask, num);