From: Erik Carrillo <erik.g.carri...@intel.com> This commit adds support for timers being created from non-EAL threads; it maps timers from all such threads to lcore id RTE_MAX_LCORE, and puts them all in a corresponding skiplist.
Signed-off-by: Erik Gabriel Carrillo <erik.g.carri...@intel.com> --- v3: * Rebased patch on reworked parent commit v2: * Address checkpatch warnings lib/librte_timer/rte_timer.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c index 1f4141e..c489c5f 100644 --- a/lib/librte_timer/rte_timer.c +++ b/lib/librte_timer/rte_timer.c @@ -66,8 +66,8 @@ struct skiplist { } __rte_cache_aligned; struct priv_timer { - /** one pending list per enabled lcore */ - struct skiplist pending_lists[RTE_MAX_LCORE]; + /** one pending list per lcore, plus one for non-EAL threads */ + struct skiplist pending_lists[RTE_MAX_LCORE + 1]; bool multi_pendlists; /** per-core variable that true if a timer was updated on this @@ -88,7 +88,7 @@ struct priv_timer { static struct priv_timer priv_timer[RTE_MAX_LCORE]; /** cache of IDs of enabled lcores */ -static unsigned int enabled_lcores[RTE_MAX_LCORE]; +static unsigned int enabled_lcores[RTE_MAX_LCORE + 1]; static int n_enabled_lcores; /* when debug is enabled, store some statistics */ @@ -114,12 +114,18 @@ rte_timer_subsystem_init(void) RTE_LCORE_FOREACH(lcore_id) enabled_lcores[n_enabled_lcores++] = lcore_id; + /* To handle timers coming from non-EAL threads */ + enabled_lcores[n_enabled_lcores++] = RTE_MAX_LCORE; + /* since priv_timer is static, it's zeroed by default, so only init some * fields. */ for (i = 0; i < n_enabled_lcores; i++) { lcore_id = enabled_lcores[i]; + /* Don't use this value to index the priv_timer array */ + if (lcore_id == RTE_MAX_LCORE) + continue; priv_tim = &priv_timer[lcore_id]; priv_tim->prev_lcore = lcore_id; @@ -343,7 +349,9 @@ timer_add(struct rte_timer *tim, unsigned int tim_lcore, int local_is_locked, struct priv_timer *priv_tim = &priv_timer[tim_lcore]; if (priv_tim->multi_pendlists) - *pending_lists_idx = lcore_id; + /* Check if timer being installed from non-EAL thread */ + *pending_lists_idx = (lcore_id == LCORE_ID_ANY) ? + RTE_MAX_LCORE : lcore_id; else *pending_lists_idx = SINGLE_LIST_IDX; -- 2.6.4