From patchwork Fri Jan 15 08:07:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 59846 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp383277lbb; Fri, 15 Jan 2016 00:08:12 -0800 (PST) X-Received: by 10.55.71.76 with SMTP id u73mr11583656qka.6.1452845291970; Fri, 15 Jan 2016 00:08:11 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id h195si12078889qhc.51.2016.01.15.00.08.11; Fri, 15 Jan 2016 00:08:11 -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 38CAB618E5; Fri, 15 Jan 2016 08:08:11 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=Ta8hNKj3; 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 38A15618C9; Fri, 15 Jan 2016 08:08:06 +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 ABF82618CB; Fri, 15 Jan 2016 08:08:04 +0000 (UTC) Received: from mail-lf0-f54.google.com (mail-lf0-f54.google.com [209.85.215.54]) by lists.linaro.org (Postfix) with ESMTPS id 92382618C8 for ; Fri, 15 Jan 2016 08:08:03 +0000 (UTC) Received: by mail-lf0-f54.google.com with SMTP id m198so130552404lfm.0 for ; Fri, 15 Jan 2016 00:08:03 -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=Ta8hNKj35v3f8UnDpdas7Z9/BKMwMxDetgb5qK9hnMYehGc3VPjVaVIGgTEjz0zOVb /DI6zYdyTr5eLsK5FNBbjkBx85l06bZyTizNg995eYIkmgMEsYdTEKXN8le1DskyfsHb s/3sV911sJVRA8IOPUzpocrEQyimUOqxMGiuM= 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=gwDHkq9ZvO4VSARDIVqTtza9NfobH4YiMajZVKv7dhRNgRPDs/sxbusrvA2YFEYp/f xk4z3xRg6kBlfxpqKTWDyGn4Ik1v/fztYTm+/hbzAtbrCBNhl3LLN1ymBUiobzTgB0EC OlD7OpXAVornAbZ2vTOpolZ3skZ7dinVyDyEhX0gzNSWl7TpO05wW8YvJyaM8YPliOQl jFXQe969oQSsPAITvpgfuNj8ay+yVEpWMAJQ4zTaUPcx2T5tNMBl8f8hYFg5DM8q37YX tgIZNR9ZLK24H/AVIkBe3xWXRPDork8fg4nWZ6lTT3sLtjYHzA8o9kyR7kwLVOOkXQo5 g5Sg== X-Gm-Message-State: ALoCoQl6oBMdgiUKjhua6Y0iDLf4betRdUC3XWV4YHzQTdlLEkR0f9MxrUZwq8hlnHvuIp1EZH8HVMzooLdXFnHhIT5d462oKg== X-Received: by 10.25.155.81 with SMTP id d78mr2335092lfe.77.1452845281554; Fri, 15 Jan 2016 00:08:01 -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 b10sm1192436lbs.37.2016.01.15.00.08.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Jan 2016 00:08:00 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Fri, 15 Jan 2016 11:07:54 +0300 Message-Id: <1452845274-11510-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 PATCHv4] 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) {