get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 44230,
    "url": "http://patchwork.dpdk.org/api/patches/44230/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/bd0158f96c9fd0d13eebccd535e74e38653f29a7.1536064999.git.anatoly.burakov@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.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": "<bd0158f96c9fd0d13eebccd535e74e38653f29a7.1536064999.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/bd0158f96c9fd0d13eebccd535e74e38653f29a7.1536064999.git.anatoly.burakov@intel.com",
    "date": "2018-09-04T13:11:46",
    "name": "[11/16] malloc: allow destroying heaps",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "eb27579ba2340d5a26827480fcb9bc6a00548f0c",
    "submitter": {
        "id": 4,
        "url": "http://patchwork.dpdk.org/api/people/4/?format=api",
        "name": "Anatoly Burakov",
        "email": "anatoly.burakov@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/bd0158f96c9fd0d13eebccd535e74e38653f29a7.1536064999.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 1170,
            "url": "http://patchwork.dpdk.org/api/series/1170/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=1170",
            "date": "2018-09-04T13:11:35",
            "name": "Support externally allocated memory in DPDK",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/1170/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/44230/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/44230/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 B39BB5B16;\n\tTue,  4 Sep 2018 15:12:11 +0200 (CEST)",
            "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n\tby dpdk.org (Postfix) with ESMTP id 54E124F93\n\tfor <dev@dpdk.org>; Tue,  4 Sep 2018 15:12:06 +0200 (CEST)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t04 Sep 2018 06:11:57 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby fmsmga001.fm.intel.com with ESMTP; 04 Sep 2018 06:11:54 -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\tw84DBse7023378; Tue, 4 Sep 2018 14:11:54 +0100",
            "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w84DBrG3024686;\n\tTue, 4 Sep 2018 14:11:53 +0100",
            "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w84DBrRF024676;\n\tTue, 4 Sep 2018 14:11:53 +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,329,1531810800\"; d=\"scan'208\";a=\"87028572\"",
        "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\tsrinath.mannam@broadcom.com, scott.branden@broadcom.com,\n\tajit.khaparde@broadcom.com, keith.wiles@intel.com,\n\tbruce.richardson@intel.com, thomas@monjalon.net",
        "Date": "Tue,  4 Sep 2018 14:11:46 +0100",
        "Message-Id": "<bd0158f96c9fd0d13eebccd535e74e38653f29a7.1536064999.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": [
            "<cover.1536064999.git.anatoly.burakov@intel.com>",
            "<cover.1536064999.git.anatoly.burakov@intel.com>"
        ],
        "References": [
            "<cover.1536064999.git.anatoly.burakov@intel.com>",
            "<cover.1536064999.git.anatoly.burakov@intel.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH 11/16] 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 2742f7b11..471094cd1 100644\n--- a/lib/librte_eal/common/malloc_heap.c\n+++ b/lib/librte_eal/common/malloc_heap.c\n@@ -1036,6 +1036,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 ade5af406..d135f9730 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 c93dcf1a3..1d3ca0716 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -312,6 +312,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": [
        "11/16"
    ]
}