get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 116520,
    "url": "http://patches.dpdk.org/api/patches/116520/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20220921031256.4954-2-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": "<20220921031256.4954-2-fengchengwen@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20220921031256.4954-2-fengchengwen@huawei.com",
    "date": "2022-09-21T03:12:48",
    "name": "[v2,1/9] memarea: introduce memory area library",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "a8d485a76df3f6b1564f7a1dd8346f62c773987f",
    "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/20220921031256.4954-2-fengchengwen@huawei.com/mbox/",
    "series": [
        {
            "id": 24741,
            "url": "http://patches.dpdk.org/api/series/24741/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=24741",
            "date": "2022-09-21T03:12:47",
            "name": "introduce memarea library",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/24741/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/116520/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/116520/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 D4C4AA034C;\n\tWed, 21 Sep 2022 05:19:19 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 96E2F410EE;\n\tWed, 21 Sep 2022 05:19:15 +0200 (CEST)",
            "from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255])\n by mails.dpdk.org (Postfix) with ESMTP id 00B344014F\n for <dev@dpdk.org>; Wed, 21 Sep 2022 05:19:12 +0200 (CEST)",
            "from dggpeml500024.china.huawei.com (unknown [172.30.72.55])\n by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MXNng3TK6z14RDX;\n Wed, 21 Sep 2022 11:15:03 +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; Wed, 21 Sep 2022 11:19:09 +0800"
        ],
        "From": "Chengwen Feng <fengchengwen@huawei.com>",
        "To": "<thomas@monjalon.net>",
        "CC": "<dev@dpdk.org>, <stephen@networkplumber.org>, <jerinjacobk@gmail.com>,\n <dmitry.kozliuk@gmail.com>",
        "Subject": "[PATCH v2 1/9] memarea: introduce memory area library",
        "Date": "Wed, 21 Sep 2022 03:12:48 +0000",
        "Message-ID": "<20220921031256.4954-2-fengchengwen@huawei.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20220921031256.4954-1-fengchengwen@huawei.com>",
        "References": "<20220721044648.6817-1-fengchengwen@huawei.com>\n <20220921031256.4954-1-fengchengwen@huawei.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[10.67.165.24]",
        "X-ClientProxiedBy": "dggems704-chm.china.huawei.com (10.3.19.181) 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": "The memarea library is an allocator of variable-size object. It is a\ncollection of allocated objects that can be efficiently alloc or free\nall at once, the main features are as follows:\na) it facilitate alloc and free of memory with low overhead.\n\nb) it provides refcnt feature which could be useful in some scenes.\n\nc) it supports MT-safe as long as it's specified at creation time.\n\nd) it's memory source could comes from:\nd.1) system API: malloc in C library.\nd.2) user provided address: it can be from the rte_malloc API series\nor extended memory as long as it is available.\nd.3) user provided memarea: it can be from another memarea.\n\nThis patch provides create/destroy API.\n\nSigned-off-by: Chengwen Feng <fengchengwen@huawei.com>\n---\n MAINTAINERS                            |   5 +\n doc/api/doxy-api-index.md              |   3 +-\n doc/api/doxy-api.conf.in               |   1 +\n doc/guides/prog_guide/index.rst        |   1 +\n doc/guides/prog_guide/memarea_lib.rst  |  41 +++++++\n doc/guides/rel_notes/release_22_11.rst |   6 ++\n lib/eal/include/rte_log.h              |   1 +\n lib/memarea/memarea_private.h          |  30 ++++++\n lib/memarea/meson.build                |  16 +++\n lib/memarea/rte_memarea.c              | 144 +++++++++++++++++++++++++\n lib/memarea/rte_memarea.h              | 127 ++++++++++++++++++++++\n lib/memarea/version.map                |  12 +++\n lib/meson.build                        |   1 +\n 13 files changed, 387 insertions(+), 1 deletion(-)\n create mode 100644 doc/guides/prog_guide/memarea_lib.rst\n create mode 100644 lib/memarea/memarea_private.h\n create mode 100644 lib/memarea/meson.build\n create mode 100644 lib/memarea/rte_memarea.c\n create mode 100644 lib/memarea/rte_memarea.h\n create mode 100644 lib/memarea/version.map",
    "diff": "diff --git a/MAINTAINERS b/MAINTAINERS\nindex 26d3a7077c..4d5bf986c6 100644\n--- a/MAINTAINERS\n+++ b/MAINTAINERS\n@@ -1558,6 +1558,11 @@ F: app/test/test_lpm*\n F: app/test/test_func_reentrancy.c\n F: app/test/test_xmmt_ops.h\n \n+Memarea - EXPERIMENTAL\n+M: Chengwen Feng <fengchengwen@huawei.com>\n+F: lib/memarea\n+F: doc/guides/prog_guide/memarea_lib.rst\n+\n Membership - EXPERIMENTAL\n M: Yipeng Wang <yipeng1.wang@intel.com>\n M: Sameh Gobriel <sameh.gobriel@intel.com>\ndiff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md\nindex 186a258be4..25dbef0b68 100644\n--- a/doc/api/doxy-api-index.md\n+++ b/doc/api/doxy-api-index.md\n@@ -64,7 +64,8 @@ The public API headers are grouped by topics:\n   [memzone](@ref rte_memzone.h),\n   [mempool](@ref rte_mempool.h),\n   [malloc](@ref rte_malloc.h),\n-  [memcpy](@ref rte_memcpy.h)\n+  [memcpy](@ref rte_memcpy.h),\n+  [memarea](@ref rte_memarea.h)\n \n - **timers**:\n   [cycles](@ref rte_cycles.h),\ndiff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in\nindex 608494a7c0..bdc5d2b0d5 100644\n--- a/doc/api/doxy-api.conf.in\n+++ b/doc/api/doxy-api.conf.in\n@@ -55,6 +55,7 @@ INPUT                   = @TOPDIR@/doc/api/doxy-api-index.md \\\n                           @TOPDIR@/lib/latencystats \\\n                           @TOPDIR@/lib/lpm \\\n                           @TOPDIR@/lib/mbuf \\\n+                          @TOPDIR@/lib/memarea \\\n                           @TOPDIR@/lib/member \\\n                           @TOPDIR@/lib/mempool \\\n                           @TOPDIR@/lib/meter \\\ndiff --git a/doc/guides/prog_guide/index.rst b/doc/guides/prog_guide/index.rst\nindex 8564883018..e9015d65e3 100644\n--- a/doc/guides/prog_guide/index.rst\n+++ b/doc/guides/prog_guide/index.rst\n@@ -37,6 +37,7 @@ Programmer's Guide\n     hash_lib\n     toeplitz_hash_lib\n     efd_lib\n+    memarea_lib\n     member_lib\n     lpm_lib\n     lpm6_lib\ndiff --git a/doc/guides/prog_guide/memarea_lib.rst b/doc/guides/prog_guide/memarea_lib.rst\nnew file mode 100644\nindex 0000000000..1979f0a12c\n--- /dev/null\n+++ b/doc/guides/prog_guide/memarea_lib.rst\n@@ -0,0 +1,41 @@\n+..  SPDX-License-Identifier: BSD-3-Clause\n+    Copyright(c) 2022 HiSilicon Limited\n+\n+Memarea Library\n+===============\n+\n+Introduction\n+------------\n+\n+The memarea library provides an allocator of variable-size objects, it is\n+oriented towards the application layer, which could provides 'region-based\n+memory management' function [1].\n+\n+The main features are as follows:\n+\n+* It facilitate alloc and free of memory with low overhead.\n+\n+* It's memory source could comes from: 1) System API: e.g. malloc/memalign in\n+  C library. 2) User provided address: it can be from the rte_malloc API series\n+  or extended memory as long as it is available. 3) User provided memarea: it\n+  can be from another memarea.\n+\n+* The default aligement size is ``RTE_CACHE_LINE_SIZE``.\n+\n+* It provides refcnt feature which could be useful in some scenes.\n+\n+* It supports MT-safe as long as it's specified at creation time.\n+\n+Library API Overview\n+--------------------\n+\n+The ``rte_memarea_create()`` function is used to create a memarea object, the\n+function returns the pointer to the created memarea or ``NULL`` if the creation\n+failed.\n+\n+The ``rte_memarea_destroy()`` function is used to destroy a memarea object.\n+\n+Reference\n+---------\n+\n+[1] https://en.wikipedia.org/wiki/Region-based_memory_management\ndiff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst\nindex 8c021cf050..1cf522132c 100644\n--- a/doc/guides/rel_notes/release_22_11.rst\n+++ b/doc/guides/rel_notes/release_22_11.rst\n@@ -55,6 +55,12 @@ New Features\n      Also, make sure to start the actual text at the margin.\n      =======================================================\n \n+* **Added memarea library.**\n+\n+  The memarea library is an allocator of variable-size objects, it is oriented\n+  towards the application layer, which could provides 'region-based memory\n+  management' function.\n+\n \n Removed Items\n -------------\ndiff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h\nindex 25ce42cdfc..708f3a39dd 100644\n--- a/lib/eal/include/rte_log.h\n+++ b/lib/eal/include/rte_log.h\n@@ -48,6 +48,7 @@ extern \"C\" {\n #define RTE_LOGTYPE_EFD       18 /**< Log related to EFD. */\n #define RTE_LOGTYPE_EVENTDEV  19 /**< Log related to eventdev. */\n #define RTE_LOGTYPE_GSO       20 /**< Log related to GSO. */\n+#define RTE_LOGTYPE_MEMAREA   21 /**< Log related to memarea. */\n \n /* these log types can be used in an application */\n #define RTE_LOGTYPE_USER1     24 /**< User-defined log type 1. */\ndiff --git a/lib/memarea/memarea_private.h b/lib/memarea/memarea_private.h\nnew file mode 100644\nindex 0000000000..c76392d3e6\n--- /dev/null\n+++ b/lib/memarea/memarea_private.h\n@@ -0,0 +1,30 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2022 HiSilicon Limited\n+ */\n+\n+#ifndef MEMAREA_PRIVATE_H\n+#define MEMAREA_PRIVATE_H\n+\n+#include <rte_memarea.h>\n+\n+#define MEMAREA_FREE_ELEM_COOKIE\t0xFFFFFFFF\n+\n+struct memarea_elem {\n+\tsize_t   size;\n+\tuint32_t cookie;\n+\tint32_t  refcnt; /* Non-zero indicates that it has been allocated */\n+\tTAILQ_ENTRY(memarea_elem) elem_node;\n+\tTAILQ_ENTRY(memarea_elem) free_node;\n+} __rte_cache_aligned;\n+\n+TAILQ_HEAD(memarea_elem_list, memarea_elem);\n+\n+struct rte_memarea {\n+\tstruct rte_memarea_param init;\n+\trte_spinlock_t           lock;\n+\tvoid                    *area_addr;\n+\tstruct memarea_elem_list elem_list;\n+\tstruct memarea_elem_list free_list;\n+} __rte_cache_aligned;\n+\n+#endif /* MEMAREA_PRIVATE_H */\ndiff --git a/lib/memarea/meson.build b/lib/memarea/meson.build\nnew file mode 100644\nindex 0000000000..0a74fb4cd1\n--- /dev/null\n+++ b/lib/memarea/meson.build\n@@ -0,0 +1,16 @@\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright(c) 2022 HiSilicon Limited\n+\n+if is_windows\n+    build = false\n+    reason = 'not supported on Windows'\n+    subdir_done()\n+endif\n+\n+sources = files(\n+        'rte_memarea.c',\n+)\n+headers = files(\n+        'rte_memarea.h',\n+)\n+deps += []\ndiff --git a/lib/memarea/rte_memarea.c b/lib/memarea/rte_memarea.c\nnew file mode 100644\nindex 0000000000..6e918dfaf9\n--- /dev/null\n+++ b/lib/memarea/rte_memarea.c\n@@ -0,0 +1,144 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2022 HiSilicon Limited\n+ */\n+\n+#include <stdio.h>\n+\n+#include <rte_common.h>\n+#include <rte_log.h>\n+#include <rte_malloc.h>\n+#include <rte_spinlock.h>\n+\n+#include \"rte_memarea.h\"\n+#include \"memarea_private.h\"\n+\n+static int\n+memarea_check_param(const struct rte_memarea_param *init)\n+{\n+\tsize_t len;\n+\n+\tif (init == NULL) {\n+\t\tRTE_LOG(ERR, MEMAREA, \"memarea init param is NULL!\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tlen = strnlen(init->name, RTE_MEMAREA_NAMESIZE);\n+\tif (len == 0 || len >= RTE_MEMAREA_NAMESIZE) {\n+\t\tRTE_LOG(ERR, MEMAREA, \"memarea name size %zu invalid!\\n\", len);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (init->source != RTE_MEMAREA_SOURCE_SYSTEM_API &&\n+\t    init->source != RTE_MEMAREA_SOURCE_USER_ADDR &&\n+\t    init->source != RTE_MEMAREA_SOURCE_USER_MEMAREA) {\n+\t\tRTE_LOG(ERR, MEMAREA, \"memarea: %s source: %d not supported!\\n\",\n+\t\t\tinit->name, init->source);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (init->total_sz <= sizeof(struct memarea_elem)) {\n+\t\tRTE_LOG(ERR, MEMAREA, \"memarea: %s total-size: %zu too small!\\n\",\n+\t\t\tinit->name, init->total_sz);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (init->source == RTE_MEMAREA_SOURCE_USER_ADDR && init->user_addr == NULL) {\n+\t\tRTE_LOG(ERR, MEMAREA, \"memarea: %s user provided addr is NULL!\\n\", init->name);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (init->source == RTE_MEMAREA_SOURCE_USER_ADDR &&\n+\t    ((uintptr_t)init->user_addr & (RTE_CACHE_LINE_SIZE - 1))) {\n+\t\tRTE_LOG(ERR, MEMAREA, \"memarea: %s user provided addr should align: %d!\\n\",\n+\t\t\tinit->name, RTE_CACHE_LINE_SIZE);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (init->source == RTE_MEMAREA_SOURCE_USER_MEMAREA && init->user_memarea == NULL) {\n+\t\tRTE_LOG(ERR, MEMAREA, \"memarea: %s user provided memarea is NULL!\\n\", init->name);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static void *\n+memarea_alloc_from_system_api(size_t size)\n+{\n+\tvoid *ptr = NULL;\n+\tint ret;\n+\n+\tret = posix_memalign(&ptr, RTE_CACHE_LINE_SIZE, size);\n+\tif (ret)\n+\t\treturn NULL;\n+\treturn ptr;\n+}\n+\n+static void *\n+memarea_alloc_area(const struct rte_memarea_param *init)\n+{\n+\tvoid *ptr = NULL;\n+\n+\tif (init->source == RTE_MEMAREA_SOURCE_SYSTEM_API)\n+\t\tptr = memarea_alloc_from_system_api(init->total_sz);\n+\telse if (init->source == RTE_MEMAREA_SOURCE_USER_ADDR)\n+\t\tptr = init->user_addr;\n+\n+\tif (ptr == NULL)\n+\t\tRTE_LOG(ERR, MEMAREA, \"memarea: %s alloc memory area fail!\\n\", init->name);\n+\n+\treturn ptr;\n+}\n+\n+struct rte_memarea *\n+rte_memarea_create(const struct rte_memarea_param *init)\n+{\n+\tstruct memarea_elem *elem;\n+\tstruct rte_memarea *ma;\n+\tvoid *addr;\n+\tint ret;\n+\n+\tret = memarea_check_param(init);\n+\tif (ret)\n+\t\treturn NULL;\n+\n+\taddr = memarea_alloc_area(init);\n+\tif (addr == NULL)\n+\t\treturn NULL;\n+\n+\tma = rte_zmalloc(NULL, sizeof(struct rte_memarea), RTE_CACHE_LINE_SIZE);\n+\tif (ma == NULL) {\n+\t\tRTE_LOG(ERR, MEMAREA, \"malloc memarea: %s management obj fail!\\n\", init->name);\n+\t\treturn NULL;\n+\t}\n+\n+\tma->init = *init;\n+\trte_spinlock_init(&ma->lock);\n+\tTAILQ_INIT(&ma->elem_list);\n+\tTAILQ_INIT(&ma->free_list);\n+\tma->area_addr = addr;\n+\telem = addr;\n+\telem->size = init->total_sz - sizeof(struct memarea_elem);\n+\telem->cookie = MEMAREA_FREE_ELEM_COOKIE;\n+\telem->refcnt = 0;\n+\tTAILQ_INSERT_TAIL(&ma->elem_list, elem, elem_node);\n+\tTAILQ_INSERT_TAIL(&ma->free_list, elem, free_node);\n+\n+\treturn ma;\n+}\n+\n+static void\n+memarea_free_area(struct rte_memarea *ma)\n+{\n+\tif (ma->init.source == RTE_MEMAREA_SOURCE_SYSTEM_API)\n+\t\tfree(ma->area_addr);\n+}\n+\n+void\n+rte_memarea_destroy(struct rte_memarea *ma)\n+{\n+\tif (ma == NULL)\n+\t\treturn;\n+\tmemarea_free_area(ma);\n+\trte_free(ma);\n+}\ndiff --git a/lib/memarea/rte_memarea.h b/lib/memarea/rte_memarea.h\nnew file mode 100644\nindex 0000000000..15f6fabcb5\n--- /dev/null\n+++ b/lib/memarea/rte_memarea.h\n@@ -0,0 +1,127 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2022 HiSilicon Limited\n+ */\n+\n+#ifndef RTE_MEMAREA_H\n+#define RTE_MEMAREA_H\n+\n+/**\n+ * @file\n+ * RTE Memarea.\n+ *\n+ * A memory area is an allocator of variable-size object. It is identified\n+ * by its name.\n+ *\n+ * The memarea is a collection of allocated objects that can be efficiently\n+ * alloc or free all at once, the main feature are as follows:\n+ *   a) It facilitate alloc and free of memory with low overhead.\n+ *   b) It's memory source could comes from:\n+ *      1) System API: malloc/memalign in C library.\n+ *      2) User provided address: it can be from the rte_malloc API series\n+ *         or extended memory as long as it is available. The address must be\n+ *         aligned to RTE_CACHE_LINE_SIZE.\n+ *      3) User provided memarea: it can be from another memarea. So we can\n+ *         build the following memory management structure:\n+ *         \\code{.unparsed}\n+ *                           -------------\n+ *                           | memarea-1 |\n+ *                           -------------\n+ *                                 |\n+ *                                 v\n+ *                  ------------------------------\n+ *                  |               |            |\n+ *                  v               v            v\n+ *            -------------   -------------   -------\n+ *            | memarea-2 |   | memarea-3 |   | obj |\n+ *            -------------   -------------   -------\n+ *         \\endcode\n+ *   c) The default alignment size is RTE_CACHE_LINE_SIZE.\n+ *   d) It provides refcnt feature which could be useful in some scenes.\n+ *   e) It supports MT-safe as long as it's specified at creation time. If not\n+ *      specified, all the functions of the memarea API are lock-free, and\n+ *      assume to not be invoked in parallel on different logical cores to work\n+ *      on the same memarea object.\n+ */\n+\n+#include <stdbool.h>\n+#include <stdint.h>\n+#include <stdio.h>\n+\n+#include <rte_compat.h>\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+#define RTE_MEMAREA_NAMESIZE\t64\n+\n+/**\n+ * Memarea memory source.\n+ */\n+enum rte_memarea_source {\n+\t/** Memory source comes from system API (e.g. malloc). */\n+\tRTE_MEMAREA_SOURCE_SYSTEM_API,\n+\t/** Memory source comes from user-provided address. */\n+\tRTE_MEMAREA_SOURCE_USER_ADDR,\n+\t/** Memory source comes from user-provided memarea. */\n+\tRTE_MEMAREA_SOURCE_USER_MEMAREA,\n+};\n+\n+struct rte_memarea;\n+\n+struct rte_memarea_param {\n+\tchar name[RTE_MEMAREA_NAMESIZE]; /**< Name of memarea. */\n+\tenum rte_memarea_source source;  /**< Memory source of memarea. */\n+\tsize_t total_sz;                 /**< total size (bytes) of memarea. */\n+\t/** Indicates whether the memarea API should be MT-safe. */\n+\tuint32_t mt_safe : 1;\n+\tunion {\n+\t\t/** User provided address, this field is valid only when the\n+\t\t * source is set to be RTE_MEMAREA_SOURCE_USER_ADDR.\n+\t\t * Note: the provided address must align at least\n+\t\t * RTE_CACHE_LINE_SIZE.\n+\t\t */\n+\t\tvoid *user_addr;\n+\t\t/** User provided memarea, this field is valid only when the\n+\t\t * source is set to be RTE_MEMAREA_SOURCE_USER_MEMAREA.\n+\t\t */\n+\t\tstruct rte_memarea *user_memarea;\n+\t};\n+};\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Create memarea.\n+ *\n+ * Create one new memarea.\n+ *\n+ * @param init\n+ *   The init parameter of memarea.\n+ *\n+ * @return\n+ *   Non-NULL on success. Otherwise NULL is returned.\n+ */\n+__rte_experimental\n+struct rte_memarea *rte_memarea_create(const struct rte_memarea_param *init);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Destroy memarea.\n+ *\n+ * Destroy the memarea.\n+ *\n+ * @param ma\n+ *   The pointer of memarea.\n+ */\n+__rte_experimental\n+void rte_memarea_destroy(struct rte_memarea *ma);\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif /* RTE_MEMAREA_H */\ndiff --git a/lib/memarea/version.map b/lib/memarea/version.map\nnew file mode 100644\nindex 0000000000..f36a04d7cf\n--- /dev/null\n+++ b/lib/memarea/version.map\n@@ -0,0 +1,12 @@\n+EXPERIMENTAL {\n+\tglobal:\n+\n+\trte_memarea_create;\n+\trte_memarea_destroy;\n+\n+\tlocal: *;\n+};\n+\n+INTERNAL {\n+\tlocal: *;\n+};\ndiff --git a/lib/meson.build b/lib/meson.build\nindex c648f7d800..521a25d6c0 100644\n--- a/lib/meson.build\n+++ b/lib/meson.build\n@@ -42,6 +42,7 @@ libraries = [\n         'kni',\n         'latencystats',\n         'lpm',\n+        'memarea',\n         'member',\n         'pcapng',\n         'power',\n",
    "prefixes": [
        "v2",
        "1/9"
    ]
}