From: Vadim Suraev <vadim.suraev@gmail.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 2/2] timer bug fix
Date: Fri, 16 May 2014 13:15:54 +0300 [thread overview]
Message-ID: <1400235354-14810-3-git-send-email-vadim.suraev@gmail.com> (raw)
In-Reply-To: <1400235354-14810-1-git-send-email-vadim.suraev@gmail.com>
Description: while running a periodic timer's callback, if another
timer is manipulated, the updated flag is raised
preventing the periodic timer to reload.
Fix: move
updated flag from priv_timer to rte_timer stucture (one
per core)
Signed-off-by: Vadim Suraev <vadim.suraev@gmail.com>
---
lib/librte_timer/rte_timer.c | 17 ++++++++---------
lib/librte_timer/rte_timer.h | 7 ++++++-
2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c
index f98e904..0cc5fa9 100755
--- a/lib/librte_timer/rte_timer.c
+++ b/lib/librte_timer/rte_timer.c
@@ -58,11 +58,6 @@ LIST_HEAD(rte_timer_list, rte_timer);
struct priv_timer {
struct rte_timer pending_head; /**< dummy timer instance to head up list */
rte_spinlock_t list_lock; /**< lock to protect list access */
-
- /** per-core variable that true if a timer was updated on this
- * core since last reset of the variable */
- int updated;
-
/** track the current depth of the skiplist */
unsigned curr_skiplist_depth;
@@ -107,10 +102,14 @@ void
rte_timer_init(struct rte_timer *tim)
{
union rte_timer_status status;
+ unsigned lcore_id;
status.state = RTE_TIMER_STOP;
status.owner = RTE_TIMER_NO_OWNER;
tim->status.u32 = status.u32;
+ for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id ++) {
+ tim->updated[lcore_id] = 0;
+ }
}
/*
@@ -378,7 +377,7 @@ __rte_timer_reset(struct rte_timer *tim, uint64_t expire,
return -1;
__TIMER_STAT_ADD(reset, 1);
- priv_timer[lcore_id].updated = 1;
+ tim->updated[lcore_id] = 1;
/* remove it from list */
if (prev_status.state == RTE_TIMER_PENDING) {
@@ -453,7 +452,7 @@ rte_timer_stop(struct rte_timer *tim)
return -1;
__TIMER_STAT_ADD(stop, 1);
- priv_timer[lcore_id].updated = 1;
+ tim->updated[lcore_id] = 1;
/* remove it from list */
if (prev_status.state == RTE_TIMER_PENDING) {
@@ -541,7 +540,7 @@ void rte_timer_manage(void)
rte_spinlock_unlock(&priv_timer[lcore_id].list_lock);
- priv_timer[lcore_id].updated = 0;
+ tim->updated[lcore_id] = 0;
/* execute callback function with list unlocked */
tim->f(tim, tim->arg);
@@ -550,7 +549,7 @@ void rte_timer_manage(void)
/* the timer was stopped or reloaded by the callback
* function, we have nothing to do here */
- if (priv_timer[lcore_id].updated == 1)
+ if (tim->updated[lcore_id] == 1)
continue;
if (tim->period == 0) {
diff --git a/lib/librte_timer/rte_timer.h b/lib/librte_timer/rte_timer.h
index c5f936b..235dfd6 100755
--- a/lib/librte_timer/rte_timer.h
+++ b/lib/librte_timer/rte_timer.h
@@ -129,6 +129,10 @@ struct rte_timer
uint64_t period; /**< Period of timer (0 if not periodic). */
rte_timer_cb_t *f; /**< Callback function. */
void *arg; /**< Argument to callback function. */
+ /** per-core variable that true if a timer was updated on this
+ * core since last reset of the variable */
+ int updated[RTE_MAX_LCORE];
+
};
@@ -142,7 +146,8 @@ struct rte_timer
{{RTE_TIMER_STOP, RTE_TIMER_NO_OWNER}}, \
0, \
NULL, \
- NULL, \
+ NULL, \
+ {0}, \
}
#else
/**
--
1.7.9.5
next prev parent reply other threads:[~2014-05-15 22:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-16 10:15 [dpdk-dev] [PATCH 0/2] Vadim Suraev
2014-05-16 10:15 ` [dpdk-dev] [PATCH 1/2] timer bug fix Vadim Suraev
2014-05-16 10:15 ` Vadim Suraev [this message]
2014-05-21 14:31 ` [dpdk-dev] [PATCH 2/2] " Olivier MATZ
2014-05-23 19:43 [dpdk-dev] [PATCH 0/2] timer bugs fixes Vadim Suraev
2014-05-23 19:43 ` [dpdk-dev] [PATCH 2/2] timer bug fix Vadim Suraev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1400235354-14810-3-git-send-email-vadim.suraev@gmail.com \
--to=vadim.suraev@gmail.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).