get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 118239,
    "url": "http://patches.dpdk.org/api/patches/118239/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20221017034058.34176-6-fengchengwen@huawei.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": "<20221017034058.34176-6-fengchengwen@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20221017034058.34176-6-fengchengwen@huawei.com",
    "date": "2022-10-17T03:40:56",
    "name": "[v10,5/7] memarea: support dump API",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "16b604b73b3c57e5d3968e31514c42f522a4cf1a",
    "submitter": {
        "id": 2146,
        "url": "http://patches.dpdk.org/api/people/2146/?format=api",
        "name": "fengchengwen",
        "email": "fengchengwen@huawei.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/20221017034058.34176-6-fengchengwen@huawei.com/mbox/",
    "series": [
        {
            "id": 25245,
            "url": "http://patches.dpdk.org/api/series/25245/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=25245",
            "date": "2022-10-17T03:40:51",
            "name": "introduce memarea library",
            "version": 10,
            "mbox": "http://patches.dpdk.org/series/25245/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/118239/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/118239/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 57956A0556;\n\tMon, 17 Oct 2022 05:47:28 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 54BC94281E;\n\tMon, 17 Oct 2022 05:46:57 +0200 (CEST)",
            "from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188])\n by mails.dpdk.org (Postfix) with ESMTP id 632EA400D7\n for <dev@dpdk.org>; Mon, 17 Oct 2022 05:46:49 +0200 (CEST)",
            "from dggpeml500024.china.huawei.com (unknown [172.30.72.56])\n by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MrNGB2ZxNzHvWj;\n Mon, 17 Oct 2022 11:46:42 +0800 (CST)",
            "from localhost.localdomain (10.67.165.24) by\n dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id\n 15.1.2375.31; Mon, 17 Oct 2022 11:46:45 +0800"
        ],
        "From": "Chengwen Feng <fengchengwen@huawei.com>",
        "To": "<david.marchand@redhat.com>, <mb@smartsharesystems.com>,\n <anatoly.burakov@intel.com>, <dmitry.kozliuk@gmail.com>,\n <jerinjacobk@gmail.com>, <hofors@lysator.liu.se>",
        "CC": "<thomas@monjalon.net>, <dev@dpdk.org>",
        "Subject": "[PATCH v10 5/7] memarea: support dump API",
        "Date": "Mon, 17 Oct 2022 03:40:56 +0000",
        "Message-ID": "<20221017034058.34176-6-fengchengwen@huawei.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20221017034058.34176-1-fengchengwen@huawei.com>",
        "References": "<20220721044648.6817-1-fengchengwen@huawei.com>\n <20221017034058.34176-1-fengchengwen@huawei.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[10.67.165.24]",
        "X-ClientProxiedBy": "dggems706-chm.china.huawei.com (10.3.19.183) To\n dggpeml500024.china.huawei.com (7.185.36.10)",
        "X-CFilter-Loop": "Reflected",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <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 <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "This patch supports rte_memarea_dump() API which could be used for\ndebug.\n\nSigned-off-by: Chengwen Feng <fengchengwen@huawei.com>\n---\n doc/guides/prog_guide/memarea_lib.rst |  3 +\n lib/memarea/rte_memarea.c             | 98 +++++++++++++++++++++++++++\n lib/memarea/rte_memarea.h             | 21 ++++++\n lib/memarea/version.map               |  1 +\n 4 files changed, 123 insertions(+)",
    "diff": "diff --git a/doc/guides/prog_guide/memarea_lib.rst b/doc/guides/prog_guide/memarea_lib.rst\nindex 8fbfd06a5d..c33a548417 100644\n--- a/doc/guides/prog_guide/memarea_lib.rst\n+++ b/doc/guides/prog_guide/memarea_lib.rst\n@@ -43,6 +43,9 @@ The ``rte_memarea_refcnt_update()`` function is used to update the memory\n object's reference count, if the count reaches zero, the memory object will\n be freed to memarea.\n \n++The ``rte_memarea_dump()`` function is used to dump the internal information\n++of a memarea.\n+\n Reference\n ---------\n \ndiff --git a/lib/memarea/rte_memarea.c b/lib/memarea/rte_memarea.c\nindex a0935dafb6..c58f68df53 100644\n--- a/lib/memarea/rte_memarea.c\n+++ b/lib/memarea/rte_memarea.c\n@@ -2,6 +2,7 @@\n  * Copyright(c) 2022 HiSilicon Limited\n  */\n \n+#include <inttypes.h>\n #include <stdio.h>\n #include <stdlib.h>\n #include <sys/queue.h>\n@@ -313,3 +314,100 @@ rte_memarea_refcnt_update(struct rte_memarea *ma, void *ptr, int32_t value)\n \t\tmemarea_free_elem(ma, elem);\n \tmemarea_unlock(ma);\n }\n+\n+static const char *\n+memarea_source_name(enum rte_memarea_source source)\n+{\n+\tif (source == RTE_MEMAREA_SOURCE_HEAP)\n+\t\treturn \"heap\";\n+\telse if (source == RTE_MEMAREA_SOURCE_LIBC)\n+\t\treturn \"libc\";\n+\telse if (source == RTE_MEMAREA_SOURCE_MEMAREA)\n+\t\treturn \"memarea\";\n+\telse\n+\t\treturn \"unknown\";\n+}\n+\n+static const char *\n+memarea_alg_name(enum rte_memarea_alg alg)\n+{\n+\tif (alg == RTE_MEMAREA_ALG_NEXTFIT)\n+\t\treturn \"nextfit\";\n+\telse\n+\t\treturn \"unknown\";\n+}\n+\n+static uint32_t\n+memarea_elem_list_num(struct rte_memarea *ma)\n+{\n+\tstruct memarea_elem *elem;\n+\tuint32_t num = 0;\n+\n+\tTAILQ_FOREACH(elem, &ma->elem_list, elem_node) {\n+\t\tif (elem->magic != MEMAREA_AVAILABLE_ELEM_MAGIC &&\n+\t\t    elem->magic != MEMAREA_ALLOCATED_ELEM_MAGIC)\n+\t\t\tbreak;\n+\t\tnum++;\n+\t}\n+\n+\treturn num;\n+}\n+\n+static uint32_t\n+memarea_free_list_num(struct rte_memarea *ma)\n+{\n+\tstruct memarea_elem *elem;\n+\tuint32_t num = 0;\n+\n+\tTAILQ_FOREACH(elem, &ma->free_list, free_node) {\n+\t\tif (elem->magic != MEMAREA_AVAILABLE_ELEM_MAGIC)\n+\t\t\tbreak;\n+\t\tnum++;\n+\t}\n+\n+\treturn num;\n+}\n+\n+static void\n+memarea_dump_all(struct rte_memarea *ma, FILE *f)\n+{\n+\tstruct memarea_elem *elem;\n+\n+\tfprintf(f, \"  regions:\\n\");\n+\tTAILQ_FOREACH(elem, &ma->elem_list, elem_node) {\n+\t\tif (elem->magic != MEMAREA_AVAILABLE_ELEM_MAGIC &&\n+\t\t    elem->magic != MEMAREA_ALLOCATED_ELEM_MAGIC) {\n+\t\t\tfprintf(f, \"    magic: 0x%x check fail!\\n\", elem->magic);\n+\t\t\tbreak;\n+\t\t}\n+\t\tfprintf(f, \"    size: 0x%zx cookie: 0x%x refcnt: %d\\n\",\n+\t\t\telem->size, elem->cookie, elem->refcnt);\n+\t}\n+}\n+\n+int\n+rte_memarea_dump(struct rte_memarea *ma, FILE *f, bool dump_all)\n+{\n+\tif (ma == NULL || f == NULL)\n+\t\treturn -EINVAL;\n+\n+\tmemarea_lock(ma);\n+\tfprintf(f, \"memarea name: %s\\n\", ma->init.name);\n+\tfprintf(f, \"  source: %s\\n\", memarea_source_name(ma->init.source));\n+\tif (ma->init.source == RTE_MEMAREA_SOURCE_HEAP)\n+\t\tfprintf(f, \"  heap-numa-socket: %d\\n\", ma->init.numa_socket);\n+\telse if (ma->init.source == RTE_MEMAREA_SOURCE_MEMAREA)\n+\t\tfprintf(f, \"  source-memarea: %s\\n\", ma->init.src_memarea->init.name);\n+\tfprintf(f, \"  algorithm: %s\\n\", memarea_alg_name(ma->init.alg));\n+\tfprintf(f, \"  total-size: 0x%zx\\n\", ma->init.total_sz);\n+\tfprintf(f, \"  mt-safe: %s\\n\", ma->init.mt_safe ? \"yes\" : \"no\");\n+\tfprintf(f, \"  total-regions: %u\\n\", memarea_elem_list_num(ma));\n+\tfprintf(f, \"  total-free-regions: %u\\n\", memarea_free_list_num(ma));\n+\tfprintf(f, \"  alloc_fails: %\" PRIu64 \"\\n\", ma->alloc_fails);\n+\tfprintf(f, \"  refcnt_check_fails: %\" PRIu64 \"\\n\", ma->refcnt_check_fails);\n+\tif (dump_all)\n+\t\tmemarea_dump_all(ma, f);\n+\tmemarea_unlock(ma);\n+\n+\treturn 0;\n+}\ndiff --git a/lib/memarea/rte_memarea.h b/lib/memarea/rte_memarea.h\nindex 31c499ec07..61042a8d0d 100644\n--- a/lib/memarea/rte_memarea.h\n+++ b/lib/memarea/rte_memarea.h\n@@ -191,6 +191,27 @@ void rte_memarea_free(struct rte_memarea *ma, void *ptr);\n __rte_experimental\n void rte_memarea_refcnt_update(struct rte_memarea *ma, void *ptr, int32_t value);\n \n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Dump memarea.\n+ *\n+ * Dump one memarea.\n+ *\n+ * @param ma\n+ *   The pointer of memarea.\n+ * @param f\n+ *   The file to write the output to.\n+ * @param dump_all\n+ *   Indicate whether to dump the allocated and free memory objects information.\n+ *\n+ * @return\n+ *   0 on success. Otherwise negative value is returned.\n+ */\n+__rte_experimental\n+int rte_memarea_dump(struct rte_memarea *ma, FILE *f, bool dump_all);\n+\n #ifdef __cplusplus\n }\n #endif\ndiff --git a/lib/memarea/version.map b/lib/memarea/version.map\nindex a087d40d5f..6d75f9f7c4 100644\n--- a/lib/memarea/version.map\n+++ b/lib/memarea/version.map\n@@ -4,6 +4,7 @@ EXPERIMENTAL {\n \trte_memarea_alloc;\n \trte_memarea_create;\n \trte_memarea_destroy;\n+\trte_memarea_dump;\n \trte_memarea_free;\n \trte_memarea_refcnt_update;\n \n",
    "prefixes": [
        "v10",
        "5/7"
    ]
}