aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGary S. Robertson <gary.robertson@linaro.org>2016-03-31 08:08:10 -0500
committerMaxim Uvarov <maxim.uvarov@linaro.org>2016-04-11 15:38:42 +0300
commite3e12b62a9c892d1ca00cb2f2b722eeebb602b87 (patch)
tree0a74ded374bfa6f34f7914e99929156f30f6db6f /test
parent4e2b9c195ced95b9b7fd831d708e648576df23ec (diff)
test: correct worker count calculation
During the process of addressing Linaro BUG 2027 which relates to inaccurate reporting of available CPUs by ODP linux-generic when running atop a kernel compiled with NO_HZ_FULL support, a number of instances were encountered in the validation and performance test software where incorrect methods were used to determine the proper (or maximum) number of worker threads to create. See Linaro BUG 2027 for details. https://bugs.linaro.org/show_bug.cgi?id=2027 The use of odp_cpu_count() for this purpose is incorrect and deprecated... odp_cpumask_default_worker() should always be used to determine the set and number of CPUs available for creating worker threads. The use of odp_cpu_count() for this purpose in conjunction with the correct means of determining available CPUs resulted in some tests hanging in calls to odp_barrier_wait() as the barriers were initialized to expect threads on ALL CPUs rather than on worker CPUs alone... and there were too few worker threads created to satisfy the barriers. The changes below correct all instances I could find of this deprecated technique and allowed all tests to complete successfully with the BUG 2027 patch applied. (BTW they also run correctly without that patch after the application of the modifications included here.) Signed-off-by: Gary S. Robertson <gary.robertson@linaro.org> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'test')
-rw-r--r--test/validation/shmem/shmem.c3
-rw-r--r--test/validation/timer/timer.c18
2 files changed, 12 insertions, 9 deletions
diff --git a/test/validation/shmem/shmem.c b/test/validation/shmem/shmem.c
index ba4973d49..0bf38d213 100644
--- a/test/validation/shmem/shmem.c
+++ b/test/validation/shmem/shmem.c
@@ -52,6 +52,7 @@ void shmem_test_odp_shm_sunnyday(void)
pthrd_arg thrdarg;
odp_shm_t shm;
test_shared_data_t *test_shared_data;
+ odp_cpumask_t unused;
shm = odp_shm_reserve(TESTNAME,
sizeof(test_shared_data_t), ALIGE_SIZE, 0);
@@ -70,7 +71,7 @@ void shmem_test_odp_shm_sunnyday(void)
test_shared_data->foo = TEST_SHARE_FOO;
test_shared_data->bar = TEST_SHARE_BAR;
- thrdarg.numthrds = odp_cpu_count();
+ thrdarg.numthrds = odp_cpumask_default_worker(&unused, 0);
if (thrdarg.numthrds > MAX_WORKERS)
thrdarg.numthrds = MAX_WORKERS;
diff --git a/test/validation/timer/timer.c b/test/validation/timer/timer.c
index 7b76dbfde..aad11aaaa 100644
--- a/test/validation/timer/timer.c
+++ b/test/validation/timer/timer.c
@@ -14,7 +14,8 @@
#endif
#include <time.h>
-#include <odp_api.h>
+#include <odp.h>
+#include <odp/helper/linux.h>
#include "odp_cunit_common.h"
#include "test_debug.h"
#include "timer.h"
@@ -41,12 +42,6 @@ static odp_atomic_u32_t ndelivtoolate;
* caches may make this number lower than the capacity of the pool */
static odp_atomic_u32_t timers_allocated;
-/** @private min() function */
-static int min(int a, int b)
-{
- return a < b ? a : b;
-}
-
/* @private Timer helper structure */
struct test_timer {
odp_timer_t tim; /* Timer handle */
@@ -457,10 +452,17 @@ void timer_test_odp_timer_all(void)
int rc;
odp_pool_param_t params;
odp_timer_pool_param_t tparam;
+ odp_cpumask_t unused;
+
/* Reserve at least one core for running other processes so the timer
* test hopefully can run undisturbed and thus get better timing
* results. */
- int num_workers = min(odp_cpu_count() - 1, MAX_WORKERS);
+ int num_workers = odp_cpumask_default_worker(&unused, 0);
+
+ /* force to max CPU count */
+ if (num_workers > MAX_WORKERS)
+ num_workers = MAX_WORKERS;
+
/* On a single-CPU machine run at least one thread */
if (num_workers < 1)
num_workers = 1;