From patchwork Tue Feb 20 17:00:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 128926 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4849068ljc; Tue, 20 Feb 2018 09:00:59 -0800 (PST) X-Google-Smtp-Source: AH8x224coSpviEMLe796ox0kbna5L+qSkMdGDcFR3sBFQtKs89UE+txa5hlAS2cAqMc3AA5O4UzD X-Received: by 10.129.109.1 with SMTP id i1mr240951ywc.113.1519146059503; Tue, 20 Feb 2018 09:00:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519146059; cv=none; d=google.com; s=arc-20160816; b=Ignf47rwOApwpUR8G0RVLyp+8v4gIqr98A0wCuD5f43iqmq1W60qPhQnLwi3PZuCF/ zneIbz1lTbgHakZU4kA7t2UGa1fwS/ELuEOFAsyY/7TunPpNUTfq0Z0CdGhtq8iGmSSS mlHStWyg/50g3D/NoRgEAo4bU5MbCQsKIFvVZkWLyyvepavu/fstgccP7LOWo+0okfd1 E+doGvlhDp3KXqBg573PrB6eQ8vRFdCwZhSVl0zsiOc0AhsawWoh6oUkF/YRWqK2L8kw 45vxkQbcwi4Fu7JKq7kcpaC8dZdXEPsgN7yieGotR9Og8xPeHnDzrScnm+XzcpRM84he KrWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=kZ/MVevFTd6YWnmie9La/LP9HxCT7klpzPHZdkK9wLc=; b=eKsDfG7GS0S5Dum1J1qCnc+p30cvGcZCFUeJs7tBZPSgM3xNdTMBIPL+ZJXLyIwXZp /WqQrVngwUEask7HuZjw/+YJ6bowZbwbgg09W41VJ65SLJ4XGafzRMT/k17OuF6mHFGt 7e2CECb2ybTa0/Yomjyjl03mQpbLn30/NoWujJ6Se9mL5f1mwvlrv1hGd6SwohGZ+p2s Qqe5y3qHP38V2IHdURreQBL4JMwSzopT7OXSt8v6j14iUTUzZ5VtYcX/eBKxPKn3wPVI 553bBmj3fXEf6U+BMGxqKutY4y4nEY+eM4hW7/Qx5lL5DgZyud91hfyHNs2q7pjDoyv+ x6JA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id p22si6531535qkl.75.2018.02.20.09.00.59; Tue, 20 Feb 2018 09:00:59 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 1EB4061520; Tue, 20 Feb 2018 17:00:59 +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,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 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 B0B366150C; Tue, 20 Feb 2018 17:00:20 +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 B86DD610B9; Tue, 20 Feb 2018 17:00:13 +0000 (UTC) Received: from forward100o.mail.yandex.net (forward100o.mail.yandex.net [37.140.190.180]) by lists.linaro.org (Postfix) with ESMTPS id 787846094D for ; Tue, 20 Feb 2018 17:00:11 +0000 (UTC) Received: from mxback5g.mail.yandex.net (mxback5g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:166]) by forward100o.mail.yandex.net (Yandex) with ESMTP id 013722A244E6 for ; Tue, 20 Feb 2018 20:00:10 +0300 (MSK) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [2a02:6b8:0:801::ac]) by mxback5g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id PgJyXSlkeD-09QWgvVX; Tue, 20 Feb 2018 20:00:09 +0300 Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id j65fuiFbN5-09EaaXbT; Tue, 20 Feb 2018 20:00:09 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 20 Feb 2018 20:00:06 +0300 Message-Id: <1519146008-3368-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519146008-3368-1-git-send-email-odpbot@yandex.ru> References: <1519146008-3368-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 491 Subject: [lng-odp] [PATCH v1 1/3] validation: timer: fix "Failed to set timer" error 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov Occasionally timer test will try to set timer to a tick that has just passed. It is not an error per se, so it should be handled properly. Signed-off-by: Dmitry Eremin-Solenikov Fixes: https://bugs.linaro.org/show_bug.cgi?id=3628 --- /** Email created from pull request 491 (lumag:timer-fix-2) ** https://github.com/Linaro/odp/pull/491 ** Patch: https://github.com/Linaro/odp/pull/491.patch ** Base sha: d5419e8857b2bc61d3be17fe53f171550fee426b ** Merge commit sha: 1623e4e7c0742c5238c1b97abe1e8af93f091443 **/ test/validation/api/timer/timer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c index 7ea508aa0..c3b807aee 100644 --- a/test/validation/api/timer/timer.c +++ b/test/validation/api/timer/timer.c @@ -373,7 +373,10 @@ static int worker_entrypoint(void *arg TEST_UNUSED) odp_timer_ns_to_tick(tp, (rand_r(&seed) % RANGE_MS) * 1000000ULL); timer_rc = odp_timer_set_abs(tt[i].tim, tck, &tt[i].ev); - if (timer_rc != ODP_TIMER_SUCCESS) { + if (timer_rc == ODP_TIMER_TOOEARLY) { + LOG_ERR("Missed tick, setting timer\n"); + } else if (timer_rc != ODP_TIMER_SUCCESS) { + LOG_ERR("Failed to set timer: %d\n", timer_rc); CU_FAIL("Failed to set timer"); } else { tt[i].tick = tck; From patchwork Tue Feb 20 17:00:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 128928 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4851037ljc; Tue, 20 Feb 2018 09:02:35 -0800 (PST) X-Google-Smtp-Source: AH8x227PMBb12Yk72Fg8PjWNlkuK1aiV1uZ2ELbU3KlGHoYWPVaysX7LF47SQZRSGYDvPK7WO8hN X-Received: by 10.237.37.161 with SMTP id x30mr477726qtc.78.1519146154976; Tue, 20 Feb 2018 09:02:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519146154; cv=none; d=google.com; s=arc-20160816; b=OuCHtxDwYT5Qu9+ll3hD1cqSMVqGbO6c77uAXpsURkPSathj+nQqrsUeipbJfJhuDM W8gi4rB8EekGUzgo/YkL5BwZqlfmWKr39gz1D4zH4LHAKpHa6moZxyGDZbJSKfH8WeEX yT6xO0Ju+eo5NoraZAP7ZgxN51EChh+SiXQgLf0hYRa3BatzE0cB7C9bvWuAK1wo1H8V AySl2Wsr/Z8DIIoBcIyAp4Dy0cUFhK4ASNxa37cQu71zbdnkUp7/LN0GTAp7j+OMGcIW fbjovJSpj4HJ16+GAfcFNHs6KvfImORQeqso4OCdxmEiILeXsT2DDte4ISbgaJPin6gh vzJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=LW+5e4L8+J7JAXvqjrdJmtKtIUS9icys8DSJLZ3aEsI=; b=iFfuH0Kr7E5majsjpgQz+GxefTLpUjVsCn/I/483LnWLhDBHjO3Ao9X9L7iLhp41R8 zXLTWZBpZwiwirXSzXYVEesYm9LEDFNPj5W2P7z+Dg1JiyHW8pNrZEq3hvBvMKlIg38t Ohx9jw/Wfe5R9hVkzcAFRWk32snddPId2h5wYLEWOwE9kZNgMTDUSZmsVnyF91BB/5dE GL9lE8T0N6xxNr0g992ftq1mlJ9AJXKZfvVg5BgxZT/boE7FUa6tW1IKNmCQtBf/yQi6 mWIjaAyLDcJy/Pb9Y8rDXv0LU6JJdbyYv84ht/SRv5Rl4A3zfBbsjVdD+lB0+fcOaM0o gh1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id m28si203231qta.91.2018.02.20.09.02.34; Tue, 20 Feb 2018 09:02:34 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id A1D9E61737; Tue, 20 Feb 2018 17:02:34 +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,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL 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 9BA08609ED; Tue, 20 Feb 2018 17:00:33 +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 CF30E6150C; Tue, 20 Feb 2018 17:00:19 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id F19B7609A8 for ; Tue, 20 Feb 2018 17:00:12 +0000 (UTC) Received: from mxback12g.mail.yandex.net (mxback12g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:91]) by forward102j.mail.yandex.net (Yandex) with ESMTP id 868B056048D2 for ; Tue, 20 Feb 2018 20:00:10 +0300 (MSK) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [2a02:6b8:0:801::ac]) by mxback12g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id nnQVUPsi6v-0AuCZVkT; Tue, 20 Feb 2018 20:00:10 +0300 Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id j65fuiFbN5-0AE44VeW; Tue, 20 Feb 2018 20:00:10 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 20 Feb 2018 20:00:07 +0300 Message-Id: <1519146008-3368-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519146008-3368-1-git-send-email-odpbot@yandex.ru> References: <1519146008-3368-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 491 Subject: [lng-odp] [PATCH v1 2/3] linux-gen: timer: don't mark expired timeouts as stale on odp_timer_cancel 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov Don't replace expiry tick for fired timeouts during odp_timer_cancel(), so that corresponding timeouts won't be reported as stale even though they are fresh. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 491 (lumag:timer-fix-2) ** https://github.com/Linaro/odp/pull/491 ** Patch: https://github.com/Linaro/odp/pull/491.patch ** Base sha: d5419e8857b2bc61d3be17fe53f171550fee426b ** Merge commit sha: 1623e4e7c0742c5238c1b97abe1e8af93f091443 **/ platform/linux-generic/odp_timer.c | 72 ++++++++++++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 10 deletions(-) diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c index bdb25c60e..0928acdeb 100644 --- a/platform/linux-generic/odp_timer.c +++ b/platform/linux-generic/odp_timer.c @@ -375,9 +375,8 @@ static inline odp_timer_t timer_alloc(timer_pool_t *tp, return hdl; } -static odp_buffer_t timer_cancel(timer_pool_t *tp, - uint32_t idx, - uint64_t new_state); +static odp_buffer_t timer_set_unused(timer_pool_t *tp, + uint32_t idx); static inline odp_buffer_t timer_free(timer_pool_t *tp, uint32_t idx) { @@ -385,7 +384,7 @@ static inline odp_buffer_t timer_free(timer_pool_t *tp, uint32_t idx) /* Free the timer by setting timer state to unused and * grab any timeout buffer */ - odp_buffer_t old_buf = timer_cancel(tp, idx, TMO_UNUSED); + odp_buffer_t old_buf = timer_set_unused(tp, idx); /* Destroy timer */ timer_fini(tim, &tp->tick_buf[idx]); @@ -540,9 +539,8 @@ static bool timer_reset(uint32_t idx, return success; } -static odp_buffer_t timer_cancel(timer_pool_t *tp, - uint32_t idx, - uint64_t new_state) +static odp_buffer_t timer_set_unused(timer_pool_t *tp, + uint32_t idx) { tick_buf_t *tb = &tp->tick_buf[idx]; odp_buffer_t old_buf; @@ -550,7 +548,7 @@ static odp_buffer_t timer_cancel(timer_pool_t *tp, #ifdef ODP_ATOMIC_U128 tick_buf_t new, old; /* Update the timer state (e.g. cancel the current timeout) */ - new.exp_tck.v = new_state; + new.exp_tck.v = TMO_UNUSED; /* Swap out the old buffer */ new.tmo_buf = ODP_BUFFER_INVALID; TB_SET_PAD(new); @@ -566,7 +564,7 @@ static odp_buffer_t timer_cancel(timer_pool_t *tp, odp_cpu_pause(); /* Update the timer state (e.g. cancel the current timeout) */ - tb->exp_tck.v = new_state; + tb->exp_tck.v = TMO_UNUSED; /* Swap out the old buffer */ old_buf = tb->tmo_buf; @@ -579,6 +577,60 @@ static odp_buffer_t timer_cancel(timer_pool_t *tp, return old_buf; } +static odp_buffer_t timer_cancel(timer_pool_t *tp, + uint32_t idx) +{ + tick_buf_t *tb = &tp->tick_buf[idx]; + odp_buffer_t old_buf; + +#ifdef ODP_ATOMIC_U128 + tick_buf_t new, old; + + do { + /* Relaxed and non-atomic read of current values */ + old.exp_tck.v = tb->exp_tck.v; + old.tmo_buf = tb->tmo_buf; + TB_SET_PAD(old); + + /* Check if it is not expired already */ + if (!(old.exp_tck.v & TMO_INACTIVE)) + break; + + /* Set up new values */ + new.exp_tck.v = TMO_INACTIVE; + new.tmo_buf = ODP_BUFFER_INVALID; + TB_SET_PAD(new); + /* Atomic CAS will fail if we experienced torn reads, + * retry update sequence until CAS succeeds */ + } while (!_odp_atomic_u128_cmp_xchg_mm( + (_odp_atomic_u128_t *)tb, + (_uint128_t *)&old, + (_uint128_t *)&new, + _ODP_MEMMODEL_RLS, + _ODP_MEMMODEL_RLX)); + old_buf = old.tmo_buf; +#else + /* Take a related lock */ + while (_odp_atomic_flag_tas(IDX2LOCK(idx))) + /* While lock is taken, spin using relaxed loads */ + while (_odp_atomic_flag_load(IDX2LOCK(idx))) + odp_cpu_pause(); + + /* Swap in new buffer, save any old buffer */ + old_buf = tb->tmo_buf; + tb->tmo_buf = ODP_BUFFER_INVALID; + + /* Write the new expiration tick if it not cancelled */ + if (!(tb->exp_tck.v & TMO_INACTIVE)) + tb->exp_tck.v = TMO_INACTIVE; + + /* Release the lock */ + _odp_atomic_flag_clear(IDX2LOCK(idx)); +#endif + /* Return the old buffer */ + return old_buf; +} + static unsigned timer_expire(timer_pool_t *tp, uint32_t idx, uint64_t tick) { _odp_timer_t *tim = &tp->timers[idx]; @@ -1109,7 +1161,7 @@ int odp_timer_cancel(odp_timer_t hdl, odp_event_t *tmo_ev) timer_pool_t *tp = handle_to_tp(hdl); uint32_t idx = handle_to_idx(hdl, tp); /* Set the expiration tick of the timer to TMO_INACTIVE */ - odp_buffer_t old_buf = timer_cancel(tp, idx, TMO_INACTIVE); + odp_buffer_t old_buf = timer_cancel(tp, idx); if (old_buf != ODP_BUFFER_INVALID) { *tmo_ev = odp_buffer_to_event(old_buf); return 0; /* Active timer cancelled, timeout returned */ From patchwork Tue Feb 20 17:00:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 128927 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4849962ljc; Tue, 20 Feb 2018 09:01:41 -0800 (PST) X-Google-Smtp-Source: AH8x2259HgHyWx84RWAm1o8Cy0sof0fkyhqInhvuCkle+s0+Zo7DYofZ75k9ZvwkZhLb08ReeZrk X-Received: by 10.200.56.249 with SMTP id g54mr397782qtc.245.1519146101040; Tue, 20 Feb 2018 09:01:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519146101; cv=none; d=google.com; s=arc-20160816; b=01dh7H9y+HFVK1tVfnqCKmwZu7RRLROX6P1QZq/n3goHQYd69RoyRBU2QZzw6DQYAk TRX+STZlxnXQYRa1VzfrqlbYEUsGfDFs2334oko4Hxx2LMTVsHbSt5XLSsiAWCrvu77Q Nzn2cz7P4zNu9Kb/qh5Uj4qWPpZ4CEN9USaherXLY6oebY/QBoo2hOedc1PR7Jq+G7lP qKtSq8ZhfZiYDidsHvqamXPZ9zVty/NGcJ3kEEBcDoMqlKlh1PQHrntADFS9zlspA7cA XjjCbuoN4p9B0Jn5LbeK5KCGJ7jVC9rGq36Yn4ax48w+MwSeR8nWQik3RiLwiGM4cxwo L/5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=UTqjr2a0JAj49feFevIqkhJ7+Nz/r78QlNEpALMOoUM=; b=G6YpdhvnFB+8XVkUWxTAxUzeYkNrkcG47K5hFO0N/6tyotmHzd4dJZqOhCsT5rd35M j2LGG260MrZwor8EkgPu2HBq9WoU4rx8Nil424eFSKt5iBiolfikCONmjHjX+UjilTxt 9Wm+e0WQiRCG1pvNQENptXVY4f0JSE3+AnIdtlgJjxL3V3BJ9SrOAMv3ugl6c4RJNykr Gx+2l4EjXvBSBYv42wXMHmMmJ4SwGgjvqS/Dx+ThiduB5c3Ymf4lW0FTyvy4AGjZDL2i ghVIKBew5rtb5sfNlZsphqy5qv9fbv4855KmqKHi3iVV7sYyX4deuEgAbla/9CFjFIGR aBRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id g38si4936677qtf.135.2018.02.20.09.01.40; Tue, 20 Feb 2018 09:01:41 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id A82EC616FC; Tue, 20 Feb 2018 17:01:40 +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,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL 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 2C0916074F; Tue, 20 Feb 2018 17:00:30 +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 981C9610B9; Tue, 20 Feb 2018 17:00:17 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id EA5B160940 for ; Tue, 20 Feb 2018 17:00:12 +0000 (UTC) Received: from mxback7g.mail.yandex.net (mxback7g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:168]) by forward102j.mail.yandex.net (Yandex) with ESMTP id 1433E56048D4 for ; Tue, 20 Feb 2018 20:00:11 +0300 (MSK) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [2a02:6b8:0:801::ac]) by mxback7g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Adve7XD6Ua-0BduOqKF; Tue, 20 Feb 2018 20:00:11 +0300 Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id j65fuiFbN5-0AECoEvd; Tue, 20 Feb 2018 20:00:10 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 20 Feb 2018 20:00:08 +0300 Message-Id: <1519146008-3368-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519146008-3368-1-git-send-email-odpbot@yandex.ru> References: <1519146008-3368-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 491 Subject: [lng-odp] [PATCH v1 3/3] validation: timer: fix test failure 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov timer_main test was regularly failing due to worker code receiving timeout events for cancelled timers in invalid state. However after fixing implementation bug, several other asserts started to fail, as they dependent on incorrect behaviour, like non-freshness of cancelled events. Fixes: https://bugs.linaro.org/show_bug.cgi?id=3517 Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 491 (lumag:timer-fix-2) ** https://github.com/Linaro/odp/pull/491 ** Patch: https://github.com/Linaro/odp/pull/491.patch ** Base sha: d5419e8857b2bc61d3be17fe53f171550fee426b ** Merge commit sha: 1623e4e7c0742c5238c1b97abe1e8af93f091443 **/ test/validation/api/timer/timer.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c index c3b807aee..183c61e8d 100644 --- a/test/validation/api/timer/timer.c +++ b/test/validation/api/timer/timer.c @@ -275,15 +275,10 @@ static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick) CU_FAIL("odp_timeout_user_ptr() wrong user ptr"); if (ttp && ttp->tim != tim) CU_FAIL("odp_timeout_timer() wrong timer"); - if (stale) { - if (odp_timeout_fresh(tmo)) - CU_FAIL("Wrong status (fresh) for stale timeout"); - /* Stale timeout => local timer must have invalid tick */ - if (ttp && ttp->tick != TICK_INVALID) - CU_FAIL("Stale timeout for active timer"); - } else { - if (!odp_timeout_fresh(tmo)) - CU_FAIL("Wrong status (stale) for fresh timeout"); + + if (!odp_timeout_fresh(tmo)) + CU_FAIL("Wrong status (stale) for fresh timeout"); + if (!stale) { /* Fresh timeout => local timer must have matching tick */ if (ttp && ttp->tick != tick) { LOG_DBG("Wrong tick: expected %" PRIu64 @@ -291,6 +286,9 @@ static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick) ttp->tick, tick); CU_FAIL("odp_timeout_tick() wrong tick"); } + if (ttp && ttp->ev != ODP_EVENT_INVALID) + CU_FAIL("Wrong state for fresh timer (event)"); + /* Check that timeout was delivered 'timely' */ if (tick > odp_timer_current_tick(tp)) CU_FAIL("Timeout delivered early"); @@ -404,11 +402,14 @@ static int worker_entrypoint(void *arg TEST_UNUSED) (rand_r(&seed) % 2 == 0)) { /* Timer active, cancel it */ rc = odp_timer_cancel(tt[i].tim, &tt[i].ev); - if (rc != 0) + if (rc != 0) { /* Cancel failed, timer already expired */ ntoolate++; - tt[i].tick = TICK_INVALID; - ncancel++; + LOG_DBG("Failed to cancel timer, probably already expired\n"); + } else { + tt[i].tick = TICK_INVALID; + ncancel++; + } } else { if (tt[i].ev != ODP_EVENT_INVALID) /* Timer inactive => set */ @@ -462,7 +463,7 @@ static int worker_entrypoint(void *arg TEST_UNUSED) thr, ntoolate); LOG_DBG("Thread %u: %" PRIu32 " timeouts received\n", thr, nrcv); LOG_DBG("Thread %u: %" PRIu32 - " stale timeout(s) after odp_timer_free()\n", + " stale timeout(s) after odp_timer_cancel()\n", thr, nstale); /* Delay some more to ensure timeouts for expired timers can be