get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 45129,
    "url": "http://patches.dpdk.org/api/patches/45129/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/23121a0c02d2ec5fa587d231b8952bba93462666.1537546029.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": "<23121a0c02d2ec5fa587d231b8952bba93462666.1537546029.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/23121a0c02d2ec5fa587d231b8952bba93462666.1537546029.git.anatoly.burakov@intel.com",
    "date": "2018-09-21T16:14:06",
    "name": "[v4,17/20] test: add unit tests for external memory support",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "8141d402d44d4eef23b068f98d7db6246e7dc704",
    "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/23121a0c02d2ec5fa587d231b8952bba93462666.1537546029.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 1446,
            "url": "http://patches.dpdk.org/api/series/1446/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1446",
            "date": "2018-09-21T16:13:49",
            "name": "Support externally allocated memory in DPDK",
            "version": 4,
            "mbox": "http://patches.dpdk.org/series/1446/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/45129/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/45129/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 20B8D5F32;\n\tFri, 21 Sep 2018 18:14:35 +0200 (CEST)",
            "from mga18.intel.com (mga18.intel.com [134.134.136.126])\n\tby dpdk.org (Postfix) with ESMTP id 376F95F28\n\tfor <dev@dpdk.org>; Fri, 21 Sep 2018 18:14:17 +0200 (CEST)",
            "from orsmga002.jf.intel.com ([10.7.209.21])\n\tby orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t21 Sep 2018 09:14:16 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby orsmga002.jf.intel.com with ESMTP; 21 Sep 2018 09:14:13 -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\tw8LGECYW029231; Fri, 21 Sep 2018 17:14:12 +0100",
            "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w8LGECsc002926;\n\tFri, 21 Sep 2018 17:14:12 +0100",
            "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w8LGECLA002922;\n\tFri, 21 Sep 2018 17:14:12 +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=\"93761615\"",
        "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:06 +0100",
        "Message-Id": "<23121a0c02d2ec5fa587d231b8952bba93462666.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 17/20] test: add unit tests for external\n\tmemory support",
        "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 simple unit tests to test external memory support.\nThe tests are pretty basic and mostly consist of checking\nif invalid API calls are handled correctly, plus a simple\nallocation/deallocation test for malloc and memzone.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n test/test/Makefile            |   1 +\n test/test/autotest_data.py    |  14 +-\n test/test/meson.build         |   1 +\n test/test/test_external_mem.c | 389 ++++++++++++++++++++++++++++++++++\n 4 files changed, 401 insertions(+), 4 deletions(-)\n create mode 100644 test/test/test_external_mem.c",
    "diff": "diff --git a/test/test/Makefile b/test/test/Makefile\nindex e6967bab6..074ac6e03 100644\n--- a/test/test/Makefile\n+++ b/test/test/Makefile\n@@ -71,6 +71,7 @@ SRCS-y += test_bitmap.c\n SRCS-y += test_reciprocal_division.c\n SRCS-y += test_reciprocal_division_perf.c\n SRCS-y += test_fbarray.c\n+SRCS-y += test_external_mem.c\n \n SRCS-y += test_ring.c\n SRCS-y += test_ring_perf.c\ndiff --git a/test/test/autotest_data.py b/test/test/autotest_data.py\nindex f68d9b111..51f8e1689 100644\n--- a/test/test/autotest_data.py\n+++ b/test/test/autotest_data.py\n@@ -477,10 +477,16 @@\n         \"Report\":  None,\n     },\n     {\n-        \"Name\":    \"Fbarray autotest\",\n-        \"Command\": \"fbarray_autotest\",\n-        \"Func\":    default_autotest,\n-        \"Report\":  None,\n+\t\"Name\":    \"Fbarray autotest\",\n+\t\"Command\": \"fbarray_autotest\",\n+\t\"Func\":    default_autotest,\n+\t\"Report\":  None,\n+    },\n+    {\n+\t\"Name\":    \"External memory autotest\",\n+\t\"Command\": \"external_mem_autotest\",\n+\t\"Func\":    default_autotest,\n+\t\"Report\":  None,\n     },\n     #\n     #Please always keep all dump tests at the end and together!\ndiff --git a/test/test/meson.build b/test/test/meson.build\nindex b1dd6eca2..3abf02b71 100644\n--- a/test/test/meson.build\n+++ b/test/test/meson.build\n@@ -155,6 +155,7 @@ test_names = [\n \t'eventdev_common_autotest',\n \t'eventdev_octeontx_autotest',\n \t'eventdev_sw_autotest',\n+\t'external_mem_autotest',\n \t'func_reentrancy_autotest',\n \t'flow_classify_autotest',\n \t'hash_scaling_autotest',\ndiff --git a/test/test/test_external_mem.c b/test/test/test_external_mem.c\nnew file mode 100644\nindex 000000000..d0837aa35\n--- /dev/null\n+++ b/test/test/test_external_mem.c\n@@ -0,0 +1,389 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2018 Intel Corporation\n+ */\n+\n+#include <errno.h>\n+#include <stdio.h>\n+#include <stdlib.h>\n+#include <string.h>\n+#include <fcntl.h>\n+#include <sys/mman.h>\n+#include <sys/wait.h>\n+\n+#include <rte_common.h>\n+#include <rte_debug.h>\n+#include <rte_eal.h>\n+#include <rte_errno.h>\n+#include <rte_malloc.h>\n+#include <rte_ring.h>\n+#include <rte_string_fns.h>\n+\n+#include \"test.h\"\n+\n+#define EXTERNAL_MEM_SZ (RTE_PGSIZE_4K << 10) /* 4M of data */\n+\n+static int\n+test_invalid_param(void *addr, size_t len, size_t pgsz, rte_iova_t *iova,\n+\t\tint n_pages)\n+{\n+\tstatic const char * const names[] = {\n+\t\tNULL, /* NULL name */\n+\t\t\"\",   /* empty name */\n+\t\t\"this heap name is definitely way too long to be valid\"\n+\t};\n+\tconst char *valid_name = \"valid heap name\";\n+\tunsigned int i;\n+\n+\t/* check invalid name handling */\n+\tfor (i = 0; i < RTE_DIM(names); i++) {\n+\t\tconst char *name = names[i];\n+\n+\t\t/* these calls may fail for other reasons, so check errno */\n+\t\tif (rte_malloc_heap_create(name) >= 0 || rte_errno != EINVAL) {\n+\t\t\tprintf(\"%s():%i: Created heap with invalid name\\n\",\n+\t\t\t\t\t__func__, __LINE__);\n+\t\t\tgoto fail;\n+\t\t}\n+\n+\t\tif (rte_malloc_heap_destroy(name) >= 0 || rte_errno != EINVAL) {\n+\t\t\tprintf(\"%s():%i: Destroyed heap with invalid name\\n\",\n+\t\t\t\t\t__func__, __LINE__);\n+\t\t\tgoto fail;\n+\t\t}\n+\n+\t\tif (rte_malloc_heap_get_socket(name) >= 0 ||\n+\t\t\t\trte_errno != EINVAL) {\n+\t\t\tprintf(\"%s():%i: Found socket for heap with invalid name\\n\",\n+\t\t\t\t\t__func__, __LINE__);\n+\t\t\tgoto fail;\n+\t\t}\n+\n+\t\tif (rte_malloc_heap_memory_add(name, addr, len,\n+\t\t\t\tNULL, 0, pgsz) >= 0 || rte_errno != EINVAL) {\n+\t\t\tprintf(\"%s():%i: Added memory to heap with invalid name\\n\",\n+\t\t\t\t\t__func__, __LINE__);\n+\t\t\tgoto fail;\n+\t\t}\n+\t\tif (rte_malloc_heap_memory_remove(name, addr, len) >= 0 ||\n+\t\t\t\trte_errno != EINVAL) {\n+\t\t\tprintf(\"%s():%i: Removed memory from heap with invalid name\\n\",\n+\t\t\t\t\t__func__, __LINE__);\n+\t\t\tgoto fail;\n+\t\t}\n+\n+\t\tif (rte_malloc_heap_memory_attach(name, addr, len) >= 0 ||\n+\t\t\t\trte_errno != EINVAL) {\n+\t\t\tprintf(\"%s():%i: Attached memory to heap with invalid name\\n\",\n+\t\t\t\t__func__, __LINE__);\n+\t\t\tgoto fail;\n+\t\t}\n+\t\tif (rte_malloc_heap_memory_detach(name, addr, len) >= 0 ||\n+\t\t\t\trte_errno != EINVAL) {\n+\t\t\tprintf(\"%s():%i: Detached memory from heap with invalid name\\n\",\n+\t\t\t\t__func__, __LINE__);\n+\t\t\tgoto fail;\n+\t\t}\n+\t}\n+\n+\t/* do same as above, but with a valid heap name */\n+\n+\t/* skip create call */\n+\tif (rte_malloc_heap_destroy(valid_name) >= 0 || rte_errno != ENOENT) {\n+\t\tprintf(\"%s():%i: Destroyed heap with invalid name\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\tif (rte_malloc_heap_get_socket(valid_name) >= 0 ||\n+\t\t\trte_errno != ENOENT) {\n+\t\tprintf(\"%s():%i: Found socket for heap with invalid name\\n\",\n+\t\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* these calls may fail for other reasons, so check errno */\n+\tif (rte_malloc_heap_memory_add(valid_name, addr, len,\n+\t\t\tNULL, 0, pgsz) >= 0 || rte_errno != ENOENT) {\n+\t\tprintf(\"%s():%i: Added memory to non-existent heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\tif (rte_malloc_heap_memory_remove(valid_name, addr, len) >= 0 ||\n+\t\t\trte_errno != ENOENT) {\n+\t\tprintf(\"%s():%i: Removed memory from non-existent heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\tif (rte_malloc_heap_memory_attach(valid_name, addr, len) >= 0 ||\n+\t\t\trte_errno != ENOENT) {\n+\t\tprintf(\"%s():%i: Attached memory to non-existent heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\tif (rte_malloc_heap_memory_detach(valid_name, addr, len) >= 0 ||\n+\t\t\trte_errno != ENOENT) {\n+\t\tprintf(\"%s():%i: Detached memory from non-existent heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* create a valid heap but test other invalid parameters */\n+\tif (rte_malloc_heap_create(valid_name) != 0) {\n+\t\tprintf(\"%s():%i: Failed to create valid heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* zero length */\n+\tif (rte_malloc_heap_memory_add(valid_name, addr, 0,\n+\t\t\tNULL, 0, pgsz) >= 0 || rte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Added memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\tif (rte_malloc_heap_memory_remove(valid_name, addr, 0) >= 0 ||\n+\t\t\trte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Removed memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\tif (rte_malloc_heap_memory_attach(valid_name, addr, 0) >= 0 ||\n+\t\t\trte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Attached memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\tif (rte_malloc_heap_memory_detach(valid_name, addr, 0) >= 0 ||\n+\t\t\trte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Detached memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* zero address */\n+\tif (rte_malloc_heap_memory_add(valid_name, NULL, len,\n+\t\t\tNULL, 0, pgsz) >= 0 || rte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Added memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\tif (rte_malloc_heap_memory_remove(valid_name, NULL, len) >= 0 ||\n+\t\t\trte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Removed memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\tif (rte_malloc_heap_memory_attach(valid_name, NULL, len) >= 0 ||\n+\t\t\trte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Attached memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\tif (rte_malloc_heap_memory_detach(valid_name, NULL, len) >= 0 ||\n+\t\t\trte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Detached memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* wrong page count */\n+\tif (rte_malloc_heap_memory_add(valid_name, addr, len,\n+\t\t\tiova, 0, pgsz) >= 0 || rte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Added memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\tif (rte_malloc_heap_memory_add(valid_name, addr, len,\n+\t\t\tiova, n_pages - 1, pgsz) >= 0 || rte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Added memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\tif (rte_malloc_heap_memory_add(valid_name, addr, len,\n+\t\t\tiova, n_pages + 1, pgsz) >= 0 || rte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Added memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* tests passed, destroy heap */\n+\tif (rte_malloc_heap_destroy(valid_name) != 0) {\n+\t\tprintf(\"%s():%i: Failed to destroy valid heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\treturn 0;\n+fail:\n+\trte_malloc_heap_destroy(valid_name);\n+\treturn -1;\n+}\n+\n+static int\n+test_basic(void *addr, size_t len, size_t pgsz, rte_iova_t *iova, int n_pages)\n+{\n+\tconst char *heap_name = \"heap\";\n+\tvoid *ptr = NULL;\n+\tint socket_id, i;\n+\tconst struct rte_memzone *mz = NULL;\n+\n+\t/* create heap */\n+\tif (rte_malloc_heap_create(heap_name) != 0) {\n+\t\tprintf(\"%s():%i: Failed to create malloc heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* get socket ID corresponding to this heap */\n+\tsocket_id = rte_malloc_heap_get_socket(heap_name);\n+\tif (socket_id < 0) {\n+\t\tprintf(\"%s():%i: cannot find socket for external heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* heap is empty, so any allocation should fail */\n+\tptr = rte_malloc_socket(\"EXTMEM\", 64, 0, socket_id);\n+\tif (ptr != NULL) {\n+\t\tprintf(\"%s():%i: Allocated from empty heap\\n\", __func__,\n+\t\t\t__LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* add memory to heap */\n+\tif (rte_malloc_heap_memory_add(heap_name, addr, len,\n+\t\t\tiova, n_pages, pgsz) != 0) {\n+\t\tprintf(\"%s():%i: Failed to add memory to heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* check that we can get this memory from EAL now */\n+\tfor (i = 0; i < n_pages; i++) {\n+\t\tconst struct rte_memseg *ms;\n+\t\tvoid *cur = RTE_PTR_ADD(addr, pgsz * i);\n+\n+\t\tms = rte_mem_virt2memseg(cur, NULL);\n+\t\tif (ms == NULL) {\n+\t\t\tprintf(\"%s():%i: Failed to retrieve memseg for external mem\\n\",\n+\t\t\t\t__func__, __LINE__);\n+\t\t\tgoto fail;\n+\t\t}\n+\t\tif (ms->addr != cur) {\n+\t\t\tprintf(\"%s():%i: VA mismatch\\n\", __func__, __LINE__);\n+\t\t\tgoto fail;\n+\t\t}\n+\t\tif (ms->iova != iova[i]) {\n+\t\t\tprintf(\"%s():%i: IOVA mismatch\\n\", __func__, __LINE__);\n+\t\t\tgoto fail;\n+\t\t}\n+\t}\n+\n+\t/* allocate - this now should succeed */\n+\tptr = rte_malloc_socket(\"EXTMEM\", 64, 0, socket_id);\n+\tif (ptr == NULL) {\n+\t\tprintf(\"%s():%i: Failed to allocate from external heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* check if address is in expected range */\n+\tif (ptr < addr || ptr >= RTE_PTR_ADD(addr, len)) {\n+\t\tprintf(\"%s():%i: Allocated from unexpected address space\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* we've allocated something - removing memory should fail */\n+\tif (rte_malloc_heap_memory_remove(heap_name, addr, len) >= 0 ||\n+\t\t\trte_errno != EBUSY) {\n+\t\tprintf(\"%s():%i: Removing memory succeeded when memory is not free\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\tif (rte_malloc_heap_destroy(heap_name) >= 0 || rte_errno != EBUSY) {\n+\t\tprintf(\"%s():%i: Destroying heap succeeded when memory is not free\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* try allocating an IOVA-contiguous memzone - this should succeed\n+\t * because we've set up a contiguous IOVA table.\n+\t */\n+\tmz = rte_memzone_reserve(\"heap_test\", pgsz * 2, socket_id,\n+\t\t\tRTE_MEMZONE_IOVA_CONTIG);\n+\tif (mz == NULL) {\n+\t\tprintf(\"%s():%i: Failed to reserve memzone\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\trte_malloc_dump_stats(stdout, NULL);\n+\trte_malloc_dump_heaps(stdout);\n+\n+\t/* free memory - removing it should now succeed */\n+\trte_free(ptr);\n+\tptr = NULL;\n+\n+\trte_memzone_free(mz);\n+\tmz = NULL;\n+\n+\tif (rte_malloc_heap_memory_remove(heap_name, addr, len) != 0) {\n+\t\tprintf(\"%s():%i: Removing memory from heap failed\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\tif (rte_malloc_heap_destroy(heap_name) != 0) {\n+\t\tprintf(\"%s():%i: Destroying heap failed\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\treturn 0;\n+fail:\n+\trte_memzone_free(mz);\n+\trte_free(ptr);\n+\t/* even if something failed, attempt to clean up */\n+\trte_malloc_heap_memory_remove(heap_name, addr, len);\n+\trte_malloc_heap_destroy(heap_name);\n+\n+\treturn -1;\n+}\n+\n+/* we need to test attach/detach in secondary processes. */\n+static int\n+test_external_mem(void)\n+{\n+\tsize_t len = EXTERNAL_MEM_SZ;\n+\tsize_t pgsz = RTE_PGSIZE_4K;\n+\trte_iova_t iova[len / pgsz];\n+\tvoid *addr;\n+\tint ret, n_pages;\n+\n+\t/* create external memory area */\n+\tn_pages = RTE_DIM(iova);\n+\taddr = mmap(NULL, len, PROT_WRITE | PROT_READ,\n+\t\t\tMAP_ANONYMOUS | MAP_PRIVATE, -1, 0);\n+\tif (addr == MAP_FAILED) {\n+\t\tprintf(\"%s():%i: Failed to create dummy memory area\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\tfor (int i = 0; i < n_pages; i++) {\n+\t\t/* arbitrary IOVA */\n+\t\trte_iova_t tmp = 0x100000000 + i * pgsz;\n+\t\tiova[i] = tmp;\n+\t}\n+\n+\tret = test_invalid_param(addr, len, pgsz, iova, n_pages);\n+\tret |= test_basic(addr, len, pgsz, iova, n_pages);\n+\n+\tmunmap(addr, len);\n+\n+\treturn ret;\n+}\n+\n+REGISTER_TEST_COMMAND(external_mem_autotest, test_external_mem);\n",
    "prefixes": [
        "v4",
        "17/20"
    ]
}