unsigned prev_lcore; /**< used for lcore round robin */
+ /** running timer on this lcore now */
+ struct rte_timer *running_tim;
+
#ifdef RTE_LIBRTE_TIMER_DEBUG
/** per-lcore statistics */
struct rte_timer_debug_stats stats;
while (success == 0) {
prev_status.u32 = tim->status.u32;
- /* timer is running on another core, exit */
+ /* timer is running on another core
+ * or ready to run on local core, exit
+ */
if (prev_status.state == RTE_TIMER_RUNNING &&
- prev_status.owner != (uint16_t)lcore_id)
+ (prev_status.owner != (uint16_t)lcore_id ||
+ tim != priv_timer[lcore_id].running_tim))
return -1;
/* timer is being configured on another core */
return;
cur_time = rte_get_timer_cycles();
-#ifdef RTE_ARCH_X86_64
+#ifdef RTE_ARCH_64
/* on 64-bit the value cached in the pending_head.expired will be
* updated atomically, so we can consult that for a quick check here
* outside the lock */
/* break the existing list at current time point */
timer_get_prev_entries(cur_time, lcore_id, prev);
for (i = priv_timer[lcore_id].curr_skiplist_depth -1; i >= 0; i--) {
+ if (prev[i] == &priv_timer[lcore_id].pending_head)
+ continue;
priv_timer[lcore_id].pending_head.sl_next[i] =
prev[i]->sl_next[i];
if (prev[i]->sl_next[i] == NULL)
pprev = &tim->sl_next[0];
} else {
/* another core is trying to re-config this one,
- * remove it from local expired list and put it
- * back on the priv_timer[] skip list */
+ * remove it from local expired list
+ */
*pprev = next_tim;
- timer_add(tim, lcore_id, 1);
}
}
for (tim = run_first_tim; tim != NULL; tim = next_tim) {
next_tim = tim->sl_next[0];
priv_timer[lcore_id].updated = 0;
+ priv_timer[lcore_id].running_tim = tim;
/* execute callback function with list unlocked */
tim->f(tim, tim->arg);
status.owner = (int16_t)lcore_id;
rte_wmb();
tim->status.u32 = status.u32;
- __rte_timer_reset(tim, cur_time + tim->period,
+ __rte_timer_reset(tim, tim->expire + tim->period,
tim->period, lcore_id, tim->f, tim->arg, 1);
rte_spinlock_unlock(&priv_timer[lcore_id].list_lock);
}
}
+ priv_timer[lcore_id].running_tim = NULL;
}
/* dump statistics about timers */