get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 39352,
    "url": "https://patches.dpdk.org/api/patches/39352/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/4b216f45b6b8245ed96a08466ce0c7c43a05a7f1.1525366407.git.anatoly.burakov@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": "<4b216f45b6b8245ed96a08466ce0c7c43a05a7f1.1525366407.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/4b216f45b6b8245ed96a08466ce0c7c43a05a7f1.1525366407.git.anatoly.burakov@intel.com",
    "date": "2018-05-03T17:17:59",
    "name": "[dpdk-dev,v3,1/3] malloc: add biggest free IOVA-contiguous element to stats",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "ac1a18595ab344947bf7b190a679f5e14f50295f",
    "submitter": {
        "id": 4,
        "url": "https://patches.dpdk.org/api/people/4/?format=api",
        "name": "Burakov, Anatoly",
        "email": "anatoly.burakov@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/4b216f45b6b8245ed96a08466ce0c7c43a05a7f1.1525366407.git.anatoly.burakov@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/39352/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/39352/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 9A98B2BA7;\n\tThu,  3 May 2018 19:18:09 +0200 (CEST)",
            "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n\tby dpdk.org (Postfix) with ESMTP id C0EE61E2F\n\tfor <dev@dpdk.org>; Thu,  3 May 2018 19:18:06 +0200 (CEST)",
            "from orsmga001.jf.intel.com ([10.7.209.18])\n\tby fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t03 May 2018 10:18:03 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby orsmga001.jf.intel.com with ESMTP; 03 May 2018 10:18:03 -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\tw43HI254004218 for <dev@dpdk.org>; Thu, 3 May 2018 18:18:02 +0100",
            "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w43HI2dK008911\n\tfor <dev@dpdk.org>; Thu, 3 May 2018 18:18:02 +0100",
            "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w43HI2CE008906\n\tfor dev@dpdk.org; Thu, 3 May 2018 18:18:02 +0100"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.49,359,1520924400\"; d=\"scan'208\";a=\"52955201\"",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Thu,  3 May 2018 18:17:59 +0100",
        "Message-Id": "<4b216f45b6b8245ed96a08466ce0c7c43a05a7f1.1525366407.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": [
            "<cover.1525366407.git.anatoly.burakov@intel.com>",
            "<cover.1525366407.git.anatoly.burakov@intel.com>"
        ],
        "References": [
            "<cover.1525366407.git.anatoly.burakov@intel.com>",
            "<777ae6b10a7524e188c07ba14e576fc7b0e21018.1524729978.git.anatoly.burakov@intel.com>\n\t<cover.1525366407.git.anatoly.burakov@intel.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH v3 1/3] malloc: add biggest free IOVA-contiguous\n\telement to stats",
        "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://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": "<https://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": "User might be interested to find out what is the biggest chunk of\nIOVA-contiguous free space that can be allocated from malloc. Add\nrelevant malloc-internal functions and expose this through malloc\nstats calculation call.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n\nNotes:\n    v2:\n    - Add header to newly recalculated element start\n\n lib/librte_eal/common/include/rte_malloc.h |  1 +\n lib/librte_eal/common/malloc_elem.c        | 77 ++++++++++++++++++++++++++++++\n lib/librte_eal/common/malloc_elem.h        |  6 +++\n lib/librte_eal/common/malloc_heap.c        | 11 +++++\n lib/librte_eal/common/rte_malloc.c         |  2 +\n 5 files changed, 97 insertions(+)",
    "diff": "diff --git a/lib/librte_eal/common/include/rte_malloc.h b/lib/librte_eal/common/include/rte_malloc.h\nindex a9fb7e4..2553201 100644\n--- a/lib/librte_eal/common/include/rte_malloc.h\n+++ b/lib/librte_eal/common/include/rte_malloc.h\n@@ -27,6 +27,7 @@ struct rte_malloc_socket_stats {\n \tsize_t heap_totalsz_bytes; /**< Total bytes on heap */\n \tsize_t heap_freesz_bytes;  /**< Total free bytes on heap */\n \tsize_t greatest_free_size; /**< Size in bytes of largest free block */\n+\tsize_t greatest_free_iova_contig_size; /**< Size in bytes of largest IOVA-contiguous block */\n \tunsigned free_count;       /**< Number of free elements on heap */\n \tunsigned alloc_count;      /**< Number of allocated elements on heap */\n \tsize_t heap_allocsz_bytes; /**< Total allocated bytes on heap */\ndiff --git a/lib/librte_eal/common/malloc_elem.c b/lib/librte_eal/common/malloc_elem.c\nindex 9bfe9b9..d330fb1 100644\n--- a/lib/librte_eal/common/malloc_elem.c\n+++ b/lib/librte_eal/common/malloc_elem.c\n@@ -18,10 +18,87 @@\n #include <rte_common.h>\n #include <rte_spinlock.h>\n \n+#include \"eal_internal_cfg.h\"\n #include \"eal_memalloc.h\"\n #include \"malloc_elem.h\"\n #include \"malloc_heap.h\"\n \n+size_t\n+malloc_elem_find_max_iova_contig(struct malloc_elem *elem, size_t align)\n+{\n+\tvoid *cur_page, *contig_seg_start, *page_end, *cur_seg_end;\n+\tvoid *data_start, *data_end;\n+\trte_iova_t expected_iova;\n+\tstruct rte_memseg *ms;\n+\tsize_t page_sz, cur, max;\n+\n+\tpage_sz = (size_t)elem->msl->page_sz;\n+\tdata_start = RTE_PTR_ADD(elem, MALLOC_ELEM_HEADER_LEN);\n+\tdata_end = RTE_PTR_ADD(elem, elem->size - MALLOC_ELEM_TRAILER_LEN);\n+\t/* segment must start after header and with specified alignment */\n+\tcontig_seg_start = RTE_PTR_ALIGN_CEIL(data_start, align);\n+\n+\t/* if we're in IOVA as VA mode, or if we're in legacy mode with\n+\t * hugepages, all elements are IOVA-contiguous.\n+\t */\n+\tif (rte_eal_iova_mode() == RTE_IOVA_VA ||\n+\t\t\t(internal_config.legacy_mem && rte_eal_has_hugepages()))\n+\t\treturn RTE_PTR_DIFF(data_end, contig_seg_start);\n+\n+\tcur_page = RTE_PTR_ALIGN_FLOOR(contig_seg_start, page_sz);\n+\tms = rte_mem_virt2memseg(cur_page, elem->msl);\n+\n+\t/* do first iteration outside the loop */\n+\tpage_end = RTE_PTR_ADD(cur_page, page_sz);\n+\tcur_seg_end = RTE_MIN(page_end, data_end);\n+\tcur = RTE_PTR_DIFF(cur_seg_end, contig_seg_start) -\n+\t\t\tMALLOC_ELEM_TRAILER_LEN;\n+\tmax = cur;\n+\texpected_iova = ms->iova + page_sz;\n+\t/* memsegs are contiguous in memory */\n+\tms++;\n+\n+\tcur_page = RTE_PTR_ADD(cur_page, page_sz);\n+\n+\twhile (cur_page < data_end) {\n+\t\tpage_end = RTE_PTR_ADD(cur_page, page_sz);\n+\t\tcur_seg_end = RTE_MIN(page_end, data_end);\n+\n+\t\t/* reset start of contiguous segment if unexpected iova. this is\n+\t\t * a contiguous segment, and elem->size includes header len, so\n+\t\t * move element start point to where header would've started\n+\t\t */\n+\t\tif (ms->iova != expected_iova) {\n+\t\t\t/* next contiguous segment must start at specified\n+\t\t\t * alignment.\n+\t\t\t */\n+\t\t\tcontig_seg_start = RTE_PTR_ALIGN(cur_page, align);\n+\t\t\t/* new segment start may be on a different page, so find\n+\t\t\t * the page and skip to next iteration to make sure\n+\t\t\t * we're not blowing past data end.\n+\t\t\t */\n+\t\t\tms = rte_mem_virt2memseg(contig_seg_start, elem->msl);\n+\t\t\tcur_page = ms->addr;\n+\t\t\t/* don't trigger another recalculation */\n+\t\t\texpected_iova = ms->iova;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tcur = RTE_PTR_DIFF(cur_seg_end, contig_seg_start) -\n+\t\t\t\tMALLOC_ELEM_TRAILER_LEN;\n+\t\t/* update max if cur value is bigger */\n+\t\tif (cur > max)\n+\t\t\tmax = cur;\n+\n+\t\t/* move to next page */\n+\t\tcur_page = page_end;\n+\t\texpected_iova = ms->iova + page_sz;\n+\t\t/* memsegs are contiguous in memory */\n+\t\tms++;\n+\t}\n+\n+\treturn max;\n+}\n+\n /*\n  * Initialize a general malloc_elem header structure\n  */\ndiff --git a/lib/librte_eal/common/malloc_elem.h b/lib/librte_eal/common/malloc_elem.h\nindex 7331af9..e2bda4c 100644\n--- a/lib/librte_eal/common/malloc_elem.h\n+++ b/lib/librte_eal/common/malloc_elem.h\n@@ -179,4 +179,10 @@ malloc_elem_free_list_index(size_t size);\n void\n malloc_elem_free_list_insert(struct malloc_elem *elem);\n \n+/*\n+ * Find biggest IOVA-contiguous zone within an element with specified alignment.\n+ */\n+size_t\n+malloc_elem_find_max_iova_contig(struct malloc_elem *elem, size_t align);\n+\n #endif /* MALLOC_ELEM_H_ */\ndiff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c\nindex d6cf3af..9305b38 100644\n--- a/lib/librte_eal/common/malloc_heap.c\n+++ b/lib/librte_eal/common/malloc_heap.c\n@@ -803,16 +803,27 @@ malloc_heap_get_stats(struct malloc_heap *heap,\n \tsocket_stats->free_count = 0;\n \tsocket_stats->heap_freesz_bytes = 0;\n \tsocket_stats->greatest_free_size = 0;\n+\tsocket_stats->greatest_free_iova_contig_size = 0;\n \n \t/* Iterate through free list */\n \tfor (idx = 0; idx < RTE_HEAP_NUM_FREELISTS; idx++) {\n \t\tfor (elem = LIST_FIRST(&heap->free_head[idx]);\n \t\t\t!!elem; elem = LIST_NEXT(elem, free_list))\n \t\t{\n+\t\t\tsize_t iova_contig_sz;\n \t\t\tsocket_stats->free_count++;\n \t\t\tsocket_stats->heap_freesz_bytes += elem->size;\n \t\t\tif (elem->size > socket_stats->greatest_free_size)\n \t\t\t\tsocket_stats->greatest_free_size = elem->size;\n+\t\t\tiova_contig_sz =\n+\t\t\t\t\tmalloc_elem_find_max_iova_contig(elem,\n+\t\t\t\t\t\t\tRTE_CACHE_LINE_SIZE);\n+\t\t\t/* find_max_iova_contig doesn't include overhead */\n+\t\t\tiova_contig_sz += MALLOC_ELEM_OVERHEAD;\n+\t\t\tif (iova_contig_sz >\n+\t\t\t\t\tsocket_stats->greatest_free_iova_contig_size)\n+\t\t\t\tsocket_stats->greatest_free_iova_contig_size =\n+\t\t\t\t\t\tiova_contig_sz;\n \t\t}\n \t}\n \t/* Get stats on overall heap and allocated memory on this heap */\ndiff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c\nindex b51a6d1..b4e87a3 100644\n--- a/lib/librte_eal/common/rte_malloc.c\n+++ b/lib/librte_eal/common/rte_malloc.c\n@@ -195,6 +195,8 @@ rte_malloc_dump_stats(FILE *f, __rte_unused const char *type)\n \t\tfprintf(f, \"\\tAlloc_size:%zu,\\n\", sock_stats.heap_allocsz_bytes);\n \t\tfprintf(f, \"\\tGreatest_free_size:%zu,\\n\",\n \t\t\t\tsock_stats.greatest_free_size);\n+\t\tfprintf(f, \"\\tGreatest_free_iova_contig_size:%zu,\\n\",\n+\t\t\t\tsock_stats.greatest_free_iova_contig_size);\n \t\tfprintf(f, \"\\tAlloc_count:%u,\\n\",sock_stats.alloc_count);\n \t\tfprintf(f, \"\\tFree_count:%u,\\n\", sock_stats.free_count);\n \t}\n",
    "prefixes": [
        "dpdk-dev",
        "v3",
        "1/3"
    ]
}