[v3,7/7] mempool: use the specific macro for object alignment
Checks
Commit Message
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>
Acked-by: Nipun Gupta <nipun.gupta@nxp.com>
---
drivers/mempool/bucket/rte_mempool_bucket.c | 8 +++++++-
lib/librte_mempool/rte_mempool.c | 2 +-
lib/librte_mempool/rte_mempool.h | 3 +++
lib/librte_mempool/rte_mempool_ops_default.c | 2 +-
4 files changed, 12 insertions(+), 3 deletions(-)
Comments
On 11/4/19 6:12 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>
> Acked-by: Nipun Gupta <nipun.gupta@nxp.com>
> ---
> drivers/mempool/bucket/rte_mempool_bucket.c | 8 +++++++-
> lib/librte_mempool/rte_mempool.c | 2 +-
> lib/librte_mempool/rte_mempool.h | 3 +++
> lib/librte_mempool/rte_mempool_ops_default.c | 2 +-
> 4 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mempool/bucket/rte_mempool_bucket.c b/drivers/mempool/bucket/rte_mempool_bucket.c
> index b978fd220..5ce1ef16f 100644
> --- a/drivers/mempool/bucket/rte_mempool_bucket.c
> +++ b/drivers/mempool/bucket/rte_mempool_bucket.c
> @@ -401,6 +401,11 @@ bucket_alloc(struct rte_mempool *mp)
> struct bucket_data *bd;
> unsigned int i;
> unsigned int bucket_header_size;
> + size_t pg_sz;
> +
> + rc = rte_mempool_get_page_size(mp, &pg_sz);
> + if (rc < 0)
> + return rc;
Looks unrelated to the patch.
> bd = rte_zmalloc_socket("bucket_pool", sizeof(*bd),
> RTE_CACHE_LINE_SIZE, mp->socket_id);
[snip]
On Tue, Nov 05, 2019 at 03:15:13PM +0300, Andrew Rybchenko wrote:
> On 11/4/19 6:12 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>
> > Acked-by: Nipun Gupta <nipun.gupta@nxp.com>
> > ---
> > drivers/mempool/bucket/rte_mempool_bucket.c | 8 +++++++-
> > lib/librte_mempool/rte_mempool.c | 2 +-
> > lib/librte_mempool/rte_mempool.h | 3 +++
> > lib/librte_mempool/rte_mempool_ops_default.c | 2 +-
> > 4 files changed, 12 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/mempool/bucket/rte_mempool_bucket.c b/drivers/mempool/bucket/rte_mempool_bucket.c
> > index b978fd220..5ce1ef16f 100644
> > --- a/drivers/mempool/bucket/rte_mempool_bucket.c
> > +++ b/drivers/mempool/bucket/rte_mempool_bucket.c
> > @@ -401,6 +401,11 @@ bucket_alloc(struct rte_mempool *mp)
> > struct bucket_data *bd;
> > unsigned int i;
> > unsigned int bucket_header_size;
> > + size_t pg_sz;
> > +
> > + rc = rte_mempool_get_page_size(mp, &pg_sz);
> > + if (rc < 0)
> > + return rc;
>
> Looks unrelated to the patch.
Oops, indeed, every change in rte_mempool_bucket.c should be in patch 6/7
"mempool: prevent objects from being across pages", Thanks for spotting it.
>
> > bd = rte_zmalloc_socket("bucket_pool", sizeof(*bd),
> > RTE_CACHE_LINE_SIZE, mp->socket_id);
>
> [snip]
>
>
@@ -401,6 +401,11 @@ bucket_alloc(struct rte_mempool *mp)
struct bucket_data *bd;
unsigned int i;
unsigned int bucket_header_size;
+ size_t pg_sz;
+
+ rc = rte_mempool_get_page_size(mp, &pg_sz);
+ if (rc < 0)
+ return rc;
bd = rte_zmalloc_socket("bucket_pool", sizeof(*bd),
RTE_CACHE_LINE_SIZE, mp->socket_id);
@@ -416,7 +421,8 @@ bucket_alloc(struct rte_mempool *mp)
RTE_BUILD_BUG_ON(sizeof(struct bucket_header) > RTE_CACHE_LINE_SIZE);
bd->header_size = mp->header_size + bucket_header_size;
bd->total_elt_size = mp->header_size + mp->elt_size + mp->trailer_size;
- bd->bucket_mem_size = RTE_DRIVER_MEMPOOL_BUCKET_SIZE_KB * 1024;
+ bd->bucket_mem_size = RTE_MIN(pg_sz,
+ (size_t)(RTE_DRIVER_MEMPOOL_BUCKET_SIZE_KB * 1024));
bd->obj_per_bucket = (bd->bucket_mem_size - bucket_header_size) /
bd->total_elt_size;
bd->bucket_page_mask = ~(rte_align64pow2(bd->bucket_mem_size) - 1);
@@ -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;
@@ -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
@@ -60,7 +60,7 @@ rte_mempool_op_calc_mem_size_helper(const struct rte_mempool *mp,
}
*min_chunk_size = total_elt_sz;
- *align = RTE_CACHE_LINE_SIZE;
+ *align = RTE_MEMPOOL_ALIGN;
return mem_size;
}