get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 5784,
    "url": "https://patches.dpdk.org/api/patches/5784/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1435241155-23684-4-git-send-email-sergio.gonzalez.monroy@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": "<1435241155-23684-4-git-send-email-sergio.gonzalez.monroy@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1435241155-23684-4-git-send-email-sergio.gonzalez.monroy@intel.com",
    "date": "2015-06-25T14:05:49",
    "name": "[dpdk-dev,v4,3/9] app/test: update malloc/memzone unit tests",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "bfbca40ad06bb93c6f7d0bc178055ee6a46b80ab",
    "submitter": {
        "id": 73,
        "url": "https://patches.dpdk.org/api/people/73/?format=api",
        "name": "Sergio Gonzalez Monroy",
        "email": "sergio.gonzalez.monroy@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1435241155-23684-4-git-send-email-sergio.gonzalez.monroy@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/5784/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/5784/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 [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 81F4BC68A;\n\tThu, 25 Jun 2015 16:06:14 +0200 (CEST)",
            "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n\tby dpdk.org (Postfix) with ESMTP id 4FC51C604\n\tfor <dev@dpdk.org>; Thu, 25 Jun 2015 16:05:59 +0200 (CEST)",
            "from orsmga001.jf.intel.com ([10.7.209.18])\n\tby orsmga102.jf.intel.com with ESMTP; 25 Jun 2015 07:05:57 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby orsmga001.jf.intel.com with ESMTP; 25 Jun 2015 07:05:56 -0700",
            "from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com\n\t[10.237.217.46])\n\tby irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id\n\tt5PE5twB010502 for <dev@dpdk.org>; Thu, 25 Jun 2015 15:05:56 +0100",
            "from sivswdev02.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev02.ir.intel.com with ESMTP id t5PE5tQJ023766\n\tfor <dev@dpdk.org>; Thu, 25 Jun 2015 15:05:55 +0100",
            "(from smonroy@localhost)\n\tby sivswdev02.ir.intel.com with  id t5PE5taL023762\n\tfor dev@dpdk.org; Thu, 25 Jun 2015 15:05:55 +0100"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.13,677,1427785200\"; d=\"scan'208\";a=\"717529315\"",
        "From": "Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Thu, 25 Jun 2015 15:05:49 +0100",
        "Message-Id": "<1435241155-23684-4-git-send-email-sergio.gonzalez.monroy@intel.com>",
        "X-Mailer": "git-send-email 1.8.5.4",
        "In-Reply-To": "<1435241155-23684-1-git-send-email-sergio.gonzalez.monroy@intel.com>",
        "References": "<1433586732-28217-1-git-send-email-sergio.gonzalez.monroy@intel.com>\n\t<1435241155-23684-1-git-send-email-sergio.gonzalez.monroy@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v4 3/9] app/test: update malloc/memzone unit tests",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Some unit test are not relevant anymore. It is the case of those malloc\nUTs that checked corner cases when allocating MALLOC_MEMZONE_SIZE\nchunks, and the case of those memzone UTs relaying of specific free\nmemsegs of rhte reserved memzone.\n\nOther UTs just need to be update, for example, to calculate maximum free\nblock size available.\n\nSigned-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>\n---\n app/test/test_malloc.c  |  86 ----------\n app/test/test_memzone.c | 440 ++++--------------------------------------------\n 2 files changed, 35 insertions(+), 491 deletions(-)",
    "diff": "diff --git a/app/test/test_malloc.c b/app/test/test_malloc.c\nindex ea6f651..a04a751 100644\n--- a/app/test/test_malloc.c\n+++ b/app/test/test_malloc.c\n@@ -56,10 +56,6 @@\n \n #define N 10000\n \n-#define QUOTE_(x) #x\n-#define QUOTE(x) QUOTE_(x)\n-#define MALLOC_MEMZONE_SIZE QUOTE(RTE_MALLOC_MEMZONE_SIZE)\n-\n /*\n  * Malloc\n  * ======\n@@ -292,60 +288,6 @@ test_str_to_size(void)\n }\n \n static int\n-test_big_alloc(void)\n-{\n-\tint socket = 0;\n-\tstruct rte_malloc_socket_stats pre_stats, post_stats;\n-\tsize_t size =rte_str_to_size(MALLOC_MEMZONE_SIZE)*2;\n-\tint align = 0;\n-#ifndef RTE_LIBRTE_MALLOC_DEBUG\n-\tint overhead = RTE_CACHE_LINE_SIZE + RTE_CACHE_LINE_SIZE;\n-#else\n-\tint overhead = RTE_CACHE_LINE_SIZE + RTE_CACHE_LINE_SIZE + RTE_CACHE_LINE_SIZE;\n-#endif\n-\n-\trte_malloc_get_socket_stats(socket, &pre_stats);\n-\n-\tvoid *p1 = rte_malloc_socket(\"BIG\", size , align, socket);\n-\tif (!p1)\n-\t\treturn -1;\n-\trte_malloc_get_socket_stats(socket,&post_stats);\n-\n-\t/* Check statistics reported are correct */\n-\t/* Allocation may increase, or may be the same as before big allocation */\n-\tif (post_stats.heap_totalsz_bytes < pre_stats.heap_totalsz_bytes) {\n-\t\tprintf(\"Malloc statistics are incorrect - heap_totalsz_bytes\\n\");\n-\t\treturn -1;\n-\t}\n-\t/* Check that allocated size adds up correctly */\n-\tif (post_stats.heap_allocsz_bytes !=\n-\t\t\tpre_stats.heap_allocsz_bytes + size + align + overhead) {\n-\t\tprintf(\"Malloc statistics are incorrect - alloc_size\\n\");\n-\t\treturn -1;\n-\t}\n-\t/* Check free size against tested allocated size */\n-\tif (post_stats.heap_freesz_bytes !=\n-\t\t\tpost_stats.heap_totalsz_bytes - post_stats.heap_allocsz_bytes) {\n-\t\tprintf(\"Malloc statistics are incorrect - heap_freesz_bytes\\n\");\n-\t\treturn -1;\n-\t}\n-\t/* Number of allocated blocks must increase after allocation */\n-\tif (post_stats.alloc_count != pre_stats.alloc_count + 1) {\n-\t\tprintf(\"Malloc statistics are incorrect - alloc_count\\n\");\n-\t\treturn -1;\n-\t}\n-\t/* New blocks now available - just allocated 1 but also 1 new free */\n-\tif (post_stats.free_count != pre_stats.free_count &&\n-\t\t\tpost_stats.free_count != pre_stats.free_count - 1) {\n-\t\tprintf(\"Malloc statistics are incorrect - free_count\\n\");\n-\t\treturn -1;\n-\t}\n-\n-\trte_free(p1);\n-\treturn 0;\n-}\n-\n-static int\n test_multi_alloc_statistics(void)\n {\n \tint socket = 0;\n@@ -399,10 +341,6 @@ test_multi_alloc_statistics(void)\n \t/* After freeing both allocations check stats return to original */\n \trte_malloc_get_socket_stats(socket, &post_stats);\n \n-\t/*\n-\t * Check that no new blocks added after small allocations\n-\t * i.e. < RTE_MALLOC_MEMZONE_SIZE\n-\t */\n \tif(second_stats.heap_totalsz_bytes != first_stats.heap_totalsz_bytes) {\n \t\tprintf(\"Incorrect heap statistics: Total size \\n\");\n \t\treturn -1;\n@@ -447,18 +385,6 @@ test_multi_alloc_statistics(void)\n }\n \n static int\n-test_memzone_size_alloc(void)\n-{\n-\tvoid *p1 = rte_malloc(\"BIG\", (size_t)(rte_str_to_size(MALLOC_MEMZONE_SIZE) - 128), 64);\n-\tif (!p1)\n-\t\treturn -1;\n-\trte_free(p1);\n-\t/* one extra check - check no crashes if free(NULL) */\n-\trte_free(NULL);\n-\treturn 0;\n-}\n-\n-static int\n test_rte_malloc_type_limits(void)\n {\n \t/* The type-limits functionality is not yet implemented,\n@@ -935,18 +861,6 @@ test_malloc(void)\n \t}\n \telse printf(\"test_str_to_size() passed\\n\");\n \n-\tif (test_memzone_size_alloc() < 0){\n-\t\tprintf(\"test_memzone_size_alloc() failed\\n\");\n-\t\treturn -1;\n-\t}\n-\telse printf(\"test_memzone_size_alloc() passed\\n\");\n-\n-\tif (test_big_alloc() < 0){\n-\t\tprintf(\"test_big_alloc() failed\\n\");\n-\t\treturn -1;\n-\t}\n-\telse printf(\"test_big_alloc() passed\\n\");\n-\n \tif (test_zero_aligned_alloc() < 0){\n \t\tprintf(\"test_zero_aligned_alloc() failed\\n\");\n \t\treturn -1;\ndiff --git a/app/test/test_memzone.c b/app/test/test_memzone.c\nindex 9c7a1cb..6934eee 100644\n--- a/app/test/test_memzone.c\n+++ b/app/test/test_memzone.c\n@@ -44,6 +44,9 @@\n #include <rte_eal_memconfig.h>\n #include <rte_common.h>\n #include <rte_string_fns.h>\n+#include <rte_errno.h>\n+#include <rte_malloc.h>\n+#include \"../../lib/librte_eal/common/malloc_elem.h\"\n \n #include \"test.h\"\n \n@@ -378,65 +381,37 @@ test_memzone_reserve_flags(void)\n \treturn 0;\n }\n \n-static int\n-test_memzone_reserve_max(void)\n+\n+/* Find the heap with the greatest free block size */\n+static size_t\n+find_max_block_free_size(const unsigned _align)\n {\n-\tconst struct rte_memzone *mz;\n-\tconst struct rte_config *config;\n-\tconst struct rte_memseg *ms;\n-\tint memseg_idx = 0;\n-\tint memzone_idx = 0;\n+\tstruct rte_malloc_socket_stats stats;\n+\tunsigned i, align = _align;\n \tsize_t len = 0;\n-\tvoid* last_addr;\n-\tsize_t maxlen = 0;\n \n-\t/* get pointer to global configuration */\n-\tconfig = rte_eal_get_configuration();\n+\tfor (i = 0; i < RTE_MAX_NUMA_NODES; i++) {\n+\t\trte_malloc_get_socket_stats(i, &stats);\n+\t\tif (stats.greatest_free_size > len)\n+\t\t\tlen = stats.greatest_free_size;\n+\t}\n \n-\tms = rte_eal_get_physmem_layout();\n+\tif (align < RTE_CACHE_LINE_SIZE)\n+\t\talign = RTE_CACHE_LINE_ROUNDUP(align+1);\n \n-\tfor (memseg_idx = 0; memseg_idx < RTE_MAX_MEMSEG; memseg_idx++){\n-\t\t/* ignore smaller memsegs as they can only get smaller */\n-\t\tif (ms[memseg_idx].len < maxlen)\n-\t\t\tcontinue;\n-\n-\t\t/* align everything */\n-\t\tlast_addr = RTE_PTR_ALIGN_CEIL(ms[memseg_idx].addr, RTE_CACHE_LINE_SIZE);\n-\t\tlen = ms[memseg_idx].len - RTE_PTR_DIFF(last_addr, ms[memseg_idx].addr);\n-\t\tlen &= ~((size_t) RTE_CACHE_LINE_MASK);\n-\n-\t\t/* cycle through all memzones */\n-\t\tfor (memzone_idx = 0; memzone_idx < RTE_MAX_MEMZONE; memzone_idx++) {\n-\n-\t\t\t/* stop when reaching last allocated memzone */\n-\t\t\tif (config->mem_config->memzone[memzone_idx].addr == NULL)\n-\t\t\t\tbreak;\n-\n-\t\t\t/* check if the memzone is in our memseg and subtract length */\n-\t\t\tif ((config->mem_config->memzone[memzone_idx].addr >=\n-\t\t\t     ms[memseg_idx].addr) &&\n-\t\t\t    (config->mem_config->memzone[memzone_idx].addr <\n-\t\t\t     (RTE_PTR_ADD(ms[memseg_idx].addr, ms[memseg_idx].len)))) {\n-\t\t\t\t/* since the zones can now be aligned and occasionally skip\n-\t\t\t\t * some space, we should calculate the length based on\n-\t\t\t\t * reported length and start addresses difference. Addresses\n-\t\t\t\t * are allocated sequentially so we don't need to worry about\n-\t\t\t\t * them being in the right order.\n-\t\t\t\t */\n-\t\t\t\tlen -= RTE_PTR_DIFF(\n-\t\t\t\t\t\t    config->mem_config->memzone[memzone_idx].addr,\n-\t\t\t\t\t\t    last_addr);\n-\t\t\t\tlen -= config->mem_config->memzone[memzone_idx].len;\n-\t\t\t\tlast_addr = RTE_PTR_ADD(config->mem_config->memzone[memzone_idx].addr,\n-\t\t\t\t\t\t\t(size_t) config->mem_config->memzone[memzone_idx].len);\n-\t\t\t}\n-\t\t}\n+\tif (len <= MALLOC_ELEM_OVERHEAD + align)\n+\t\treturn 0;\n \n-\t\t/* we don't need to calculate offset here since length\n-\t\t * is always cache-aligned */\n-\t\tif (len > maxlen)\n-\t\t\tmaxlen = len;\n-\t}\n+\treturn len - MALLOC_ELEM_OVERHEAD - align;\n+}\n+\n+static int\n+test_memzone_reserve_max(void)\n+{\n+\tconst struct rte_memzone *mz;\n+\tsize_t maxlen;\n+\n+\tmaxlen = find_max_block_free_size(0);\n \n \tif (maxlen == 0) {\n \t\tprintf(\"There is no space left!\\n\");\n@@ -445,7 +420,8 @@ test_memzone_reserve_max(void)\n \n \tmz = rte_memzone_reserve(\"max_zone\", 0, SOCKET_ID_ANY, 0);\n \tif (mz == NULL){\n-\t\tprintf(\"Failed to reserve a big chunk of memory\\n\");\n+\t\tprintf(\"Failed to reserve a big chunk of memory - %s\\n\",\n+\t\t\t\trte_strerror(rte_errno));\n \t\trte_dump_physmem_layout(stdout);\n \t\trte_memzone_dump(stdout);\n \t\treturn -1;\n@@ -453,8 +429,7 @@ test_memzone_reserve_max(void)\n \n \tif (mz->len != maxlen) {\n \t\tprintf(\"Memzone reserve with 0 size did not return bigest block\\n\");\n-\t\tprintf(\"Expected size = %zu, actual size = %zu\\n\",\n-\t\t       maxlen, mz->len);\n+\t\tprintf(\"Expected size = %zu, actual size = %zu\\n\", maxlen, mz->len);\n \t\trte_dump_physmem_layout(stdout);\n \t\trte_memzone_dump(stdout);\n \n@@ -467,81 +442,24 @@ static int\n test_memzone_reserve_max_aligned(void)\n {\n \tconst struct rte_memzone *mz;\n-\tconst struct rte_config *config;\n-\tconst struct rte_memseg *ms;\n-\tint memseg_idx = 0;\n-\tint memzone_idx = 0;\n-\tuintptr_t addr_offset;\n-\tsize_t len = 0;\n-\tvoid* last_addr;\n \tsize_t maxlen = 0;\n \n \t/* random alignment */\n \trte_srand((unsigned)rte_rdtsc());\n \tconst unsigned align = 1 << ((rte_rand() % 8) + 5); /* from 128 up to 4k alignment */\n \n-\t/* get pointer to global configuration */\n-\tconfig = rte_eal_get_configuration();\n-\n-\tms = rte_eal_get_physmem_layout();\n-\n-\taddr_offset = 0;\n-\n-\tfor (memseg_idx = 0; memseg_idx < RTE_MAX_MEMSEG; memseg_idx++){\n-\n-\t\t/* ignore smaller memsegs as they can only get smaller */\n-\t\tif (ms[memseg_idx].len < maxlen)\n-\t\t\tcontinue;\n-\n-\t\t/* align everything */\n-\t\tlast_addr = RTE_PTR_ALIGN_CEIL(ms[memseg_idx].addr, RTE_CACHE_LINE_SIZE);\n-\t\tlen = ms[memseg_idx].len - RTE_PTR_DIFF(last_addr, ms[memseg_idx].addr);\n-\t\tlen &= ~((size_t) RTE_CACHE_LINE_MASK);\n-\n-\t\t/* cycle through all memzones */\n-\t\tfor (memzone_idx = 0; memzone_idx < RTE_MAX_MEMZONE; memzone_idx++) {\n-\n-\t\t\t/* stop when reaching last allocated memzone */\n-\t\t\tif (config->mem_config->memzone[memzone_idx].addr == NULL)\n-\t\t\t\tbreak;\n-\n-\t\t\t/* check if the memzone is in our memseg and subtract length */\n-\t\t\tif ((config->mem_config->memzone[memzone_idx].addr >=\n-\t\t\t\t\tms[memseg_idx].addr) &&\n-\t\t\t\t\t(config->mem_config->memzone[memzone_idx].addr <\n-\t\t\t\t\t(RTE_PTR_ADD(ms[memseg_idx].addr, ms[memseg_idx].len)))) {\n-\t\t\t\t/* since the zones can now be aligned and occasionally skip\n-\t\t\t\t * some space, we should calculate the length based on\n-\t\t\t\t * reported length and start addresses difference.\n-\t\t\t\t */\n-\t\t\t\tlen -= (uintptr_t) RTE_PTR_SUB(\n-\t\t\t\t\t\tconfig->mem_config->memzone[memzone_idx].addr,\n-\t\t\t\t\t\t(uintptr_t) last_addr);\n-\t\t\t\tlen -= config->mem_config->memzone[memzone_idx].len;\n-\t\t\t\tlast_addr =\n-\t\t\t\t\t\tRTE_PTR_ADD(config->mem_config->memzone[memzone_idx].addr,\n-\t\t\t\t\t\t(size_t) config->mem_config->memzone[memzone_idx].len);\n-\t\t\t}\n-\t\t}\n-\n-\t\t/* make sure we get the alignment offset */\n-\t\tif (len > maxlen) {\n-\t\t\taddr_offset = RTE_PTR_ALIGN_CEIL((uintptr_t) last_addr, align) - (uintptr_t) last_addr;\n-\t\t\tmaxlen = len;\n-\t\t}\n-\t}\n+\tmaxlen = find_max_block_free_size(align);\n \n-\tif (maxlen == 0 || maxlen == addr_offset) {\n+\tif (maxlen == 0) {\n \t\tprintf(\"There is no space left for biggest %u-aligned memzone!\\n\", align);\n \t\treturn 0;\n \t}\n \n-\tmaxlen -= addr_offset;\n-\n \tmz = rte_memzone_reserve_aligned(\"max_zone_aligned\", 0,\n \t\t\tSOCKET_ID_ANY, 0, align);\n \tif (mz == NULL){\n-\t\tprintf(\"Failed to reserve a big chunk of memory\\n\");\n+\t\tprintf(\"Failed to reserve a big chunk of memory - %s\\n\",\n+\t\t\t\trte_strerror(rte_errno));\n \t\trte_dump_physmem_layout(stdout);\n \t\trte_memzone_dump(stdout);\n \t\treturn -1;\n@@ -762,282 +680,6 @@ test_memzone_bounded(void)\n \tif ((rc = check_memzone_bounded(\"bounded_1K_MAX\", 0, 64, 1024)) != 0)\n \t\treturn (rc);\n \n-\treturn (0);\n-}\n-\n-static int\n-test_memzone_reserve_memory_in_smallest_segment(void)\n-{\n-\tconst struct rte_memzone *mz;\n-\tconst struct rte_memseg *ms, *min_ms, *prev_min_ms;\n-\tsize_t min_len, prev_min_len;\n-\tconst struct rte_config *config;\n-\tint i;\n-\n-\tconfig = rte_eal_get_configuration();\n-\n-\tmin_ms = NULL;  /*< smallest segment */\n-\tprev_min_ms = NULL; /*< second smallest segment */\n-\n-\t/* find two smallest segments */\n-\tfor (i = 0; i < RTE_MAX_MEMSEG; i++) {\n-\t\tms = &config->mem_config->free_memseg[i];\n-\n-\t\tif (ms->addr == NULL)\n-\t\t\tbreak;\n-\t\tif (ms->len == 0)\n-\t\t\tcontinue;\n-\n-\t\tif (min_ms == NULL)\n-\t\t\tmin_ms = ms;\n-\t\telse if (min_ms->len > ms->len) {\n-\t\t\t/* set last smallest to second last */\n-\t\t\tprev_min_ms = min_ms;\n-\n-\t\t\t/* set new smallest */\n-\t\t\tmin_ms = ms;\n-\t\t} else if ((prev_min_ms == NULL)\n-\t\t\t|| (prev_min_ms->len > ms->len))\n-\t\t\tprev_min_ms = ms;\n-\t}\n-\n-\tif (min_ms == NULL || prev_min_ms == NULL) {\n-\t\tprintf(\"Smallest segments not found!\\n\");\n-\t\treturn -1;\n-\t}\n-\n-\tmin_len = min_ms->len;\n-\tprev_min_len = prev_min_ms->len;\n-\n-\t/* try reserving a memzone in the smallest memseg */\n-\tmz = rte_memzone_reserve(\"smallest_mz\", RTE_CACHE_LINE_SIZE,\n-\t\t\tSOCKET_ID_ANY, 0);\n-\tif (mz == NULL) {\n-\t\tprintf(\"Failed to reserve memory from smallest memseg!\\n\");\n-\t\treturn -1;\n-\t}\n-\tif (prev_min_ms->len != prev_min_len &&\n-\t\t\tmin_ms->len != min_len - RTE_CACHE_LINE_SIZE) {\n-\t\tprintf(\"Reserved memory from wrong memseg!\\n\");\n-\t\treturn -1;\n-\t}\n-\n-\treturn 0;\n-}\n-\n-/* this test is a bit  tricky, and thus warrants explanation.\n- *\n- * first, we find two smallest memsegs to conduct our experiments on.\n- *\n- * then, we bring them within alignment from each other: if second segment is\n- * twice+ as big as the first, reserve memory from that segment; if second\n- * segment is comparable in length to the first, then cut the first segment\n- * down until it becomes less than half of second segment, and then cut down\n- * the second segment to be within alignment of the first.\n- *\n- * then, we have to pass the following test: if segments are within alignment\n- * of each other (that is, the difference is less than 256 bytes, which is what\n- * our alignment will be), segment with smallest offset should be picked.\n- *\n- * we know that min_ms will be our smallest segment, so we need to make sure\n- * that we adjust the alignments so that the bigger segment has smallest\n- * alignment (in our case, smallest segment will have 64-byte alignment, while\n- * bigger segment will have 128-byte alignment).\n- */\n-static int\n-test_memzone_reserve_memory_with_smallest_offset(void)\n-{\n-\tconst struct rte_memseg *ms, *min_ms, *prev_min_ms;\n-\tsize_t len, min_len, prev_min_len;\n-\tconst struct rte_config *config;\n-\tint i, align;\n-\n-\tconfig = rte_eal_get_configuration();\n-\n-\tmin_ms = NULL;  /*< smallest segment */\n-\tprev_min_ms = NULL; /*< second smallest segment */\n-\talign = RTE_CACHE_LINE_SIZE * 4;\n-\n-\t/* find two smallest segments */\n-\tfor (i = 0; i < RTE_MAX_MEMSEG; i++) {\n-\t\tms = &config->mem_config->free_memseg[i];\n-\n-\t\tif (ms->addr == NULL)\n-\t\t\tbreak;\n-\t\tif (ms->len == 0)\n-\t\t\tcontinue;\n-\n-\t\tif (min_ms == NULL)\n-\t\t\tmin_ms = ms;\n-\t\telse if (min_ms->len > ms->len) {\n-\t\t\t/* set last smallest to second last */\n-\t\t\tprev_min_ms = min_ms;\n-\n-\t\t\t/* set new smallest */\n-\t\t\tmin_ms = ms;\n-\t\t} else if ((prev_min_ms == NULL)\n-\t\t\t|| (prev_min_ms->len > ms->len)) {\n-\t\t\tprev_min_ms = ms;\n-\t\t}\n-\t}\n-\n-\tif (min_ms == NULL || prev_min_ms == NULL) {\n-\t\tprintf(\"Smallest segments not found!\\n\");\n-\t\treturn -1;\n-\t}\n-\n-\tprev_min_len = prev_min_ms->len;\n-\tmin_len = min_ms->len;\n-\n-\t/* if smallest segment is bigger than half of bigger segment */\n-\tif (prev_min_ms->len - min_ms->len <= min_ms->len) {\n-\n-\t\tlen = (min_ms->len * 2) - prev_min_ms->len;\n-\n-\t\t/* make sure final length is *not* aligned */\n-\t\twhile (((min_ms->addr_64 + len) & (align-1)) == 0)\n-\t\t\tlen += RTE_CACHE_LINE_SIZE;\n-\n-\t\tif (rte_memzone_reserve(\"dummy_mz1\", len, SOCKET_ID_ANY, 0) == NULL) {\n-\t\t\tprintf(\"Cannot reserve memory!\\n\");\n-\t\t\treturn -1;\n-\t\t}\n-\n-\t\t/* check if we got memory from correct segment */\n-\t\tif (min_ms->len != min_len - len) {\n-\t\t\tprintf(\"Reserved memory from wrong segment!\\n\");\n-\t\t\treturn -1;\n-\t\t}\n-\t}\n-    /* if we don't need to touch smallest segment but it's aligned */\n-    else if ((min_ms->addr_64 & (align-1)) == 0) {\n-            if (rte_memzone_reserve(\"align_mz1\", RTE_CACHE_LINE_SIZE,\n-                    SOCKET_ID_ANY, 0) == NULL) {\n-                            printf(\"Cannot reserve memory!\\n\");\n-                            return -1;\n-            }\n-            if (min_ms->len != min_len - RTE_CACHE_LINE_SIZE) {\n-                    printf(\"Reserved memory from wrong segment!\\n\");\n-                    return -1;\n-            }\n-    }\n-\n-\t/* if smallest segment is less than half of bigger segment */\n-\tif (prev_min_ms->len - min_ms->len > min_ms->len) {\n-\t\tlen = prev_min_ms->len - min_ms->len - align;\n-\n-\t\t/* make sure final length is aligned */\n-\t\twhile (((prev_min_ms->addr_64 + len) & (align-1)) != 0)\n-\t\t\tlen += RTE_CACHE_LINE_SIZE;\n-\n-\t\tif (rte_memzone_reserve(\"dummy_mz2\", len, SOCKET_ID_ANY, 0) == NULL) {\n-\t\t\tprintf(\"Cannot reserve memory!\\n\");\n-\t\t\treturn -1;\n-\t\t}\n-\n-\t\t/* check if we got memory from correct segment */\n-\t\tif (prev_min_ms->len != prev_min_len - len) {\n-\t\t\tprintf(\"Reserved memory from wrong segment!\\n\");\n-\t\t\treturn -1;\n-\t\t}\n-\t}\n-\tlen = RTE_CACHE_LINE_SIZE;\n-\n-\n-\n-\tprev_min_len = prev_min_ms->len;\n-\tmin_len = min_ms->len;\n-\n-\tif (min_len >= prev_min_len || prev_min_len - min_len > (unsigned) align) {\n-\t\tprintf(\"Segments are of wrong lengths!\\n\");\n-\t\treturn -1;\n-\t}\n-\n-\t/* try reserving from a bigger segment */\n-\tif (rte_memzone_reserve_aligned(\"smallest_offset\", len, SOCKET_ID_ANY, 0, align) ==\n-\t\t\tNULL) {\n-\t\tprintf(\"Cannot reserve memory!\\n\");\n-\t\treturn -1;\n-\t}\n-\n-\t/* check if we got memory from correct segment */\n-\tif (min_ms->len != min_len && prev_min_ms->len != (prev_min_len - len)) {\n-\t\tprintf(\"Reserved memory from segment with smaller offset!\\n\");\n-\t\treturn -1;\n-\t}\n-\n-\treturn 0;\n-}\n-\n-static int\n-test_memzone_reserve_remainder(void)\n-{\n-\tconst struct rte_memzone *mz1, *mz2;\n-\tconst struct rte_memseg *ms, *min_ms = NULL;\n-\tsize_t min_len;\n-\tconst struct rte_config *config;\n-\tint i, align;\n-\n-\tmin_len = 0;\n-\talign = RTE_CACHE_LINE_SIZE;\n-\n-\tconfig = rte_eal_get_configuration();\n-\n-\t/* find minimum free contiguous length */\n-\tfor (i = 0; i < RTE_MAX_MEMSEG; i++) {\n-\t\tms = &config->mem_config->free_memseg[i];\n-\n-\t\tif (ms->addr == NULL)\n-\t\t\tbreak;\n-\t\tif (ms->len == 0)\n-\t\t\tcontinue;\n-\n-\t\tif (min_len == 0 || ms->len < min_len) {\n-\t\t\tmin_len = ms->len;\n-\t\t\tmin_ms = ms;\n-\n-\t\t\t/* find maximum alignment this segment is able to hold */\n-\t\t\talign = RTE_CACHE_LINE_SIZE;\n-\t\t\twhile ((ms->addr_64 & (align-1)) == 0) {\n-\t\t\t\talign <<= 1;\n-\t\t\t}\n-\t\t}\n-\t}\n-\n-\tif (min_ms == NULL) {\n-\t\tprintf(\"Minimal sized segment not found!\\n\");\n-\t\treturn -1;\n-\t}\n-\n-\t/* try reserving min_len bytes with alignment - this should not affect our\n-\t * memseg, the memory will be taken from a different one.\n-\t */\n-\tmz1 = rte_memzone_reserve_aligned(\"reserve_remainder_1\", min_len,\n-\t\t\tSOCKET_ID_ANY, 0, align);\n-\tif (mz1 == NULL) {\n-\t\tprintf(\"Failed to reserve %zu bytes aligned on %i bytes\\n\", min_len,\n-\t\t\t\talign);\n-\t\treturn -1;\n-\t}\n-\tif (min_ms->len != min_len) {\n-\t\tprintf(\"Memseg memory should not have been reserved!\\n\");\n-\t\treturn -1;\n-\t}\n-\n-\t/* try reserving min_len bytes with less alignment - this should fill up\n-\t * the segment.\n-\t */\n-\tmz2 = rte_memzone_reserve(\"reserve_remainder_2\", min_len,\n-\t\t\tSOCKET_ID_ANY, 0);\n-\tif (mz2 == NULL) {\n-\t\tprintf(\"Failed to reserve %zu bytes\\n\", min_len);\n-\t\treturn -1;\n-\t}\n-\tif (min_ms->len != 0) {\n-\t\tprintf(\"Memseg memory should have been reserved!\\n\");\n-\t\treturn -1;\n-\t}\n-\n \treturn 0;\n }\n \n@@ -1125,14 +767,6 @@ test_memzone(void)\n \tif (test_memzone_reserving_zone_size_bigger_than_the_maximum() < 0)\n \t\treturn -1;\n \n-\tprintf(\"test reserving memory in smallest segments\\n\");\n-\tif (test_memzone_reserve_memory_in_smallest_segment() < 0)\n-\t\treturn -1;\n-\n-\tprintf(\"test reserving memory in segments with smallest offsets\\n\");\n-\tif (test_memzone_reserve_memory_with_smallest_offset() < 0)\n-\t\treturn -1;\n-\n \tprintf(\"test memzone_reserve flags\\n\");\n \tif (test_memzone_reserve_flags() < 0)\n \t\treturn -1;\n@@ -1149,10 +783,6 @@ test_memzone(void)\n \tif (test_memzone_invalid_alignment() < 0)\n \t\treturn -1;\n \n-\tprintf(\"test reserving amounts of memory equal to segment's length\\n\");\n-\tif (test_memzone_reserve_remainder() < 0)\n-\t\treturn -1;\n-\n \tprintf(\"test reserving the largest size memzone possible\\n\");\n \tif (test_memzone_reserve_max() < 0)\n \t\treturn -1;\n",
    "prefixes": [
        "dpdk-dev",
        "v4",
        "3/9"
    ]
}