summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroyuki Mikita <h.mikita89@gmail.com>2016-07-18 03:08:00 +0900
committerThomas Monjalon <thomas.monjalon@6wind.com>2016-07-25 17:55:12 +0200
commit20d159f2054383c46529e301aac723a823c670cb (patch)
tree096f5d6e4739135d500ab77d79617099dcecdb06
parenta829d41f9dd286c70e1bef26aca666473fde74fb (diff)
downloaddpdk-20d159f2054383c46529e301aac723a823c670cb.zip
dpdk-20d159f2054383c46529e301aac723a823c670cb.tar.gz
dpdk-20d159f2054383c46529e301aac723a823c670cb.tar.xz
timer: fix corruption with reset
When timer_cb resets another running timer on the same lcore, the list of expired timers is chained to the pending-list. This commit prevents a running timer from being reset by not its own timer_cb. Fixes: a4b7a5a45cf5 ("timer: fix race condition") Signed-off-by: Hiroyuki Mikita <h.mikita89@gmail.com> Acked-by: Robert Sanford <rsanford@akamai.com>
-rw-r--r--lib/librte_timer/rte_timer.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c
index 3f21f2d..43da836 100644
--- a/lib/librte_timer/rte_timer.c
+++ b/lib/librte_timer/rte_timer.c
@@ -69,6 +69,9 @@ struct priv_timer {
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;
@@ -135,9 +138,12 @@ timer_set_config_state(struct rte_timer *tim,
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 */
@@ -581,6 +587,7 @@ void rte_timer_manage(void)
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);
@@ -611,6 +618,7 @@ void rte_timer_manage(void)
rte_spinlock_unlock(&priv_timer[lcore_id].list_lock);
}
}
+ priv_timer[lcore_id].running_tim = NULL;
}
/* dump statistics about timers */