get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 129655,
    "url": "https://patches.dpdk.org/api/patches/129655/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20230720092254.54157-6-fengchengwen@huawei.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": "<20230720092254.54157-6-fengchengwen@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230720092254.54157-6-fengchengwen@huawei.com",
    "date": "2023-07-20T09:22:53",
    "name": "[v19,5/6] memarea: support dump API",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "32264bbf7c2aa86c49a2c83f70ede7e7e861dbec",
    "submitter": {
        "id": 2146,
        "url": "https://patches.dpdk.org/api/people/2146/?format=api",
        "name": "fengchengwen",
        "email": "fengchengwen@huawei.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/20230720092254.54157-6-fengchengwen@huawei.com/mbox/",
    "series": [
        {
            "id": 28981,
            "url": "https://patches.dpdk.org/api/series/28981/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=28981",
            "date": "2023-07-20T09:22:53",
            "name": "introduce memarea library",
            "version": 19,
            "mbox": "https://patches.dpdk.org/series/28981/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/129655/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/129655/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 3B43442EBF;\n\tThu, 20 Jul 2023 11:31:11 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 00D6E40EE3;\n\tThu, 20 Jul 2023 11:31:11 +0200 (CEST)",
            "from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188])\n by mails.dpdk.org (Postfix) with ESMTP id E31AC40DF5\n for <dev@dpdk.org>; Thu, 20 Jul 2023 11:31:09 +0200 (CEST)",
            "from dggpeml100024.china.huawei.com (unknown [172.30.72.56])\n by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4R66mN40MtzNmVD;\n Thu, 20 Jul 2023 17:27:48 +0800 (CST)",
            "from localhost.localdomain (10.50.163.32) by\n dggpeml100024.china.huawei.com (7.185.36.115) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id\n 15.1.2507.27; Thu, 20 Jul 2023 17:31:08 +0800"
        ],
        "From": "Chengwen Feng <fengchengwen@huawei.com>",
        "To": "<thomas@monjalon.net>, <david.marchand@redhat.com>",
        "CC": "<dev@dpdk.org>, <mb@smartsharesystems.com>, <anatoly.burakov@intel.com>,\n <dmitry.kozliuk@gmail.com>, <jerinjacobk@gmail.com>, <hofors@lysator.liu.se>,\n <stephen@networkplumber.org>",
        "Subject": "[PATCH v19 5/6] memarea: support dump API",
        "Date": "Thu, 20 Jul 2023 09:22:53 +0000",
        "Message-ID": "<20230720092254.54157-6-fengchengwen@huawei.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20230720092254.54157-1-fengchengwen@huawei.com>",
        "References": "<20220721044648.6817-1-fengchengwen@huawei.com>\n <20230720092254.54157-1-fengchengwen@huawei.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"UTF-8\"",
        "Content-Transfer-Encoding": "8bit",
        "X-Originating-IP": "[10.50.163.32]",
        "X-ClientProxiedBy": "dggems705-chm.china.huawei.com (10.3.19.182) To\n dggpeml100024.china.huawei.com (7.185.36.115)",
        "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>\nReviewed-by: Dongdong Liu <liudongdong3@huawei.com>\nAcked-by: Morten Brørup <mb@smartsharesystems.com>\nAcked-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n doc/guides/prog_guide/memarea_lib.rst |   3 +\n lib/memarea/rte_memarea.c             | 100 ++++++++++++++++++++++++++\n lib/memarea/rte_memarea.h             |  21 ++++++\n lib/memarea/version.map               |   1 +\n 4 files changed, 125 insertions(+)",
    "diff": "diff --git a/doc/guides/prog_guide/memarea_lib.rst b/doc/guides/prog_guide/memarea_lib.rst\nindex 157baf3c7e..ef22294664 100644\n--- a/doc/guides/prog_guide/memarea_lib.rst\n+++ b/doc/guides/prog_guide/memarea_lib.rst\n@@ -39,6 +39,9 @@ the memarea.\n The ``rte_memarea_free()`` function is used to free one memory object which\n allocated by ``rte_memarea_alloc()``.\n \n++The ``rte_memarea_dump()`` function is used to dump the internal information\n++of a memarea.\n+\n Debug Mode\n ----------\n \ndiff --git a/lib/memarea/rte_memarea.c b/lib/memarea/rte_memarea.c\nindex 7a35c875a7..d5d9a46736 100644\n--- a/lib/memarea/rte_memarea.c\n+++ b/lib/memarea/rte_memarea.c\n@@ -361,3 +361,103 @@ rte_memarea_free(struct rte_memarea *ma, void *ptr)\n \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_algorithm alg)\n+{\n+\tif (alg == RTE_MEMAREA_ALGORITHM_NEXTFIT)\n+\t\treturn \"nextfit\";\n+\telse\n+\t\treturn \"unknown\";\n+}\n+\n+static void\n+memarea_dump_objects_brief(struct rte_memarea *ma, FILE *f)\n+{\n+\tuint32_t total_objs = 0, total_avail_objs = 0;\n+\tstruct memarea_objhdr *hdr;\n+\tsize_t total_avail_sz = 0;\n+\n+\tTAILQ_FOREACH(hdr, &ma->obj_list, obj_next) {\n+\t\tif (hdr == ma->guard_hdr)\n+\t\t\tbreak;\n+\t\tmemarea_check_cookie(ma, hdr, COOKIE_EXPECT_STATUS_VALID);\n+\t\ttotal_objs++;\n+\t\tif (!MEMAREA_OBJECT_IS_ALLOCATED(hdr)) {\n+\t\t\ttotal_avail_objs++;\n+\t\t\ttotal_avail_sz += MEMAREA_OBJECT_GET_SIZE(hdr);\n+\t\t}\n+\t}\n+\tfprintf(f, \"  total-objects: %u\\n\", total_objs);\n+\tfprintf(f, \"  total-avail-objects: %u\\n\", total_avail_objs);\n+\tfprintf(f, \"  total-avail-objects-size: 0x%zx\\n\", total_avail_sz);\n+}\n+\n+static void\n+memarea_dump_objects_detail(struct rte_memarea *ma, FILE *f)\n+{\n+\tstruct memarea_objhdr *hdr;\n+\tsize_t offset;\n+\tvoid *ptr;\n+\n+\tfprintf(f, \"  objects:\\n\");\n+\tTAILQ_FOREACH(hdr, &ma->obj_list, obj_next) {\n+\t\tif (hdr == ma->guard_hdr)\n+\t\t\tbreak;\n+\t\tmemarea_check_cookie(ma, hdr, COOKIE_EXPECT_STATUS_VALID);\n+\t\tptr = RTE_PTR_ADD(hdr, sizeof(struct memarea_objhdr));\n+\t\toffset = RTE_PTR_DIFF(ptr, ma->area_base);\n+#ifdef RTE_LIBRTE_MEMAREA_DEBUG\n+\t\tfprintf(f, \"    %p off: 0x%zx size: 0x%zx %s\\n\",\n+\t\t\tptr, offset, MEMAREA_OBJECT_GET_SIZE(hdr),\n+\t\t\tMEMAREA_OBJECT_IS_ALLOCATED(hdr) ? \"allocated\" : \"\");\n+#else\n+\t\tfprintf(f, \"    off: 0x%zx size: 0x%zx %s\\n\",\n+\t\t\toffset, MEMAREA_OBJECT_GET_SIZE(hdr),\n+\t\t\tMEMAREA_OBJECT_IS_ALLOCATED(hdr) ? \"allocated\" : \"\");\n+#endif\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\trte_errno = EINVAL;\n+\t\treturn -1;\n+\t}\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.heap.socket_id);\n+\telse if (ma->init.source == RTE_MEMAREA_SOURCE_MEMAREA)\n+\t\tfprintf(f, \"  source-memarea: %s\\n\", ma->init.ma.src->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+#ifdef RTE_LIBRTE_MEMAREA_DEBUG\n+\tfprintf(f, \"  area-base: %p\\n\", ma->area_base);\n+\tfprintf(f, \"  guard-header: %p\\n\", ma->guard_hdr);\n+#endif\n+\tmemarea_dump_objects_brief(ma, f);\n+\tif (dump_all)\n+\t\tmemarea_dump_objects_detail(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 bb1bd5bae5..fa57f6c455 100644\n--- a/lib/memarea/rte_memarea.h\n+++ b/lib/memarea/rte_memarea.h\n@@ -180,6 +180,27 @@ void *rte_memarea_alloc(struct rte_memarea *ma, size_t size);\n __rte_experimental\n void rte_memarea_free(struct rte_memarea *ma, void *ptr);\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 (the rte_errno is set).\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 effbd0b488..9513d91e0b 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 \n \tlocal: *;\n",
    "prefixes": [
        "v19",
        "5/6"
    ]
}