DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] timer: fix break list when timer_cb reset running timer
@ 2016-07-17 18:08 Hiroyuki Mikita
  2016-07-20 20:17 ` Sanford, Robert
  2016-07-22 22:14 ` Sanford, Robert
  0 siblings, 2 replies; 11+ messages in thread
From: Hiroyuki Mikita @ 2016-07-17 18:08 UTC (permalink / raw)
  To: rsanford; +Cc: dev

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.

Signed-off-by: Hiroyuki Mikita <h.mikita89@gmail.com>
---
 lib/librte_timer/rte_timer.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c
index 3dcdab5..00e80c9 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 */
@@ -580,6 +586,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);
@@ -610,6 +617,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 */
-- 
2.7.4

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-07-25 15:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-17 18:08 [dpdk-dev] [PATCH] timer: fix break list when timer_cb reset running timer Hiroyuki Mikita
2016-07-20 20:17 ` Sanford, Robert
2016-07-21 10:34   ` Hiroyuki Mikita
2016-07-22 22:14 ` Sanford, Robert
2016-07-23  8:49   ` Thomas Monjalon
2016-07-25 12:29     ` Sanford, Robert
2016-07-25 14:21       ` Hiroyuki Mikita
2016-07-25 14:43         ` Thomas Monjalon
2016-07-25 15:14           ` Hiroyuki Mikita
2016-07-25 15:21             ` Thomas Monjalon
2016-07-25 15:53   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).