From: Suanming Mou <suanmingm@mellanox.com>
To: viacheslavo@mellanox.com, matan@mellanox.com
Cc: orika@mellanox.com, rasland@mellanox.com, dev@dpdk.org
Subject: [dpdk-dev] [PATCH 5/7] common/mlx5: convert data path objects to unified malloc
Date: Wed, 15 Jul 2020 12:00:01 +0800 [thread overview]
Message-ID: <1594785603-152773-6-git-send-email-suanmingm@mellanox.com> (raw)
In-Reply-To: <1594785603-152773-1-git-send-email-suanmingm@mellanox.com>
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 <suanmingm@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
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. */
--
1.8.3.1
next prev parent reply other threads:[~2020-07-15 4:01 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-15 3:59 [dpdk-dev] [PATCH 0/7] net/mlx5: add sys_mem_en devarg Suanming Mou
2020-07-15 3:59 ` [dpdk-dev] [PATCH 1/7] common/mlx5: add mlx5 memory management functions Suanming Mou
2020-07-15 3:59 ` [dpdk-dev] [PATCH 2/7] net/mlx5: add allocate memory from system devarg Suanming Mou
2020-07-15 3:59 ` [dpdk-dev] [PATCH 3/7] net/mlx5: convert control path memory to unified malloc Suanming Mou
2020-07-15 4:00 ` [dpdk-dev] [PATCH 4/7] common/mlx5: " Suanming Mou
2020-07-15 4:00 ` Suanming Mou [this message]
2020-07-15 4:00 ` [dpdk-dev] [PATCH 6/7] net/mlx5: convert configuration objects " Suanming Mou
2020-07-15 4:00 ` [dpdk-dev] [PATCH 7/7] net/mlx5: convert Rx/Tx queue " Suanming Mou
2020-07-16 9:20 ` [dpdk-dev] [PATCH v2 0/7] net/mlx5: add sys_mem_en devarg Suanming Mou
2020-07-16 9:20 ` [dpdk-dev] [PATCH v2 1/7] common/mlx5: add mlx5 memory management functions Suanming Mou
2020-07-16 9:20 ` [dpdk-dev] [PATCH v2 2/7] net/mlx5: add allocate memory from system devarg Suanming Mou
2020-07-16 9:20 ` [dpdk-dev] [PATCH v2 3/7] net/mlx5: convert control path memory to unified malloc Suanming Mou
2020-07-16 9:20 ` [dpdk-dev] [PATCH v2 4/7] common/mlx5: " Suanming Mou
2020-07-16 9:20 ` [dpdk-dev] [PATCH v2 5/7] common/mlx5: convert data path objects " Suanming Mou
2020-07-16 9:20 ` [dpdk-dev] [PATCH v2 6/7] net/mlx5: convert configuration " Suanming Mou
2020-07-16 9:20 ` [dpdk-dev] [PATCH v2 7/7] net/mlx5: convert Rx/Tx queue " Suanming Mou
2020-07-17 13:50 ` [dpdk-dev] [PATCH v3 0/7] net/mlx5: add sys_mem_en devarg Suanming Mou
2020-07-17 13:50 ` [dpdk-dev] [PATCH v3 1/7] common/mlx5: add mlx5 memory management functions Suanming Mou
2020-07-17 13:51 ` [dpdk-dev] [PATCH v3 2/7] net/mlx5: add allocate memory from system devarg Suanming Mou
2020-07-17 13:51 ` [dpdk-dev] [PATCH v3 3/7] net/mlx5: convert control path memory to unified malloc Suanming Mou
2020-07-17 13:51 ` [dpdk-dev] [PATCH v3 4/7] common/mlx5: " Suanming Mou
2020-07-17 13:51 ` [dpdk-dev] [PATCH v3 5/7] common/mlx5: convert data path objects " Suanming Mou
2020-07-17 13:51 ` [dpdk-dev] [PATCH v3 6/7] net/mlx5: convert configuration " Suanming Mou
2020-07-17 13:51 ` [dpdk-dev] [PATCH v3 7/7] net/mlx5: convert Rx/Tx queue " Suanming Mou
2020-07-17 17:09 ` [dpdk-dev] [PATCH v3 0/7] net/mlx5: add sys_mem_en devarg Raslan Darawsheh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1594785603-152773-6-git-send-email-suanmingm@mellanox.com \
--to=suanmingm@mellanox.com \
--cc=dev@dpdk.org \
--cc=matan@mellanox.com \
--cc=orika@mellanox.com \
--cc=rasland@mellanox.com \
--cc=viacheslavo@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).