get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 118048,
    "url": "http://patchwork.dpdk.org/api/patches/118048/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20221012104805.44185-2-fengchengwen@huawei.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.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": "<20221012104805.44185-2-fengchengwen@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20221012104805.44185-2-fengchengwen@huawei.com",
    "date": "2022-10-12T10:47:59",
    "name": "[v9,1/7] memarea: introduce memarea library",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "3cc69c6a882e2371eaf999098d18ab76bf0197f9",
    "submitter": {
        "id": 2146,
        "url": "http://patchwork.dpdk.org/api/people/2146/?format=api",
        "name": "fengchengwen",
        "email": "fengchengwen@huawei.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20221012104805.44185-2-fengchengwen@huawei.com/mbox/",
    "series": [
        {
            "id": 25175,
            "url": "http://patchwork.dpdk.org/api/series/25175/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=25175",
            "date": "2022-10-12T10:47:58",
            "name": "introduce memarea library",
            "version": 9,
            "mbox": "http://patchwork.dpdk.org/series/25175/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/118048/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/118048/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 621B1A00C4;\n\tWed, 12 Oct 2022 12:54:23 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id C96AF4302C;\n\tWed, 12 Oct 2022 12:53: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 09CCD42D6E\n for <dev@dpdk.org>; Wed, 12 Oct 2022 12:53:51 +0200 (CEST)",
            "from dggpeml500024.china.huawei.com (unknown [172.30.72.54])\n by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MnTsY3vNmzHtvW;\n Wed, 12 Oct 2022 18:48:49 +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, 12 Oct 2022 18:53:49 +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 v9 1/7] memarea: introduce memarea library",
        "Date": "Wed, 12 Oct 2022 10:47:59 +0000",
        "Message-ID": "<20221012104805.44185-2-fengchengwen@huawei.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20221012104805.44185-1-fengchengwen@huawei.com>",
        "References": "<20220721044648.6817-1-fengchengwen@huawei.com>\n <20221012104805.44185-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 which based\non a memory region.\n\nThis patch provides rte_memarea_create() and rte_memarea_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  |  39 +++++++\n doc/guides/rel_notes/release_22_11.rst |   6 ++\n lib/eal/common/eal_common_log.c        |   1 +\n lib/eal/include/rte_log.h              |   1 +\n lib/memarea/memarea_private.h          |  33 ++++++\n lib/memarea/meson.build                |  16 +++\n lib/memarea/rte_memarea.c              | 143 +++++++++++++++++++++++++\n lib/memarea/rte_memarea.h              | 124 +++++++++++++++++++++\n lib/memarea/version.map                |  12 +++\n lib/meson.build                        |   1 +\n 14 files changed, 385 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 2bd4a55f1b..3d8d4c2dbe 100644\n--- a/MAINTAINERS\n+++ b/MAINTAINERS\n@@ -1551,6 +1551,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 de488c7abf..24456604f8 100644\n--- a/doc/api/doxy-api-index.md\n+++ b/doc/api/doxy-api-index.md\n@@ -62,7 +62,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 f0886c3bd1..8334ebcbd6 100644\n--- a/doc/api/doxy-api.conf.in\n+++ b/doc/api/doxy-api.conf.in\n@@ -53,6 +53,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..d032b24ce9\n--- /dev/null\n+++ b/doc/guides/prog_guide/memarea_lib.rst\n@@ -0,0 +1,39 @@\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, providing 'region-based memory\n+management' function [1].\n+\n+The main features are as follows:\n+\n+* The memory region can be initialized from the following memory sources:\n+\n+  - HEAP: e.g. invoke ``rte_malloc_socket``.\n+\n+  - LIBC: e.g. invoke posix_memalign.\n+\n+  - Another memarea: it can be allocated from another memarea.\n+\n+* It provides refcnt feature which could be useful in multi-reader scenario.\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, the function\n+returns the pointer to the created memarea or ``NULL`` if the creation failed.\n+\n+The ``rte_memarea_destroy()`` function is used to destroy a memarea.\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 2da8bc9661..f8e3a23db7 100644\n--- a/doc/guides/rel_notes/release_22_11.rst\n+++ b/doc/guides/rel_notes/release_22_11.rst\n@@ -63,6 +63,12 @@ New Features\n   In theory this implementation should work with any target based on\n   ``LoongArch`` ISA.\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, providing 'region-based memory management'\n+  function.\n+\n * **Added support for multiple mbuf pools per ethdev Rx queue.**\n \n   The capability allows application to provide many mempools\ndiff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c\nindex bd7b188ceb..3d62af59c6 100644\n--- a/lib/eal/common/eal_common_log.c\n+++ b/lib/eal/common/eal_common_log.c\n@@ -369,6 +369,7 @@ static const struct logtype logtype_strings[] = {\n \t{RTE_LOGTYPE_EFD,        \"lib.efd\"},\n \t{RTE_LOGTYPE_EVENTDEV,   \"lib.eventdev\"},\n \t{RTE_LOGTYPE_GSO,        \"lib.gso\"},\n+\t{RTE_LOGTYPE_MEMAREA,    \"lib.memarea\"},\n \t{RTE_LOGTYPE_USER1,      \"user1\"},\n \t{RTE_LOGTYPE_USER2,      \"user2\"},\n \t{RTE_LOGTYPE_USER3,      \"user3\"},\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..59be9c1d00\n--- /dev/null\n+++ b/lib/memarea/memarea_private.h\n@@ -0,0 +1,33 @@\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_AVAILABLE_ELEM_MAGIC\t0xbeef1234\n+#define MEMAREA_ALLOCATED_ELEM_MAGIC\t0xbeef1230\n+#define MEMAREA_AVAILABLE_ELEM_COOKIE\t0xffffffff\n+\n+struct memarea_elem {\n+\tTAILQ_ENTRY(memarea_elem) elem_node;\n+\tTAILQ_ENTRY(memarea_elem) free_node;\n+\tsize_t   size;\n+\tuint32_t magic;\n+\tuint32_t cookie;\n+\tint32_t  refcnt; /* Non-zero indicates that it has been allocated */\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..60b8fa8612\n--- /dev/null\n+++ b/lib/memarea/rte_memarea.c\n@@ -0,0 +1,143 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2022 HiSilicon Limited\n+ */\n+\n+#include <stdio.h>\n+#include <stdlib.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_HEAP &&\n+\t    init->source != RTE_MEMAREA_SOURCE_LIBC &&\n+\t    init->source != RTE_MEMAREA_SOURCE_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_MEMAREA && init->src_memarea == NULL) {\n+\t\tRTE_LOG(ERR, MEMAREA, \"memarea: %s source memarea is NULL!\\n\", init->name);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (init->alg != RTE_MEMAREA_ALG_NEXTFIT) {\n+\t\tRTE_LOG(ERR, MEMAREA, \"memarea: %s alg: %d not supported!\\n\",\n+\t\t\tinit->name, init->alg);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static void *\n+memarea_alloc_from_libc(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_HEAP)\n+\t\tptr = rte_malloc_socket(NULL, init->total_sz, RTE_CACHE_LINE_SIZE,\n+\t\t\t\t\tinit->numa_socket);\n+\telse if (init->source == RTE_MEMAREA_SOURCE_LIBC)\n+\t\tptr = memarea_alloc_from_libc(init->total_sz);\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+\tTAILQ_INSERT_TAIL(&ma->elem_list, elem, elem_node);\n+\tTAILQ_INSERT_TAIL(&ma->free_list, elem, free_node);\n+\telem->size = init->total_sz - sizeof(struct memarea_elem);\n+\telem->magic = MEMAREA_AVAILABLE_ELEM_MAGIC;\n+\telem->cookie = MEMAREA_AVAILABLE_ELEM_COOKIE;\n+\telem->refcnt = 0;\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_HEAP)\n+\t\trte_free(ma->area_addr);\n+\telse if (ma->init.source == RTE_MEMAREA_SOURCE_LIBC)\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..d48ceaf733\n--- /dev/null\n+++ b/lib/memarea/rte_memarea.h\n@@ -0,0 +1,124 @@\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+ * The memarea is an allocator of variable-size object which based on a memory\n+ * region. It has the following features:\n+ *\n+ * - The memory region can be initialized from the following memory sources:\n+ *   1. HEAP: e.g. invoke rte_malloc_socket.\n+ *   2. LIBC: e.g. invoke posix_memalign.\n+ *   3. Another memarea: it can be allocated from another memarea.\n+ *\n+ * - It provides refcnt feature which could be useful in multi-reader scenario.\n+ *\n+ * - 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 assume\n+ *   to not be invoked in parallel on different logical cores to work on the\n+ *   same memarea.\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 rte memory. */\n+\tRTE_MEMAREA_SOURCE_HEAP,\n+\t/** Memory source comes from libc. */\n+\tRTE_MEMAREA_SOURCE_LIBC,\n+\t/** Memory source comes from another memarea. */\n+\tRTE_MEMAREA_SOURCE_MEMAREA,\n+};\n+\n+/**\n+ * Memarea memory management algorithm.\n+ */\n+enum rte_memarea_alg {\n+\t/** The default management algorithm is a variant of the next fit\n+\t * algorithm. It uses a free-list to apply for memory and uses an\n+\t * element-list in ascending order of address to support merging\n+\t * upon free.\n+\t */\n+\tRTE_MEMAREA_ALG_NEXTFIT,\n+};\n+\n+struct rte_memarea;\n+\n+/**\n+ * Memarea creation parameters.\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+\tenum rte_memarea_alg alg;        /**< Memory management algorithm. */\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/** Numa socket from which to apply for memarea's memory, this\n+\t\t * field is valid only when the source is set to be\n+\t\t * RTE_MEMAREA_SOURCE_HEAP.\n+\t\t */\n+\t\tint numa_socket;\n+\t\t/** Source memarea, this field is valid only when the source is\n+\t\t * set to be RTE_MEMAREA_SOURCE_MEMAREA.\n+\t\t */\n+\t\tstruct rte_memarea *src_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 c51cdc24fa..87d621e792 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": [
        "v9",
        "1/7"
    ]
}