From patchwork Thu Mar 31 13:08:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 64779 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp148423lbc; Thu, 31 Mar 2016 06:09:41 -0700 (PDT) X-Received: by 10.140.252.197 with SMTP id x188mr17042472qhc.81.1459429780670; Thu, 31 Mar 2016 06:09:40 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id s51si7658010qge.104.2016.03.31.06.09.32; Thu, 31 Mar 2016 06:09:40 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id B7B1061A04; Thu, 31 Mar 2016 13:09:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id CD62461A0A; Thu, 31 Mar 2016 13:08:31 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 5E6B161A0B; Thu, 31 Mar 2016 13:08:24 +0000 (UTC) Received: from mail-ob0-f173.google.com (mail-ob0-f173.google.com [209.85.214.173]) by lists.linaro.org (Postfix) with ESMTPS id 73863619C8 for ; Thu, 31 Mar 2016 13:08:18 +0000 (UTC) Received: by mail-ob0-f173.google.com with SMTP id fp4so22486474obb.2 for ; Thu, 31 Mar 2016 06:08:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1pYW57VSmaJKFCwQMiBO0Qkge1xD4IRT80ncT12eyzQ=; b=ZsEY3xoy+rzWDhGKo84oP2jwKmbN4gQ0Xve2TwlyIL4nBwwbwKJxZwIgE4gJQ/6pr9 r24DxiBoTg3gwa/Aks9AyR5HWQEmw3oRIPPInoUCEAmBfT4uNepl+gQ75jjkU8GlJdVn WV0x6XoF1EtAGteTGD8eAsGjVFlEkZg2ftfT1OHZPDL8j2kr63+56tFx0U/evtRGcaiq 6zYwJGf9EtQFr6jBDtPvebI3FLQjNUWsC6gfNL9qYwy6hLkC6ExVeAQULs0Ml+oIBMMH Qt9SHZiTYEs8V9TBJe62SO3DFE2NEGdl5RRRzh/sSP0zrEnAjb/B8Dr1C+L/kBNhzLsy 27VQ== X-Gm-Message-State: AD7BkJIB95JT+aahtqd6zEi9MVxN28A5qjHdby/mlXdO5mUTPOxV+91JjoU4ZZZ12K1z5k1dnYg= X-Received: by 10.60.141.193 with SMTP id rq1mr467618oeb.19.1459429698049; Thu, 31 Mar 2016 06:08:18 -0700 (PDT) Received: from Ubuntu15.localdomain (cpe-66-68-129-43.austin.res.rr.com. [66.68.129.43]) by smtp.gmail.com with ESMTPSA id yn3sm2668627obc.27.2016.03.31.06.08.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 Mar 2016 06:08:17 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Thu, 31 Mar 2016 08:08:10 -0500 Message-Id: <1459429694-6832-2-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459429694-6832-1-git-send-email-bill.fischofer@linaro.org> References: <1459429694-6832-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv7 1/5] test: correct worker count calculation X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: "Gary S. Robertson" 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 Signed-off-by: Bill Fischofer --- test/validation/shmem/shmem.c | 3 ++- test/validation/timer/timer.c | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/test/validation/shmem/shmem.c b/test/validation/shmem/shmem.c index ba4973d..0bf38d2 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 7b76dbf..aad11aa 100644 --- a/test/validation/timer/timer.c +++ b/test/validation/timer/timer.c @@ -14,7 +14,8 @@ #endif #include -#include +#include +#include #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;