[v2,6/6] mempool: use the specific macro for object alignment

Message ID 20191030143619.4007-7-olivier.matz@6wind.com (mailing list archive)
State Superseded, archived
Headers
Series mempool: avoid objects allocations across pages |

Checks

Context Check Description
ci/Intel-compilation fail Compilation issues
ci/travis-robot success Travis build: passed
ci/checkpatch success coding style OK

Commit Message

Olivier Matz Oct. 30, 2019, 2:36 p.m. UTC
  For consistency, RTE_MEMPOOL_ALIGN should be used in place of
RTE_CACHE_LINE_SIZE. They have the same value, because the only arch
that was defining a specific value for it has been removed from dpdk.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 lib/librte_mempool/rte_mempool.c             | 2 +-
 lib/librte_mempool/rte_mempool.h             | 3 +++
 lib/librte_mempool/rte_mempool_ops_default.c | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)
  

Comments

Andrew Rybchenko Oct. 30, 2019, 2:55 p.m. UTC | #1
On 10/30/19 5:36 PM, Olivier Matz wrote:
> For consistency, RTE_MEMPOOL_ALIGN should be used in place of
> RTE_CACHE_LINE_SIZE. They have the same value, because the only arch
> that was defining a specific value for it has been removed from dpdk.
>
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>

Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
  

Patch

diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index d3db9273d..40cae3eb6 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -329,7 +329,7 @@  rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr,
 	if (mp->flags & MEMPOOL_F_NO_CACHE_ALIGN)
 		off = RTE_PTR_ALIGN_CEIL(vaddr, 8) - vaddr;
 	else
-		off = RTE_PTR_ALIGN_CEIL(vaddr, RTE_CACHE_LINE_SIZE) - vaddr;
+		off = RTE_PTR_ALIGN_CEIL(vaddr, RTE_MEMPOOL_ALIGN) - vaddr;
 
 	if (off > len) {
 		ret = -EINVAL;
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index 6d98b3743..cb7c423e6 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -116,6 +116,9 @@  struct rte_mempool_objsz {
 #define	MEMPOOL_PG_NUM_DEFAULT	1
 
 #ifndef RTE_MEMPOOL_ALIGN
+/**
+ * Alignment of elements inside mempool.
+ */
 #define RTE_MEMPOOL_ALIGN	RTE_CACHE_LINE_SIZE
 #endif
 
diff --git a/lib/librte_mempool/rte_mempool_ops_default.c b/lib/librte_mempool/rte_mempool_ops_default.c
index e5cd4600f..390c490fd 100644
--- a/lib/librte_mempool/rte_mempool_ops_default.c
+++ b/lib/librte_mempool/rte_mempool_ops_default.c
@@ -56,7 +56,7 @@  rte_mempool_op_calc_mem_size_default(const struct rte_mempool *mp,
 	}
 
 	*min_chunk_size = total_elt_sz;
-	*align = RTE_CACHE_LINE_SIZE;
+	*align = RTE_MEMPOOL_ALIGN;
 
 	return mem_size;
 }