eventdev/timer: move adapters memory to hugepage
authorPavan Nikhilesh <pbhagavatula@marvell.com>
Mon, 18 Oct 2021 23:36:06 +0000 (05:06 +0530)
committerJerin Jacob <jerinj@marvell.com>
Thu, 21 Oct 2021 08:16:00 +0000 (10:16 +0200)
Move memory used by timer adapters to hugepage.
Allocate memory on the first adapter create or lookup to address
both primary and secondary process usecases.
This will prevent TLB misses if any and aligns to memory structure
of other subsystems.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
doc/guides/rel_notes/release_21_11.rst
lib/eventdev/rte_event_timer_adapter.c

index d81c2f2..a0ad309 100644 (file)
@@ -363,6 +363,9 @@ API Changes
 
 * bbdev: Added device info related to data byte endianness processing.
 
+* eventdev: Moved memory used by timer adapters to hugepage. This will prevent
+  TLB misses if any and aligns to memory structure of other subsystems.
+
 
 ABI Changes
 -----------
index ae55407..af76b77 100644 (file)
@@ -33,7 +33,7 @@ RTE_LOG_REGISTER_SUFFIX(evtim_logtype, adapter.timer, NOTICE);
 RTE_LOG_REGISTER_SUFFIX(evtim_buffer_logtype, adapter.timer, NOTICE);
 RTE_LOG_REGISTER_SUFFIX(evtim_svc_logtype, adapter.timer.svc, NOTICE);
 
-static struct rte_event_timer_adapter adapters[RTE_EVENT_TIMER_ADAPTER_NUM_MAX];
+static struct rte_event_timer_adapter *adapters;
 
 static const struct event_timer_adapter_ops swtim_ops;
 
@@ -138,6 +138,17 @@ rte_event_timer_adapter_create_ext(
        int n, ret;
        struct rte_eventdev *dev;
 
+       if (adapters == NULL) {
+               adapters = rte_zmalloc("Eventdev",
+                                      sizeof(struct rte_event_timer_adapter) *
+                                              RTE_EVENT_TIMER_ADAPTER_NUM_MAX,
+                                      RTE_CACHE_LINE_SIZE);
+               if (adapters == NULL) {
+                       rte_errno = ENOMEM;
+                       return NULL;
+               }
+       }
+
        if (conf == NULL) {
                rte_errno = EINVAL;
                return NULL;
@@ -312,6 +323,17 @@ rte_event_timer_adapter_lookup(uint16_t adapter_id)
        int ret;
        struct rte_eventdev *dev;
 
+       if (adapters == NULL) {
+               adapters = rte_zmalloc("Eventdev",
+                                      sizeof(struct rte_event_timer_adapter) *
+                                              RTE_EVENT_TIMER_ADAPTER_NUM_MAX,
+                                      RTE_CACHE_LINE_SIZE);
+               if (adapters == NULL) {
+                       rte_errno = ENOMEM;
+                       return NULL;
+               }
+       }
+
        if (adapters[adapter_id].allocated)
                return &adapters[adapter_id]; /* Adapter is already loaded */
 
@@ -358,7 +380,7 @@ rte_event_timer_adapter_lookup(uint16_t adapter_id)
 int
 rte_event_timer_adapter_free(struct rte_event_timer_adapter *adapter)
 {
-       int ret;
+       int i, ret;
 
        ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
        FUNC_PTR_OR_ERR_RET(adapter->ops->uninit, -EINVAL);
@@ -382,6 +404,16 @@ rte_event_timer_adapter_free(struct rte_event_timer_adapter *adapter)
        adapter->data = NULL;
        adapter->allocated = 0;
 
+       ret = 0;
+       for (i = 0; i < RTE_EVENT_TIMER_ADAPTER_NUM_MAX; i++)
+               if (adapters[i].allocated)
+                       ret = adapters[i].allocated;
+
+       if (!ret) {
+               rte_free(adapters);
+               adapters = NULL;
+       }
+
        rte_eventdev_trace_timer_adapter_free(adapter);
        return 0;
 }