From patchwork Fri Jan 15 09:14:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 59848 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp414248lbb; Fri, 15 Jan 2016 01:14:22 -0800 (PST) X-Received: by 10.140.221.70 with SMTP id r67mr12839005qhb.84.1452849262074; Fri, 15 Jan 2016 01:14:22 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 192si12336229qhg.20.2016.01.15.01.14.21; Fri, 15 Jan 2016 01:14:21 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 64BB3618C8; Fri, 15 Jan 2016 09:14:21 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=km8hg4l3; dkim-adsp=none (unprotected policy); dkim-atps=neutral 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.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, 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 901CD616B9; Fri, 15 Jan 2016 09:14:17 +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 6992A616B9; Fri, 15 Jan 2016 09:14:15 +0000 (UTC) Received: from mail-lf0-f45.google.com (mail-lf0-f45.google.com [209.85.215.45]) by lists.linaro.org (Postfix) with ESMTPS id 5C7FD60762 for ; Fri, 15 Jan 2016 09:14:14 +0000 (UTC) Received: by mail-lf0-f45.google.com with SMTP id m198so131477189lfm.0 for ; Fri, 15 Jan 2016 01:14:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=1ts2uCljJtqgP+NtOwH5MPdlJNocnx+GG0l4Wvw5ej8=; b=km8hg4l38cdz3USM7rcxUGGE/1CJt+ZWiGi5c7IcqWQrp1DQ5Y0TPbklXrvuQWvt/1 wjw/RDzZwByHouh67cp2NnZ90DLV9gDTwfdDsiiskEJLQeJI5f5D9cwy/DXySWqJJr0e e9ggX1ez5V1Vwd97J6cwWRZGKwGDozuGnmg+Y= 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; bh=1ts2uCljJtqgP+NtOwH5MPdlJNocnx+GG0l4Wvw5ej8=; b=LiKbsY5BIsSH/SKQL5KMZoHUCn1GSHrqrkD8JU/U+7G+BSKWLaSClinRwBvHgYCyRE RXRLgXwaIy6RCvsRgxrsnlinVw3wuDGxKKeTa/a5tW3CsE/NCZHf7pqoOXS5F4ZlRhKr oKeparMqBfZhomEeAQUbeF1/3Vv63kfW3pnr5irrvRb7Pe8Ni6Pjosjg2sdFQiDp55+n 9+KjkuylwCpUv9rHOSnODGPvovpkjxIaUqz2mEDq3j5Iw2vr9OKtNFvQFEqMmsz+FABA 9QxuyqALoz2kwN5EUhrs2wA0B3Ry00zxxZz4K0bcB4Xa0k6hr7El1ZD0oFlCxOERD6pL +/rw== X-Gm-Message-State: ALoCoQnpm6oLdcKdT1RLOxWwZThIU0j8NlnimQ4hxH98bew9blCQUKLlbSODDJi2WXxGKxXxTUQKNyDESmvVwr7O496HubwMUA== X-Received: by 10.25.42.18 with SMTP id q18mr2778323lfq.151.1452849252762; Fri, 15 Jan 2016 01:14:12 -0800 (PST) Received: from localhost.localdomain (ppp91-76-173-134.pppoe.mtu-net.ru. [91.76.173.134]) by smtp.gmail.com with ESMTPSA id um4sm1258380lbb.1.2016.01.15.01.14.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Jan 2016 01:14:12 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Fri, 15 Jan 2016 12:14:06 +0300 Message-Id: <1452849247-32266-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: timers patch Subject: [lng-odp] [API-NEXT PATCHv1 1/2] validation: increase timer expiration wait time 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" Following current test logic validation test should correctly wait for all scheduled timer expirations. Setting that time to 1ms is not correct due to code above schedules timer to 1.1ms and context switch in linux takes 10ms. Problem that odp_timer_pool_destroy() does not disarm all trigered timers before freeing pool shared memory still exist. That should be covered with separate test case. Signed-off-by: Maxim Uvarov --- test/validation/timer/timer.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/test/validation/timer/timer.c b/test/validation/timer/timer.c index dda5e4c..db0a5ca 100644 --- a/test/validation/timer/timer.c +++ b/test/validation/timer/timer.c @@ -266,6 +266,23 @@ static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick) } } +/* Delay to ensure timeouts for expired timers can be + * received. + * Delay time = (max timer expiration time) + + * (timer handler execution time) + + * (system overhead for thread creation and schedule + * context switches) + */ +static void _wait_for_timers_expiration(void) +{ + struct timespec ts; + + ts.tv_sec = 0; + ts.tv_nsec = 50 * ODP_TIME_MSEC_IN_NS; + if (nanosleep(&ts, NULL) < 0) + CU_FAIL_FATAL("nanosleep failed"); +} + /* @private Worker thread entrypoint which performs timer alloc/set/cancel/free * tests */ static void *worker_entrypoint(void *arg TEST_UNUSED) @@ -305,7 +322,7 @@ static void *worker_entrypoint(void *arg TEST_UNUSED) uint64_t tck = odp_timer_current_tick(tp) + 1 + odp_timer_ns_to_tick(tp, (rand_r(&seed) % RANGE_MS) - * 1000000ULL); + * ODP_TIME_MSEC_IN_NS); odp_timer_set_t rc; rc = odp_timer_set_abs(tt[i].tim, tck, &tt[i].ev); if (rc != ODP_TIMER_SUCCESS) { @@ -351,7 +368,8 @@ static void *worker_entrypoint(void *arg TEST_UNUSED) /* Timer active => reset */ nreset++; uint64_t tck = 1 + odp_timer_ns_to_tick(tp, - (rand_r(&seed) % RANGE_MS) * 1000000ULL); + (rand_r(&seed) % RANGE_MS) * + ODP_TIME_MSEC_IN_NS); odp_timer_set_t rc; uint64_t cur_tick; /* Loop until we manage to read cur_tick and set a @@ -372,11 +390,8 @@ static void *worker_entrypoint(void *arg TEST_UNUSED) tt[i].tick = cur_tick + tck; } } - struct timespec ts; - ts.tv_sec = 0; - ts.tv_nsec = 1000000; /* 1ms */ - if (nanosleep(&ts, NULL) < 0) - CU_FAIL_FATAL("nanosleep failed"); + + _wait_for_timers_expiration(); } /* Cancel and free all timers */ @@ -401,13 +416,8 @@ static void *worker_entrypoint(void *arg TEST_UNUSED) LOG_DBG("Thread %u: %" PRIu32 " stale timeout(s) after odp_timer_free()\n", thr, nstale); - /* Delay some more to ensure timeouts for expired timers can be - * received */ - struct timespec ts; - ts.tv_sec = 0; - ts.tv_nsec = 1000000; /* 1ms */ - if (nanosleep(&ts, NULL) < 0) - CU_FAIL_FATAL("nanosleep failed"); + _wait_for_timers_expiration(); + while (nstale != 0) { odp_event_t ev = odp_queue_deq(queue); if (ev != ODP_EVENT_INVALID) {