Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/45133/?format=api
https://patches.dpdk.org/api/patches/45133/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/4a76b48cb42c500833a99d3dbcb0292eefa6d284.1537546029.git.anatoly.burakov@intel.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": "<4a76b48cb42c500833a99d3dbcb0292eefa6d284.1537546029.git.anatoly.burakov@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/4a76b48cb42c500833a99d3dbcb0292eefa6d284.1537546029.git.anatoly.burakov@intel.com", "date": "2018-09-21T16:14:00", "name": "[v4,11/20] malloc: allow creating malloc heaps", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "62a75eb57c525058a6a2db70ad3e1b1a987ab9b7", "submitter": { "id": 4, "url": "https://patches.dpdk.org/api/people/4/?format=api", "name": "Anatoly Burakov", "email": "anatoly.burakov@intel.com" }, "delegate": { "id": 1, "url": "https://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "https://patches.dpdk.org/project/dpdk/patch/4a76b48cb42c500833a99d3dbcb0292eefa6d284.1537546029.git.anatoly.burakov@intel.com/mbox/", "series": [ { "id": 1446, "url": "https://patches.dpdk.org/api/series/1446/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=1446", "date": "2018-09-21T16:13:49", "name": "Support externally allocated memory in DPDK", "version": 4, "mbox": "https://patches.dpdk.org/series/1446/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/45133/comments/", "check": "fail", "checks": "https://patches.dpdk.org/api/patches/45133/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 692547D04;\n\tFri, 21 Sep 2018 18:14:43 +0200 (CEST)", "from mga18.intel.com (mga18.intel.com [134.134.136.126])\n\tby dpdk.org (Postfix) with ESMTP id 20F255F1D\n\tfor <dev@dpdk.org>; Fri, 21 Sep 2018 18:14:21 +0200 (CEST)", "from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t21 Sep 2018 09:14:21 -0700", "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby fmsmga006.fm.intel.com with ESMTP; 21 Sep 2018 09:14:12 -0700", "from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com\n\t[10.237.217.45])\n\tby irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id\n\tw8LGEB48029213; Fri, 21 Sep 2018 17:14:11 +0100", "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w8LGEBLL002856;\n\tFri, 21 Sep 2018 17:14:11 +0100", "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w8LGEBCB002852;\n\tFri, 21 Sep 2018 17:14:11 +0100" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.54,285,1534834800\"; d=\"scan'208\";a=\"265595790\"", "From": "Anatoly Burakov <anatoly.burakov@intel.com>", "To": "dev@dpdk.org", "Cc": "laszlo.madarassy@ericsson.com, laszlo.vadkerti@ericsson.com,\n\tandras.kovacs@ericsson.com, winnie.tian@ericsson.com,\n\tdaniel.andrasi@ericsson.com, janos.kobor@ericsson.com,\n\tgeza.koblo@ericsson.com, srinath.mannam@broadcom.com,\n\tscott.branden@broadcom.com, ajit.khaparde@broadcom.com,\n\tkeith.wiles@intel.com, bruce.richardson@intel.com, thomas@monjalon.net,\n\tshreyansh.jain@nxp.com, shahafs@mellanox.com, arybchenko@solarflare.com", "Date": "Fri, 21 Sep 2018 17:14:00 +0100", "Message-Id": "<4a76b48cb42c500833a99d3dbcb0292eefa6d284.1537546029.git.anatoly.burakov@intel.com>", "X-Mailer": "git-send-email 1.7.0.7", "In-Reply-To": [ "<cover.1537546029.git.anatoly.burakov@intel.com>", "<cover.1537546029.git.anatoly.burakov@intel.com>" ], "References": [ "<cover.1537546029.git.anatoly.burakov@intel.com>", "<cover.1537443103.git.anatoly.burakov@intel.com>\n\t<cover.1537546029.git.anatoly.burakov@intel.com>" ], "Subject": "[dpdk-dev] [PATCH v4 11/20] malloc: allow creating malloc heaps", "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\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Add API to allow creating new malloc heaps. They will be created\nwith socket ID's going above RTE_MAX_NUMA_NODES, to avoid clashing\nwith internal heaps.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n lib/librte_eal/common/include/rte_malloc.h | 19 ++++++++\n lib/librte_eal/common/malloc_heap.c | 30 +++++++++++++\n lib/librte_eal/common/malloc_heap.h | 3 ++\n lib/librte_eal/common/rte_malloc.c | 52 ++++++++++++++++++++++\n lib/librte_eal/rte_eal_version.map | 1 +\n 5 files changed, 105 insertions(+)", "diff": "diff --git a/lib/librte_eal/common/include/rte_malloc.h b/lib/librte_eal/common/include/rte_malloc.h\nindex 403271ddc..e326529d0 100644\n--- a/lib/librte_eal/common/include/rte_malloc.h\n+++ b/lib/librte_eal/common/include/rte_malloc.h\n@@ -263,6 +263,25 @@ int\n rte_malloc_get_socket_stats(int socket,\n \t\tstruct rte_malloc_socket_stats *socket_stats);\n \n+/**\n+ * Creates a new empty malloc heap with a specified name.\n+ *\n+ * @note Heaps created via this call will automatically get assigned a unique\n+ * socket ID, which can be found using ``rte_malloc_heap_get_socket()``\n+ *\n+ * @param heap_name\n+ * Name of the heap to create.\n+ *\n+ * @return\n+ * - 0 on successful creation\n+ * - -1 in case of error, with rte_errno set to one of the following:\n+ * EINVAL - ``heap_name`` was NULL, empty or too long\n+ * EEXIST - heap by name of ``heap_name`` already exists\n+ * ENOSPC - no more space in internal config to store a new heap\n+ */\n+int __rte_experimental\n+rte_malloc_heap_create(const char *heap_name);\n+\n /**\n * Find socket ID corresponding to a named heap.\n *\ndiff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c\nindex 2a5d2a381..1dd4ffcf9 100644\n--- a/lib/librte_eal/common/malloc_heap.c\n+++ b/lib/librte_eal/common/malloc_heap.c\n@@ -29,6 +29,10 @@\n #include \"malloc_heap.h\"\n #include \"malloc_mp.h\"\n \n+/* start external socket ID's at a very high number */\n+#define CONST_MAX(a, b) (a > b ? a : b) /* RTE_MAX is not a constant */\n+#define EXTERNAL_HEAP_MIN_SOCKET_ID (CONST_MAX((1 << 8), RTE_MAX_NUMA_NODES))\n+\n static unsigned\n check_hugepage_sz(unsigned flags, uint64_t hugepage_sz)\n {\n@@ -1015,6 +1019,32 @@ malloc_heap_dump(struct malloc_heap *heap, FILE *f)\n \trte_spinlock_unlock(&heap->lock);\n }\n \n+int\n+malloc_heap_create(struct malloc_heap *heap, const char *heap_name)\n+{\n+\tstatic uint32_t next_socket_id = EXTERNAL_HEAP_MIN_SOCKET_ID;\n+\n+\t/* prevent overflow. did you really create 2 billion heaps??? */\n+\tif (next_socket_id > INT32_MAX) {\n+\t\tRTE_LOG(ERR, EAL, \"Cannot assign new socket ID's\\n\");\n+\t\trte_errno = ENOSPC;\n+\t\treturn -1;\n+\t}\n+\n+\t/* initialize empty heap */\n+\theap->alloc_count = 0;\n+\theap->first = NULL;\n+\theap->last = NULL;\n+\tLIST_INIT(heap->free_head);\n+\trte_spinlock_init(&heap->lock);\n+\theap->total_size = 0;\n+\theap->socket_id = next_socket_id++;\n+\n+\t/* set up name */\n+\tstrlcpy(heap->name, heap_name, RTE_HEAP_NAME_MAX_LEN);\n+\treturn 0;\n+}\n+\n int\n rte_eal_malloc_heap_init(void)\n {\ndiff --git a/lib/librte_eal/common/malloc_heap.h b/lib/librte_eal/common/malloc_heap.h\nindex 61b844b6f..eebee16dc 100644\n--- a/lib/librte_eal/common/malloc_heap.h\n+++ b/lib/librte_eal/common/malloc_heap.h\n@@ -33,6 +33,9 @@ void *\n malloc_heap_alloc_biggest(const char *type, int socket, unsigned int flags,\n \t\tsize_t align, bool contig);\n \n+int\n+malloc_heap_create(struct malloc_heap *heap, const char *heap_name);\n+\n int\n malloc_heap_free(struct malloc_elem *elem);\n \ndiff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c\nindex fa81d7862..25967a7cb 100644\n--- a/lib/librte_eal/common/rte_malloc.c\n+++ b/lib/librte_eal/common/rte_malloc.c\n@@ -13,6 +13,7 @@\n #include <rte_memory.h>\n #include <rte_eal.h>\n #include <rte_eal_memconfig.h>\n+#include <rte_errno.h>\n #include <rte_branch_prediction.h>\n #include <rte_debug.h>\n #include <rte_launch.h>\n@@ -311,3 +312,54 @@ rte_malloc_virt2iova(const void *addr)\n \n \treturn ms->iova + RTE_PTR_DIFF(addr, ms->addr);\n }\n+\n+int\n+rte_malloc_heap_create(const char *heap_name)\n+{\n+\tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n+\tstruct malloc_heap *heap = NULL;\n+\tint i, ret;\n+\n+\tif (heap_name == NULL ||\n+\t\t\tstrnlen(heap_name, RTE_HEAP_NAME_MAX_LEN) == 0 ||\n+\t\t\tstrnlen(heap_name, RTE_HEAP_NAME_MAX_LEN) ==\n+\t\t\t\tRTE_HEAP_NAME_MAX_LEN) {\n+\t\trte_errno = EINVAL;\n+\t\treturn -1;\n+\t}\n+\t/* check if there is space in the heap list, or if heap with this name\n+\t * already exists.\n+\t */\n+\trte_rwlock_write_lock(&mcfg->memory_hotplug_lock);\n+\n+\tfor (i = 0; i < RTE_MAX_HEAPS; i++) {\n+\t\tstruct malloc_heap *tmp = &mcfg->malloc_heaps[i];\n+\t\t/* existing heap */\n+\t\tif (strncmp(heap_name, tmp->name,\n+\t\t\t\tRTE_HEAP_NAME_MAX_LEN) == 0) {\n+\t\t\tRTE_LOG(ERR, EAL, \"Heap %s already exists\\n\",\n+\t\t\t\theap_name);\n+\t\t\trte_errno = EEXIST;\n+\t\t\tret = -1;\n+\t\t\tgoto unlock;\n+\t\t}\n+\t\t/* empty heap */\n+\t\tif (strnlen(tmp->name, RTE_HEAP_NAME_MAX_LEN) == 0) {\n+\t\t\theap = tmp;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\tif (heap == NULL) {\n+\t\tRTE_LOG(ERR, EAL, \"Cannot create new heap: no space\\n\");\n+\t\trte_errno = ENOSPC;\n+\t\tret = -1;\n+\t\tgoto unlock;\n+\t}\n+\n+\t/* we're sure that we can create a new heap, so do it */\n+\tret = malloc_heap_create(heap, heap_name);\n+unlock:\n+\trte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);\n+\n+\treturn ret;\n+}\ndiff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map\nindex bd60506af..376f33bbb 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -318,6 +318,7 @@ EXPERIMENTAL {\n \trte_fbarray_set_used;\n \trte_log_register_type_and_pick_level;\n \trte_malloc_dump_heaps;\n+\trte_malloc_heap_create;\n \trte_malloc_heap_get_socket;\n \trte_malloc_heap_socket_is_external;\n \trte_mem_alloc_validator_register;\n", "prefixes": [ "v4", "11/20" ] }{ "id": 45133, "url": "