From patchwork Thu Jul 16 09:20:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suanming Mou X-Patchwork-Id: 74214 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9DD61A0540; Thu, 16 Jul 2020 11:21:30 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B4BC51BFB7; Thu, 16 Jul 2020 11:20:36 +0200 (CEST) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id 835841BFB1 for ; Thu, 16 Jul 2020 11:20:32 +0200 (CEST) From: Suanming Mou To: viacheslavo@mellanox.com, matan@mellanox.com Cc: orika@mellanox.com, rasland@mellanox.com, dev@dpdk.org Date: Thu, 16 Jul 2020 17:20:14 +0800 Message-Id: <1594891216-11778-6-git-send-email-suanmingm@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1594891216-11778-1-git-send-email-suanmingm@mellanox.com> References: <1594785603-152773-1-git-send-email-suanmingm@mellanox.com> <1594891216-11778-1-git-send-email-suanmingm@mellanox.com> Subject: [dpdk-dev] [PATCH v2 5/7] common/mlx5: convert data path objects to unified malloc X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This commit allocates the data path object page and B-tree table memory from unified malloc function with explicit flag MLX5_MEM_RTE. Signed-off-by: Suanming Mou Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_common.c | 10 ++++++---- drivers/common/mlx5/mlx5_common_mr.c | 31 +++++++++++++++---------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index 693e2c6..17168e6 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -13,6 +13,7 @@ #include "mlx5_common.h" #include "mlx5_common_os.h" #include "mlx5_common_utils.h" +#include "mlx5_malloc.h" int mlx5_common_logtype; @@ -169,8 +170,9 @@ static inline void mlx5_cpu_id(unsigned int level, struct mlx5_devx_dbr_page *page; /* Allocate space for door-bell page and management data. */ - page = rte_calloc_socket(__func__, 1, sizeof(struct mlx5_devx_dbr_page), - RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY); + page = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, + sizeof(struct mlx5_devx_dbr_page), + RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY); if (!page) { DRV_LOG(ERR, "cannot allocate dbr page"); return NULL; @@ -180,7 +182,7 @@ static inline void mlx5_cpu_id(unsigned int level, MLX5_DBR_PAGE_SIZE, 0); if (!page->umem) { DRV_LOG(ERR, "cannot umem reg dbr page"); - rte_free(page); + mlx5_free(page); return NULL; } return page; @@ -261,7 +263,7 @@ static inline void mlx5_cpu_id(unsigned int level, LIST_REMOVE(page, next); if (page->umem) ret = -mlx5_glue->devx_umem_dereg(page->umem); - rte_free(page); + mlx5_free(page); } else { /* Mark in bitmap that this door-bell is not in use. */ offset /= MLX5_DBR_SIZE; diff --git a/drivers/common/mlx5/mlx5_common_mr.c b/drivers/common/mlx5/mlx5_common_mr.c index 564d618..23324c0 100644 --- a/drivers/common/mlx5/mlx5_common_mr.c +++ b/drivers/common/mlx5/mlx5_common_mr.c @@ -12,6 +12,7 @@ #include "mlx5_common_mp.h" #include "mlx5_common_mr.h" #include "mlx5_common_utils.h" +#include "mlx5_malloc.h" struct mr_find_contig_memsegs_data { uintptr_t addr; @@ -47,7 +48,8 @@ struct mr_find_contig_memsegs_data { * Initially cache_bh[] will be given practically enough space and once * it is expanded, expansion wouldn't be needed again ever. */ - mem = rte_realloc(bt->table, n * sizeof(struct mr_cache_entry), 0); + mem = mlx5_realloc(bt->table, MLX5_MEM_RTE | MLX5_MEM_ZERO, + n * sizeof(struct mr_cache_entry), 0, SOCKET_ID_ANY); if (mem == NULL) { /* Not an error, B-tree search will be skipped. */ DRV_LOG(WARNING, "failed to expand MR B-tree (%p) table", @@ -180,9 +182,9 @@ struct mr_find_contig_memsegs_data { } MLX5_ASSERT(!bt->table && !bt->size); memset(bt, 0, sizeof(*bt)); - bt->table = rte_calloc_socket("B-tree table", - n, sizeof(struct mr_cache_entry), - 0, socket); + bt->table = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, + sizeof(struct mr_cache_entry) * n, + 0, socket); if (bt->table == NULL) { rte_errno = ENOMEM; DEBUG("failed to allocate memory for btree cache on socket %d", @@ -212,7 +214,7 @@ struct mr_find_contig_memsegs_data { return; DEBUG("freeing B-tree %p with table %p", (void *)bt, (void *)bt->table); - rte_free(bt->table); + mlx5_free(bt->table); memset(bt, 0, sizeof(*bt)); } @@ -443,7 +445,7 @@ struct mlx5_mr * dereg_mr_cb(&mr->pmd_mr); if (mr->ms_bmp != NULL) rte_bitmap_free(mr->ms_bmp); - rte_free(mr); + mlx5_free(mr); } void @@ -650,11 +652,9 @@ struct mlx5_mr * (void *)addr, data.start, data.end, msl->page_sz, ms_n); /* Size of memory for bitmap. */ bmp_size = rte_bitmap_get_memory_footprint(ms_n); - mr = rte_zmalloc_socket(NULL, - RTE_ALIGN_CEIL(sizeof(*mr), - RTE_CACHE_LINE_SIZE) + - bmp_size, - RTE_CACHE_LINE_SIZE, msl->socket_id); + mr = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, + RTE_ALIGN_CEIL(sizeof(*mr), RTE_CACHE_LINE_SIZE) + + bmp_size, RTE_CACHE_LINE_SIZE, msl->socket_id); if (mr == NULL) { DEBUG("Unable to allocate memory for a new MR of" " address (%p).", (void *)addr); @@ -1033,10 +1033,9 @@ struct mlx5_mr * { struct mlx5_mr *mr = NULL; - mr = rte_zmalloc_socket(NULL, - RTE_ALIGN_CEIL(sizeof(*mr), - RTE_CACHE_LINE_SIZE), - RTE_CACHE_LINE_SIZE, socket_id); + mr = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, + RTE_ALIGN_CEIL(sizeof(*mr), RTE_CACHE_LINE_SIZE), + RTE_CACHE_LINE_SIZE, socket_id); if (mr == NULL) return NULL; reg_mr_cb(pd, (void *)addr, len, &mr->pmd_mr); @@ -1044,7 +1043,7 @@ struct mlx5_mr * DRV_LOG(WARNING, "Fail to create MR for address (%p)", (void *)addr); - rte_free(mr); + mlx5_free(mr); return NULL; } mr->msl = NULL; /* Mark it is external memory. */