This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, master has been updated via 84d072b5c7327437cae7a13333dd35ab9777ce14 (commit) via c4571009907584a103b878ea5c90ced7a5cac283 (commit) via 5131f551d8525d3a9235b2944f0fa84546dba120 (commit) from f5e12df388352b27f09787028a0040afb28564f4 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit 84d072b5c7327437cae7a13333dd35ab9777ce14 Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Wed Feb 14 15:24:45 2018 +0000
validation: timer: fix test failure
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 dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c index 9aa6d014..1cd32cb1 100644 --- a/test/validation/api/timer/timer.c +++ b/test/validation/api/timer/timer.c @@ -274,15 +274,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 @@ -290,6 +285,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"); @@ -403,11 +401,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 */ @@ -461,7 +462,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
commit c4571009907584a103b878ea5c90ced7a5cac283 Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Tue Feb 20 16:15:11 2018 +0000
linux-gen: timer: don't mark expired timeouts as stale on odp_timer_cancel
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 dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c index adc92497..6ecddbdb 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,64 @@ 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) { + old.tmo_buf = ODP_BUFFER_INVALID; + 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) + old_buf = ODP_BUFFER_INVALID; + else + 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 +1165,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 */
commit 5131f551d8525d3a9235b2944f0fa84546dba120 Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Thu Feb 15 00:18:56 2018 +0000
validation: timer: fix "Failed to set timer" error
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. Fixes: https://bugs.linaro.org/show_bug.cgi?id=3628
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c index 60dbbdd0..9aa6d014 100644 --- a/test/validation/api/timer/timer.c +++ b/test/validation/api/timer/timer.c @@ -372,7 +372,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;
-----------------------------------------------------------------------
Summary of changes: platform/linux-generic/odp_timer.c | 76 +++++++++++++++++++++++++++++++++----- test/validation/api/timer/timer.c | 32 +++++++++------- 2 files changed, 84 insertions(+), 24 deletions(-)
hooks/post-receive