Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/82402/?format=api
https://patches.dpdk.org/api/patches/82402/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/20201027232335.31427-16-ophirmu@nvidia.com/", "project": { "id": 1, "url": "https://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20201027232335.31427-16-ophirmu@nvidia.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20201027232335.31427-16-ophirmu@nvidia.com", "date": "2020-10-27T23:22:38", "name": "[v1,15/72] common/mlx5/linux: handle memory allocations with alignment", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "ec73ce402c53910400b6eb4108d6306b500fa185", "submitter": { "id": 1908, "url": "https://patches.dpdk.org/api/people/1908/?format=api", "name": "Ophir Munk", "email": "ophirmu@nvidia.com" }, "delegate": { "id": 3268, "url": "https://patches.dpdk.org/api/users/3268/?format=api", "username": "rasland", "first_name": "Raslan", "last_name": "Darawsheh", "email": "rasland@nvidia.com" }, "mbox": "https://patches.dpdk.org/project/dpdk/patch/20201027232335.31427-16-ophirmu@nvidia.com/mbox/", "series": [ { "id": 13395, "url": "https://patches.dpdk.org/api/series/13395/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=13395", "date": "2020-10-27T23:22:23", "name": "mlx5 Windows support - part #5", "version": 1, "mbox": "https://patches.dpdk.org/series/13395/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/82402/comments/", "check": "success", "checks": "https://patches.dpdk.org/api/patches/82402/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id D47B6A04B5;\n\tWed, 28 Oct 2020 00:28:06 +0100 (CET)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 633B92BFA;\n\tWed, 28 Oct 2020 00:24:34 +0100 (CET)", "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by dpdk.org (Postfix) with ESMTP id 83ED72C55\n for <dev@dpdk.org>; Wed, 28 Oct 2020 00:24:00 +0100 (CET)", "from Internal Mail-Server by MTLPINE1 (envelope-from\n ophirmu@nvidia.com) with SMTP; 28 Oct 2020 01:23:54 +0200", "from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100])\n by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09RNNrrR026642;\n Wed, 28 Oct 2020 01:23:54 +0200" ], "From": "Ophir Munk <ophirmu@nvidia.com>", "To": "dev@dpdk.org, Raslan Darawsheh <rasland@nvidia.com>", "Cc": "Ophir Munk <ophirmu@nvidia.com>, Matan Azrad <matan@nvidia.com>,\n Tal Shnaiderman <talshn@nvidia.com>, Thomas Monjalon <thomas@monjalon.net>", "Date": "Tue, 27 Oct 2020 23:22:38 +0000", "Message-Id": "<20201027232335.31427-16-ophirmu@nvidia.com>", "X-Mailer": "git-send-email 2.8.4", "In-Reply-To": "<20201027232335.31427-1-ophirmu@nvidia.com>", "References": "<20201027232335.31427-1-ophirmu@nvidia.com>", "Subject": "[dpdk-dev] [PATCH v1 15/72] common/mlx5/linux: handle memory\n\tallocations with alignment", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "mlx5_malloc() API has an alignment parameter for system memory\nallocations. malloc() is called for non-aligned allocations and\nposix_memalign() is called for aligned allocations. When calling\nmlx5_free() there is no distinction whether the memory was originally\nallocated with or without alignment. Freeing a memory may be handled\ndifferently by operating systems. Therefore this commit wraps these APIs\nwith OS specific calls: mlx5_os_malloc(), mlx5_os_free().\n\nSigned-off-by: Ophir Munk <ophirmu@nvidia.com>\nAcked-by: Matan Azrad <matan@nvidia.com>\n---\n drivers/common/mlx5/linux/mlx5_common_os.h | 38 ++++++++++++++++++++++++++++++\n drivers/common/mlx5/mlx5_malloc.c | 14 +++++------\n 2 files changed, 44 insertions(+), 8 deletions(-)", "diff": "diff --git a/drivers/common/mlx5/linux/mlx5_common_os.h b/drivers/common/mlx5/linux/mlx5_common_os.h\nindex f8b215c..bd44ecb 100644\n--- a/drivers/common/mlx5/linux/mlx5_common_os.h\n+++ b/drivers/common/mlx5/linux/mlx5_common_os.h\n@@ -6,6 +6,7 @@\n #define RTE_PMD_MLX5_COMMON_OS_H_\n \n #include <stdio.h>\n+#include <malloc.h>\n \n #include <rte_pci.h>\n #include <rte_debug.h>\n@@ -16,6 +17,7 @@\n \n #include \"mlx5_autoconf.h\"\n #include \"mlx5_glue.h\"\n+#include \"mlx5_malloc.h\"\n \n /**\n * Get device name. Given an ibv_device pointer - return a\n@@ -224,4 +226,40 @@ mlx5_os_umem_dereg(void *pumem)\n {\n \treturn mlx5_glue->devx_umem_dereg(pumem);\n }\n+\n+/**\n+ * Memory allocation optionally with alignment.\n+ *\n+ * @param[in] align\n+ * Alignment size (may be zero)\n+ * @param[in] size\n+ * Size in bytes to allocate\n+ *\n+ * @return\n+ * Valid pointer to allocated memory, NULL in case of failure\n+ */\n+static inline void *\n+mlx5_os_malloc(size_t align, size_t size)\n+{\n+\tvoid *buf;\n+\n+\tif (posix_memalign(&buf, align, size))\n+\t\treturn NULL;\n+\treturn buf;\n+}\n+\n+/**\n+ * This API de-allocates a memory that originally could have been\n+ * allocated aligned or non-aligned. In Linux it is a wrapper\n+ * around free().\n+ *\n+ * @param[in] addr\n+ * Pointer to address to free\n+ *\n+ */\n+static inline void\n+mlx5_os_free(void *addr)\n+{\n+\tfree(addr);\n+}\n #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */\ndiff --git a/drivers/common/mlx5/mlx5_malloc.c b/drivers/common/mlx5/mlx5_malloc.c\nindex 4489971..dd8b793 100644\n--- a/drivers/common/mlx5/mlx5_malloc.c\n+++ b/drivers/common/mlx5/mlx5_malloc.c\n@@ -11,6 +11,7 @@\n #include <rte_atomic.h>\n \n #include \"mlx5_common_utils.h\"\n+#include \"mlx5_common_os.h\"\n #include \"mlx5_malloc.h\"\n \n struct mlx5_sys_mem {\n@@ -151,14 +152,11 @@ static void *\n mlx5_alloc_align(size_t size, unsigned int align, unsigned int zero)\n {\n \tvoid *buf;\n-\tint ret;\n-\n-\tret = posix_memalign(&buf, align, size);\n-\tif (ret) {\n-\t\tDRV_LOG(ERR,\n-\t\t\t\"Couldn't allocate buf size=%zu align=%u. Err=%d\\n\",\n-\t\t\tsize, align, ret);\n \n+\tbuf = mlx5_os_malloc(align, size);\n+\tif (!buf) {\n+\t\tDRV_LOG(ERR, \"Couldn't allocate buf size=%zu align=%u.\",\n+\t\t\tsize, align);\n \t\treturn NULL;\n \t}\n \tif (zero)\n@@ -262,7 +260,7 @@ mlx5_free(void *addr)\n #ifdef RTE_LIBRTE_MLX5_DEBUG\n \t\trte_atomic64_inc(&mlx5_sys_mem.free_sys);\n #endif\n-\t\tfree(addr);\n+\t\tmlx5_os_free(addr);\n \t} else {\n #ifdef RTE_LIBRTE_MLX5_DEBUG\n \t\trte_atomic64_inc(&mlx5_sys_mem.free_rte);\n", "prefixes": [ "v1", "15/72" ] }{ "id": 82402, "url": "