Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/45494/?format=api
http://patches.dpdk.org/api/patches/45494/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/ea1f63ab6ab083c34395e9d1ad7768ad1f5120aa.1538044725.git.anatoly.burakov@intel.com/", "project": { "id": 1, "url": "http://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": "<ea1f63ab6ab083c34395e9d1ad7768ad1f5120aa.1538044725.git.anatoly.burakov@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/ea1f63ab6ab083c34395e9d1ad7768ad1f5120aa.1538044725.git.anatoly.burakov@intel.com", "date": "2018-09-27T10:41:09", "name": "[v6,12/21] malloc: allow destroying heaps", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "e9defde39a6357e9766396fe19ef8c5a700b54c2", "submitter": { "id": 4, "url": "http://patches.dpdk.org/api/people/4/?format=api", "name": "Anatoly Burakov", "email": "anatoly.burakov@intel.com" }, "delegate": { "id": 1, "url": "http://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/ea1f63ab6ab083c34395e9d1ad7768ad1f5120aa.1538044725.git.anatoly.burakov@intel.com/mbox/", "series": [ { "id": 1543, "url": "http://patches.dpdk.org/api/series/1543/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1543", "date": "2018-09-27T10:40:57", "name": "Support externally allocated memory in DPDK", "version": 6, "mbox": "http://patches.dpdk.org/series/1543/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/45494/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/45494/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 109421B19E;\n\tThu, 27 Sep 2018 12:41:43 +0200 (CEST)", "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id DFD231B136\n\tfor <dev@dpdk.org>; Thu, 27 Sep 2018 12:41:28 +0200 (CEST)", "from fmsmga008.fm.intel.com ([10.253.24.58])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t27 Sep 2018 03:41:28 -0700", "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby fmsmga008.fm.intel.com with ESMTP; 27 Sep 2018 03:41:24 -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\tw8RAfOf2028387; Thu, 27 Sep 2018 11:41:24 +0100", "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w8RAfO0G022788;\n\tThu, 27 Sep 2018 11:41:24 +0100", "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w8RAfOhb022784;\n\tThu, 27 Sep 2018 11:41:24 +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,310,1534834800\"; d=\"scan'208\";a=\"74133734\"", "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,\n\tarybchenko@solarflare.com, alejandro.lucero@netronome.com", "Date": "Thu, 27 Sep 2018 11:41:09 +0100", "Message-Id": "<ea1f63ab6ab083c34395e9d1ad7768ad1f5120aa.1538044725.git.anatoly.burakov@intel.com>", "X-Mailer": "git-send-email 1.7.0.7", "In-Reply-To": [ "<cover.1538044725.git.anatoly.burakov@intel.com>", "<cover.1538044725.git.anatoly.burakov@intel.com>" ], "References": [ "<cover.1538044725.git.anatoly.burakov@intel.com>", "<cover.1537960448.git.anatoly.burakov@intel.com>\n\t<cover.1538044725.git.anatoly.burakov@intel.com>" ], "Subject": "[dpdk-dev] [PATCH v6 12/21] malloc: allow destroying 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 an API to destroy specified heap.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n lib/librte_eal/common/include/rte_malloc.h | 23 +++++++++\n lib/librte_eal/common/malloc_heap.c | 22 ++++++++\n lib/librte_eal/common/malloc_heap.h | 3 ++\n lib/librte_eal/common/rte_malloc.c | 58 ++++++++++++++++++++++\n lib/librte_eal/rte_eal_version.map | 1 +\n 5 files changed, 107 insertions(+)", "diff": "diff --git a/lib/librte_eal/common/include/rte_malloc.h b/lib/librte_eal/common/include/rte_malloc.h\nindex e326529d0..309bbbcc9 100644\n--- a/lib/librte_eal/common/include/rte_malloc.h\n+++ b/lib/librte_eal/common/include/rte_malloc.h\n@@ -282,6 +282,29 @@ rte_malloc_get_socket_stats(int socket,\n int __rte_experimental\n rte_malloc_heap_create(const char *heap_name);\n \n+/**\n+ * Destroys a previously created malloc heap with specified name.\n+ *\n+ * @note This function will return a failure result if not all memory allocated\n+ * from the heap has been freed back to the heap\n+ *\n+ * @note This function will return a failure result if not all memory segments\n+ * were removed from the heap prior to its destruction\n+ *\n+ * @param heap_name\n+ * Name of the heap to create.\n+ *\n+ * @return\n+ * - 0 on success\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+ * ENOENT - heap by the name of ``heap_name`` was not found\n+ * EPERM - attempting to destroy reserved heap\n+ * EBUSY - heap still contains data\n+ */\n+int __rte_experimental\n+rte_malloc_heap_destroy(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 987b83fb8..b51390210 100644\n--- a/lib/librte_eal/common/malloc_heap.c\n+++ b/lib/librte_eal/common/malloc_heap.c\n@@ -1049,6 +1049,28 @@ malloc_heap_create(struct malloc_heap *heap, const char *heap_name)\n \treturn 0;\n }\n \n+int\n+malloc_heap_destroy(struct malloc_heap *heap)\n+{\n+\tif (heap->alloc_count != 0) {\n+\t\tRTE_LOG(ERR, EAL, \"Heap is still in use\\n\");\n+\t\trte_errno = EBUSY;\n+\t\treturn -1;\n+\t}\n+\tif (heap->first != NULL || heap->last != NULL) {\n+\t\tRTE_LOG(ERR, EAL, \"Heap still contains memory segments\\n\");\n+\t\trte_errno = EBUSY;\n+\t\treturn -1;\n+\t}\n+\tif (heap->total_size != 0)\n+\t\tRTE_LOG(ERR, EAL, \"Total size not zero, heap is likely corrupt\\n\");\n+\n+\t/* after this, the lock will be dropped */\n+\tmemset(heap, 0, sizeof(*heap));\n+\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 eebee16dc..75278da3c 100644\n--- a/lib/librte_eal/common/malloc_heap.h\n+++ b/lib/librte_eal/common/malloc_heap.h\n@@ -36,6 +36,9 @@ malloc_heap_alloc_biggest(const char *type, int socket, unsigned int flags,\n int\n malloc_heap_create(struct malloc_heap *heap, const char *heap_name);\n \n+int\n+malloc_heap_destroy(struct malloc_heap *heap);\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 25967a7cb..286e748ef 100644\n--- a/lib/librte_eal/common/rte_malloc.c\n+++ b/lib/librte_eal/common/rte_malloc.c\n@@ -313,6 +313,21 @@ rte_malloc_virt2iova(const void *addr)\n \treturn ms->iova + RTE_PTR_DIFF(addr, ms->addr);\n }\n \n+static struct malloc_heap *\n+find_named_heap(const char *name)\n+{\n+\tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n+\tunsigned int i;\n+\n+\tfor (i = 0; i < RTE_MAX_HEAPS; i++) {\n+\t\tstruct malloc_heap *heap = &mcfg->malloc_heaps[i];\n+\n+\t\tif (!strncmp(name, heap->name, RTE_HEAP_NAME_MAX_LEN))\n+\t\t\treturn heap;\n+\t}\n+\treturn NULL;\n+}\n+\n int\n rte_malloc_heap_create(const char *heap_name)\n {\n@@ -363,3 +378,46 @@ rte_malloc_heap_create(const char *heap_name)\n \n \treturn ret;\n }\n+\n+int\n+rte_malloc_heap_destroy(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 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+\trte_rwlock_write_lock(&mcfg->memory_hotplug_lock);\n+\n+\t/* start from non-socket heaps */\n+\theap = find_named_heap(heap_name);\n+\tif (heap == NULL) {\n+\t\tRTE_LOG(ERR, EAL, \"Heap %s not found\\n\", heap_name);\n+\t\trte_errno = ENOENT;\n+\t\tret = -1;\n+\t\tgoto unlock;\n+\t}\n+\t/* we shouldn't be able to destroy internal heaps */\n+\tif (heap->socket_id < RTE_MAX_NUMA_NODES) {\n+\t\trte_errno = EPERM;\n+\t\tret = -1;\n+\t\tgoto unlock;\n+\t}\n+\t/* sanity checks done, now we can destroy the heap */\n+\trte_spinlock_lock(&heap->lock);\n+\tret = malloc_heap_destroy(heap);\n+\n+\t/* if we failed, lock is still active */\n+\tif (ret < 0)\n+\t\trte_spinlock_unlock(&heap->lock);\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 376f33bbb..27aac5bea 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -319,6 +319,7 @@ EXPERIMENTAL {\n \trte_log_register_type_and_pick_level;\n \trte_malloc_dump_heaps;\n \trte_malloc_heap_create;\n+\trte_malloc_heap_destroy;\n \trte_malloc_heap_get_socket;\n \trte_malloc_heap_socket_is_external;\n \trte_mem_alloc_validator_register;\n", "prefixes": [ "v6", "12/21" ] }{ "id": 45494, "url": "