From: Suanming Mou Date: Tue, 28 Apr 2020 09:13:37 +0000 (+0800) Subject: net/mlx5: fix indexed pool bitmap initialization X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=691b3d3ebb6acf7f6a88b64690b1f6b319ab7b6d;p=dpdk.git net/mlx5: fix indexed pool bitmap initialization Currently, the indexed memory pool bitmap start address is not aligned to cacheline size explicitly. The bitmap initialization requires the address should be cacheline aligned. In that case, the initialization maybe failed if the address is not cacheline aligned. Add RTE_CACHE_LINE_ROUNDUP() to the trunk size calculation to make sure the bitmap offset address will start with cacheline aligned. Fixes: a3cf59f56c47 ("net/mlx5: add indexed memory pool") Signed-off-by: Suanming Mou Tested-by: Lijian Zhang Acked-by: Viacheslav Ovsiienko Reviewed-by: Ruifeng Wang --- diff --git a/drivers/net/mlx5/mlx5_utils.c b/drivers/net/mlx5/mlx5_utils.c index 2146ffdc04..d29fbcbc83 100644 --- a/drivers/net/mlx5/mlx5_utils.c +++ b/drivers/net/mlx5/mlx5_utils.c @@ -265,7 +265,9 @@ mlx5_ipool_grow(struct mlx5_indexed_pool *pool) trunk_size += sizeof(*trunk); data_size = mlx5_trunk_size_get(pool, idx); bmp_size = rte_bitmap_get_memory_footprint(data_size); - trunk_size += data_size * pool->cfg.size + bmp_size; + /* rte_bitmap requires memory cacheline aligned. */ + trunk_size += RTE_CACHE_LINE_ROUNDUP(data_size * pool->cfg.size); + trunk_size += bmp_size; trunk = pool->cfg.malloc(pool->cfg.type, trunk_size, RTE_CACHE_LINE_SIZE, rte_socket_id()); if (!trunk) @@ -278,8 +280,10 @@ mlx5_ipool_grow(struct mlx5_indexed_pool *pool) MLX5_ASSERT(pool->free_list == TRUNK_INVALID); pool->free_list = idx; /* Mark all entries as available. */ - trunk->bmp = rte_bitmap_init_with_all_set(data_size, - &trunk->data[data_size * pool->cfg.size], bmp_size); + trunk->bmp = rte_bitmap_init_with_all_set(data_size, &trunk->data + [RTE_CACHE_LINE_ROUNDUP(data_size * pool->cfg.size)], + bmp_size); + MLX5_ASSERT(trunk->bmp); pool->n_trunk_valid++; #ifdef POOL_DEBUG pool->trunk_new++; diff --git a/drivers/net/mlx5/mlx5_utils.h b/drivers/net/mlx5/mlx5_utils.h index 0e016f87c3..f4ec15170a 100644 --- a/drivers/net/mlx5/mlx5_utils.h +++ b/drivers/net/mlx5/mlx5_utils.h @@ -105,7 +105,7 @@ struct mlx5_indexed_trunk { uint32_t next; /* Next free trunk in free list. */ uint32_t free; /* Free entries available */ struct rte_bitmap *bmp; - uint8_t data[] __rte_cache_min_aligned; /* Entry data start. */ + uint8_t data[] __rte_cache_aligned; /* Entry data start. */ }; struct mlx5_indexed_pool {