[RFC,v3,3/6] lib/mempool: allow page size aligned mempool

Message ID 20180816144321.17719-4-qi.z.zhang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series [RFC,v3,1/6] net/af_xdp: new PMD driver |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Qi Zhang Aug. 16, 2018, 2:43 p.m. UTC
  Allow create a mempool with page size aligned base address.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 lib/librte_mempool/rte_mempool.c | 3 +++
 lib/librte_mempool/rte_mempool.h | 1 +
 2 files changed, 4 insertions(+)
  

Comments

Jerin Jacob Aug. 19, 2018, 6:56 a.m. UTC | #1
-----Original Message-----
> Date: Thu, 16 Aug 2018 22:43:18 +0800
> From: Qi Zhang <qi.z.zhang@intel.com>
> To: dev@dpdk.org
> CC: magnus.karlsson@intel.com, bjorn.topel@intel.com,
>  jingjing.wu@intel.com, xiaoyun.li@intel.com, ferruh.yigit@intel.com, Qi
>  Zhang <qi.z.zhang@intel.com>
> Subject: [dpdk-dev] [RFC v3 3/6] lib/mempool: allow page size aligned
>  mempool
> X-Mailer: git-send-email 2.13.6
> 
> 
> Allow create a mempool with page size aligned base address.


If I understand it correctly, you are doing this enable AF_XDP PMD which
has some constraints. If so, I think more transparent way to handle this
from application perspective would be to
1) add new mempool ops which based this new flags
and
2) and call rte_mbuf_set_platform_mempool_ops("new mempool op for af_xdp");
on af_xdp device probe()

That will avoid the need for new API and testpmd changes for flag
selection.

The proposed RFC has problem where, end user needs to know what flags are
relevant for certain PMD.

> 
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> ---
>  lib/librte_mempool/rte_mempool.c | 3 +++
>  lib/librte_mempool/rte_mempool.h | 1 +
>  2 files changed, 4 insertions(+)
> 
> diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
> index 03e6b5f73..61f7764c5 100644
> --- a/lib/librte_mempool/rte_mempool.c
> +++ b/lib/librte_mempool/rte_mempool.c
> @@ -508,6 +508,9 @@ rte_mempool_populate_default(struct rte_mempool *mp)
>                 if (try_contig)
>                         flags |= RTE_MEMZONE_IOVA_CONTIG;
> 
> +               if (mp->flags & MEMPOOL_F_PAGE_ALIGN)
> +                       align = getpagesize();
> +
>                 mz = rte_memzone_reserve_aligned(mz_name, mem_size,
>                                 mp->socket_id, flags, align);
> 
> diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
> index 7c9cd9a2f..75553b36f 100644
> --- a/lib/librte_mempool/rte_mempool.h
> +++ b/lib/librte_mempool/rte_mempool.h
> @@ -264,6 +264,7 @@ struct rte_mempool {
>  #define MEMPOOL_F_POOL_CREATED   0x0010 /**< Internal: pool is created. */
>  #define MEMPOOL_F_NO_IOVA_CONTIG 0x0020 /**< Don't need IOVA contiguous objs. */
>  #define MEMPOOL_F_NO_PHYS_CONTIG MEMPOOL_F_NO_IOVA_CONTIG /* deprecated */
> +#define MEMPOOL_F_PAGE_ALIGN     0x0040 /**< Chunk's base address is page aligned */
> 
>  /**
>   * @internal When debug is enabled, store some statistics.
> --
> 2.13.6
>
  

Patch

diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 03e6b5f73..61f7764c5 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -508,6 +508,9 @@  rte_mempool_populate_default(struct rte_mempool *mp)
 		if (try_contig)
 			flags |= RTE_MEMZONE_IOVA_CONTIG;
 
+		if (mp->flags & MEMPOOL_F_PAGE_ALIGN)
+			align = getpagesize();
+
 		mz = rte_memzone_reserve_aligned(mz_name, mem_size,
 				mp->socket_id, flags, align);
 
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index 7c9cd9a2f..75553b36f 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -264,6 +264,7 @@  struct rte_mempool {
 #define MEMPOOL_F_POOL_CREATED   0x0010 /**< Internal: pool is created. */
 #define MEMPOOL_F_NO_IOVA_CONTIG 0x0020 /**< Don't need IOVA contiguous objs. */
 #define MEMPOOL_F_NO_PHYS_CONTIG MEMPOOL_F_NO_IOVA_CONTIG /* deprecated */
+#define MEMPOOL_F_PAGE_ALIGN     0x0040 /**< Chunk's base address is page aligned */
 
 /**
  * @internal When debug is enabled, store some statistics.