diff mbox series

[RFC,03/15] eventdev: move eventdevs globals to hugepage mem

Message ID 20210823194020.1229-3-pbhagavatula@marvell.com (mailing list archive)
State Changes Requested
Delegated to: Jerin Jacob
Headers show
Series [RFC,01/15] eventdev: make driver interface as internal | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Pavan Nikhilesh Bhagavatula Aug. 23, 2021, 7:40 p.m. UTC
From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Move the global struct eventdevs to hugepage memory, allocate
memory on the first pmd allocate request for both primary and
secondary process.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 lib/eventdev/rte_eventdev.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/lib/eventdev/rte_eventdev.c b/lib/eventdev/rte_eventdev.c
index 594dd5e759..21c5c55086 100644
--- a/lib/eventdev/rte_eventdev.c
+++ b/lib/eventdev/rte_eventdev.c
@@ -38,9 +38,7 @@ 
 #include "eventdev_pmd.h"
 #include "rte_eventdev_trace.h"
 
-static struct rte_eventdev rte_event_devices[RTE_EVENT_MAX_DEVS];
-
-struct rte_eventdev *rte_eventdevs = rte_event_devices;
+struct rte_eventdev *rte_eventdevs;
 
 static struct rte_eventdev_global eventdev_globals = {
 	.nb_devs		= 0
@@ -64,13 +62,13 @@  rte_event_dev_get_dev_id(const char *name)
 		return -EINVAL;
 
 	for (i = 0; i < eventdev_globals.nb_devs; i++) {
-		cmp = (strncmp(rte_event_devices[i].data->name, name,
-				RTE_EVENTDEV_NAME_MAX_LEN) == 0) ||
-			(rte_event_devices[i].dev ? (strncmp(
-				rte_event_devices[i].dev->driver->name, name,
-					 RTE_EVENTDEV_NAME_MAX_LEN) == 0) : 0);
-		if (cmp && (rte_event_devices[i].attached ==
-					RTE_EVENTDEV_ATTACHED))
+		cmp = (strncmp(rte_eventdevs[i].data->name, name,
+			       RTE_EVENTDEV_NAME_MAX_LEN) == 0) ||
+		      (rte_eventdevs[i].dev ?
+				    (strncmp(rte_eventdevs[i].dev->driver->name,
+					name, RTE_EVENTDEV_NAME_MAX_LEN) == 0) :
+				    0);
+		if (cmp && (rte_eventdevs[i].attached == RTE_EVENTDEV_ATTACHED))
 			return i;
 	}
 	return -ENODEV;
@@ -1469,6 +1467,18 @@  rte_event_pmd_allocate(const char *name, int socket_id)
 	struct rte_eventdev *eventdev;
 	uint8_t dev_id;
 
+	if (rte_eventdevs == NULL) {
+		rte_eventdevs = rte_zmalloc("Eventdev",
+					    sizeof(struct rte_eventdev) *
+						    RTE_EVENT_MAX_DEVS,
+					    RTE_CACHE_LINE_SIZE);
+		if (rte_eventdevs == NULL) {
+			RTE_EDEV_LOG_ERR(
+				"Unable to allocate memory for event devices");
+			return NULL;
+		}
+	}
+
 	if (rte_event_pmd_get_named_dev(name) != NULL) {
 		RTE_EDEV_LOG_ERR("Event device with name %s already "
 				"allocated!", name);