get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/45015/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 45015,
    "url": "http://patches.dpdk.org/api/patches/45015/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/9ff60fe7919d1dec01fdbda2f4f724c047eec2bd.1537443103.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": "<9ff60fe7919d1dec01fdbda2f4f724c047eec2bd.1537443103.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/9ff60fe7919d1dec01fdbda2f4f724c047eec2bd.1537443103.git.anatoly.burakov@intel.com",
    "date": "2018-09-20T11:36:24",
    "name": "[v3,11/20] malloc: allow destroying heaps",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "eb27579ba2340d5a26827480fcb9bc6a00548f0c",
    "submitter": {
        "id": 4,
        "url": "http://patches.dpdk.org/api/people/4/?format=api",
        "name": "Burakov, Anatoly",
        "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/9ff60fe7919d1dec01fdbda2f4f724c047eec2bd.1537443103.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 1415,
            "url": "http://patches.dpdk.org/api/series/1415/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1415",
            "date": "2018-09-20T11:36:13",
            "name": "Support externally allocated memory in DPDK",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/1415/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/45015/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/45015/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 B6F241B0FF;\n\tThu, 20 Sep 2018 13:36:57 +0200 (CEST)",
            "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby dpdk.org (Postfix) with ESMTP id 024965F27\n\tfor <dev@dpdk.org>; Thu, 20 Sep 2018 13:36:44 +0200 (CEST)",
            "from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t20 Sep 2018 04:36:44 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby fmsmga006.fm.intel.com with ESMTP; 20 Sep 2018 04:36:40 -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\tw8KBaeSb022828; Thu, 20 Sep 2018 12:36:40 +0100",
            "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w8KBaev8011531;\n\tThu, 20 Sep 2018 12:36:40 +0100",
            "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w8KBaeZb011521;\n\tThu, 20 Sep 2018 12:36:40 +0100"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.53,398,1531810800\"; d=\"scan'208\";a=\"265202969\"",
        "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": "Thu, 20 Sep 2018 12:36:24 +0100",
        "Message-Id": "<9ff60fe7919d1dec01fdbda2f4f724c047eec2bd.1537443103.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": [
            "<cover.1537443103.git.anatoly.burakov@intel.com>",
            "<cover.1537443103.git.anatoly.burakov@intel.com>"
        ],
        "References": [
            "<cover.1537443103.git.anatoly.burakov@intel.com>",
            "<cover.1537363686.git.anatoly.burakov@intel.com>\n\t<cover.1537443103.git.anatoly.burakov@intel.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH v3 11/20] 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 182afab1c..8a8cc1e6d 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 1dd4ffcf9..e98f720cb 100644\n--- a/lib/librte_eal/common/malloc_heap.c\n+++ b/lib/librte_eal/common/malloc_heap.c\n@@ -1045,6 +1045,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 39875fe69..6734b0d09 100644\n--- a/lib/librte_eal/common/rte_malloc.c\n+++ b/lib/librte_eal/common/rte_malloc.c\n@@ -288,6 +288,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@@ -338,3 +353,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 d1e92361b..7db38c8ac 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_mem_alloc_validator_register;\n \trte_mem_alloc_validator_unregister;\n",
    "prefixes": [
        "v3",
        "11/20"
    ]
}