DPDK patches and discussions
 help / color / mirror / Atom feed
From: Gabriel Carrillo <erik.g.carrillo@intel.com>
To: rsanford@akamai.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 2/3] timer: handle timers installed from non-EAL threads
Date: Wed, 23 Aug 2017 09:47:23 -0500	[thread overview]
Message-ID: <1503499644-29432-3-git-send-email-erik.g.carrillo@intel.com> (raw)
In-Reply-To: <1503499644-29432-1-git-send-email-erik.g.carrillo@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: Gabriel Carrillo <erik.g.carrillo@intel.com>
---
 lib/librte_timer/rte_timer.c | 48 ++++++++++++++++++++++++++++++--------------
 1 file changed, 33 insertions(+), 15 deletions(-)

diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c
index 2db74c1..a493874 100644
--- a/lib/librte_timer/rte_timer.c
+++ b/lib/librte_timer/rte_timer.c
@@ -64,8 +64,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];
 
 	/** per-core variable that true if a timer was updated on this
 	 *  core since last reset of the variable */
@@ -85,7 +85,7 @@ struct priv_timer {
 static struct priv_timer priv_timer[RTE_MAX_LCORE];
 
 /** cache of IDs of enabled lcores */
-static unsigned enabled_lcores[RTE_MAX_LCORE];
+static unsigned enabled_lcores[RTE_MAX_LCORE + 1];
 static int n_enabled_lcores;
 
 /* when debug is enabled, store some statistics */
@@ -103,23 +103,33 @@ static int n_enabled_lcores;
 void
 rte_timer_subsystem_init(void)
 {
-	unsigned lcore_id1, lcore_id2;
+	unsigned target_lcore, installer_lcore;
 	struct skiplist *list;
+	struct priv_timer *priv_tim;
 	int i, j;
 
-	RTE_LCORE_FOREACH(lcore_id1)
-		enabled_lcores[n_enabled_lcores++] = lcore_id1;
+	RTE_LCORE_FOREACH(target_lcore)
+		enabled_lcores[n_enabled_lcores++] = target_lcore;
+
+	/* 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, lcore_id1 = enabled_lcores[i]; i < n_enabled_lcores;
-	     lcore_id1 = enabled_lcores[++i]) {
-		priv_timer[lcore_id1].prev_lcore = lcore_id1;
+	for (i = 0, target_lcore = enabled_lcores[i]; i < n_enabled_lcores;
+	     target_lcore = enabled_lcores[++i]) {
+		/* Don't use this value to index the priv_timer array */
+		if (target_lcore == RTE_MAX_LCORE)
+			continue;
 
-		for (j = 0, lcore_id2 = enabled_lcores[j]; j < n_enabled_lcores;
-		     lcore_id2 = enabled_lcores[++j]) {
-			list = &priv_timer[lcore_id1].pending_lists[lcore_id2];
+		priv_tim = &priv_timer[target_lcore];
+		priv_tim->prev_lcore = target_lcore;
+
+		for (j = 0, installer_lcore = enabled_lcores[j];
+		     j < n_enabled_lcores;
+		     installer_lcore = enabled_lcores[++j]) {
+			list = &priv_tim->pending_lists[installer_lcore];
 			rte_spinlock_init(&list->lock);
 		}
 	}
@@ -300,10 +310,16 @@ timer_get_prev_entries_for_node(struct rte_timer *tim, struct skiplist *list,
 static void
 timer_add(struct rte_timer *tim, unsigned tim_lcore, int local_is_locked)
 {
-	unsigned lcore_id = rte_lcore_id();
+	unsigned installer_lcore, lcore_id = rte_lcore_id();
 	unsigned lvl;
 	struct rte_timer *prev[MAX_SKIPLIST_DEPTH+1];
-	struct skiplist *list = &priv_timer[tim_lcore].pending_lists[lcore_id];
+	struct skiplist *list;
+
+	/* Check if timer being installed from non-EAL thread */
+	installer_lcore = (lcore_id == LCORE_ID_ANY) ? RTE_MAX_LCORE :
+		lcore_id;
+
+	list = &priv_timer[tim_lcore].pending_lists[installer_lcore];
 
 	/* if timer needs to be scheduled on another core, we need to
 	 * lock the list; if it is on local core, we need to lock if
@@ -439,7 +455,9 @@ __rte_timer_reset(struct rte_timer *tim, uint64_t expire,
 	 * the state so we don't need to use cmpset() here */
 	rte_wmb();
 	status.state = RTE_TIMER_PENDING;
-	status.installer = lcore_id;
+	/* Check if installer is non-EAL thread */
+	status.installer = (lcore_id == LCORE_ID_ANY) ? RTE_MAX_LCORE :
+			   lcore_id;
 	status.owner = tim_lcore;
 	tim->status.u32 = status.u32;
 
-- 
2.6.4

  parent reply	other threads:[~2017-08-23 14:47 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-23 14:47 [dpdk-dev] [PATCH 0/3] *** timer library enhancements *** Gabriel Carrillo
2017-08-23 14:47 ` [dpdk-dev] [PATCH 1/3] timer: add per-installer pending lists for each lcore Gabriel Carrillo
2017-08-25 20:27   ` [dpdk-dev] [PATCH v2 " Gabriel Carrillo
2017-08-29 10:57     ` Ananyev, Konstantin
2017-08-29 16:13       ` Carrillo, Erik G
2017-08-29 15:11   ` [dpdk-dev] [PATCH " Stephen Hemminger
2017-08-23 14:47 ` Gabriel Carrillo [this message]
2017-08-25 20:27   ` [dpdk-dev] [PATCH v2 2/3] timer: handle timers installed from non-EAL threads Gabriel Carrillo
2017-08-23 14:47 ` [dpdk-dev] [PATCH 3/3] doc: update timer lib docs Gabriel Carrillo
2017-08-25 20:27   ` [dpdk-dev] [PATCH v2 " Gabriel Carrillo
2017-08-23 15:02 ` [dpdk-dev] [PATCH 0/3] *** timer library enhancements *** Wiles, Keith
2017-08-23 16:19   ` Carrillo, Erik G
2017-08-23 16:50     ` Wiles, Keith
2017-08-23 19:28       ` Carrillo, Erik G
2017-08-23 21:04         ` Wiles, Keith
2017-08-24 14:08           ` Carrillo, Erik G
2017-08-25 20:26 ` [dpdk-dev] [PATCH v2 " Gabriel Carrillo
2017-09-13 22:05   ` [dpdk-dev] [PATCH v3 0/3] timer library enhancement Erik Gabriel Carrillo
2017-09-13 22:05     ` [dpdk-dev] [PATCH v3 1/3] timer: add multiple pending lists option for each lcore Erik Gabriel Carrillo
2017-09-13 22:05     ` [dpdk-dev] [PATCH v3 2/3] timer: handle timers installed from non-EAL threads Erik Gabriel Carrillo
2017-09-13 22:05     ` [dpdk-dev] [PATCH v3 3/3] doc: update timer lib docs Erik Gabriel Carrillo
2017-09-18 16:19       ` Mcnamara, John
2017-09-19 17:04         ` Carrillo, Erik G
2017-09-19 17:02     ` [dpdk-dev] [PATCH v4 0/3] timer library enhancement Erik Gabriel Carrillo
2017-09-19 17:02       ` [dpdk-dev] [PATCH v4 1/3] timer: add multiple pending lists option for each lcore Erik Gabriel Carrillo
2017-09-19 17:02       ` [dpdk-dev] [PATCH v4 2/3] timer: handle timers installed from non-EAL threads Erik Gabriel Carrillo
2017-09-19 17:02       ` [dpdk-dev] [PATCH v4 3/3] doc: update timer lib docs Erik Gabriel Carrillo
2017-10-11 20:42       ` [dpdk-dev] [PATCH v4 0/3] timer library enhancement Thomas Monjalon
2018-04-04 22:42         ` Thomas Monjalon
2018-04-05 21:53           ` Carrillo, Erik G

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=1503499644-29432-3-git-send-email-erik.g.carrillo@intel.com \
    --to=erik.g.carrillo@intel.com \
    --cc=dev@dpdk.org \
    --cc=rsanford@akamai.com \
    /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).