diff mbox series

[v5,11/14] eventdev: move timer adapters memory to hugepage

Message ID 20211018233610.5694-11-pbhagavatula@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers show
Series [v5,01/14] eventdev: make driver interface as internal | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Pavan Nikhilesh Bhagavatula Oct. 18, 2021, 11:36 p.m. UTC
From: Pavan Nikhilesh <pbhagavatula@marvell.com>

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 |  2 ++
 lib/eventdev/rte_event_timer_adapter.c | 36 ++++++++++++++++++++++++--
 2 files changed, 36 insertions(+), 2 deletions(-)

Comments

Carrillo, Erik G Oct. 20, 2021, 8:24 p.m. UTC | #1
Hi Pavan and Jerin,

> -----Original Message-----
> From: pbhagavatula@marvell.com <pbhagavatula@marvell.com>
> Sent: Monday, October 18, 2021 6:36 PM
> To: jerinj@marvell.com; Carrillo, Erik G <erik.g.carrillo@intel.com>
> Cc: dev@dpdk.org; Pavan Nikhilesh <pbhagavatula@marvell.com>
> Subject: [dpdk-dev] [PATCH v5 11/14] eventdev: move timer adapters
> memory to hugepage
> 
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> 
> 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 |  2 ++
> lib/eventdev/rte_event_timer_adapter.c | 36
> ++++++++++++++++++++++++--
>  2 files changed, 36 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/guides/rel_notes/release_21_11.rst
> b/doc/guides/rel_notes/release_21_11.rst
> index 6442c79977..9694b32002 100644
> --- a/doc/guides/rel_notes/release_21_11.rst
> +++ b/doc/guides/rel_notes/release_21_11.rst
> @@ -226,6 +226,8 @@ API Changes
>    the crypto/security operation. This field will be used to communicate
>    events such as soft expiry with IPsec in lookaside mode.
> 
> +* eventdev: Move memory used by timer adapters to hugepage. This will
> +prevent
> +  TLB misses if any and aligns to memory structure of other subsystems.
> 
>  ABI Changes
>  -----------
> diff --git a/lib/eventdev/rte_event_timer_adapter.c
> b/lib/eventdev/rte_event_timer_adapter.c
> index ae55407042..894f532ef0 100644
> --- a/lib/eventdev/rte_event_timer_adapter.c
> +++ b/lib/eventdev/rte_event_timer_adapter.c
> @@ -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 = adapter[i].allocated;
> +

I found a typo here, but it looks like this series has already been accepted, so I submitted the following patch for the issue:

http://patchwork.dpdk.org/project/dpdk/patch/20211020202021.1205135-1-erik.g.carrillo@intel.com/

Besides that, this patch and the others I was copied on look good to me.

Thanks,
Erik

> +	if (!ret) {
> +		rte_free(adapters);
> +		adapters = NULL;
> +	}
> +
>  	rte_eventdev_trace_timer_adapter_free(adapter);
>  	return 0;
>  }
> --
> 2.17.1
diff mbox series

Patch

diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index 6442c79977..9694b32002 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -226,6 +226,8 @@  API Changes
   the crypto/security operation. This field will be used to communicate
   events such as soft expiry with IPsec in lookaside mode.
 
+* eventdev: Move memory used by timer adapters to hugepage. This will prevent
+  TLB misses if any and aligns to memory structure of other subsystems.
 
 ABI Changes
 -----------
diff --git a/lib/eventdev/rte_event_timer_adapter.c b/lib/eventdev/rte_event_timer_adapter.c
index ae55407042..894f532ef0 100644
--- a/lib/eventdev/rte_event_timer_adapter.c
+++ b/lib/eventdev/rte_event_timer_adapter.c
@@ -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 = adapter[i].allocated;
+
+	if (!ret) {
+		rte_free(adapters);
+		adapters = NULL;
+	}
+
 	rte_eventdev_trace_timer_adapter_free(adapter);
 	return 0;
 }