Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/117698/?format=api
https://patches.dpdk.org/api/patches/117698/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/20221008113343.30577-8-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": "<20221008113343.30577-8-fengchengwen@huawei.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20221008113343.30577-8-fengchengwen@huawei.com", "date": "2022-10-08T11:33:40", "name": "[v6,07/10] memarea: support backup memory mechanism", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "551c1b91fe5f391fe0f1cbe6e569577e1c251758", "submitter": { "id": 2146, "url": "https://patches.dpdk.org/api/people/2146/?format=api", "name": "fengchengwen", "email": "fengchengwen@huawei.com" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/20221008113343.30577-8-fengchengwen@huawei.com/mbox/", "series": [ { "id": 25049, "url": "https://patches.dpdk.org/api/series/25049/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=25049", "date": "2022-10-08T11:33:34", "name": "introduce memarea library", "version": 6, "mbox": "https://patches.dpdk.org/series/25049/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/117698/comments/", "check": "pending", "checks": "https://patches.dpdk.org/api/patches/117698/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 7631FA0542;\n\tSat, 8 Oct 2022 13:40:13 +0200 (CEST)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 1D34E42BDE;\n\tSat, 8 Oct 2022 13:39:38 +0200 (CEST)", "from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187])\n by mails.dpdk.org (Postfix) with ESMTP id CEF3742BB8\n for <dev@dpdk.org>; Sat, 8 Oct 2022 13:39:30 +0200 (CEST)", "from dggpeml500024.china.huawei.com (unknown [172.30.72.57])\n by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Ml34Z4ky2zlXhT;\n Sat, 8 Oct 2022 19:34:54 +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; Sat, 8 Oct 2022 19:39:24 +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>, <datshan@qq.com>", "Subject": "[PATCH v6 07/10] memarea: support backup memory mechanism", "Date": "Sat, 8 Oct 2022 11:33:40 +0000", "Message-ID": "<20221008113343.30577-8-fengchengwen@huawei.com>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20221008113343.30577-1-fengchengwen@huawei.com>", "References": "<20220721044648.6817-1-fengchengwen@huawei.com>\n <20221008113343.30577-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": "This patch adds a memarea backup mechanism, where an allocation request\nwhich cannot be met by the current memarea is deferred to its backup\nmemarea.\n\nSigned-off-by: Chengwen Feng <fengchengwen@huawei.com>\n---\n doc/guides/prog_guide/memarea_lib.rst | 4 ++++\n lib/memarea/memarea_private.h | 2 ++\n lib/memarea/rte_memarea.c | 22 ++++++++++++++++++++++\n lib/memarea/rte_memarea.h | 11 +++++++++++\n 4 files changed, 39 insertions(+)", "diff": "diff --git a/doc/guides/prog_guide/memarea_lib.rst b/doc/guides/prog_guide/memarea_lib.rst\nindex 720d8099e2..feebafabcc 100644\n--- a/doc/guides/prog_guide/memarea_lib.rst\n+++ b/doc/guides/prog_guide/memarea_lib.rst\n@@ -25,6 +25,10 @@ The main features are as follows:\n \n * It supports MT-safe as long as it's specified at creation time.\n \n+* It provides backup memory mechanism, the memarea could use another memarea\n+ as a backup. It will attempts to allocate object from backup memarea when\n+ the current memarea failed to allocate.\n+\n Library API Overview\n --------------------\n \ndiff --git a/lib/memarea/memarea_private.h b/lib/memarea/memarea_private.h\nindex 98406879b9..08735ca81f 100644\n--- a/lib/memarea/memarea_private.h\n+++ b/lib/memarea/memarea_private.h\n@@ -23,11 +23,13 @@ struct rte_memarea {\n \tstruct rte_memarea_param init;\n \trte_spinlock_t lock;\n \tvoid *area_addr;\n+\tvoid *top_addr;\n \tstruct memarea_elem_list elem_list;\n \tstruct memarea_elem_list free_list;\n \n \tuint64_t alloc_fails;\n \tuint64_t refcnt_check_fails;\n+\tuint64_t bak_alloc_fails;\n } __rte_cache_aligned;\n \n #endif /* MEMAREA_PRIVATE_H */\ndiff --git a/lib/memarea/rte_memarea.c b/lib/memarea/rte_memarea.c\nindex bc51d2a5ff..f95f89b6ec 100644\n--- a/lib/memarea/rte_memarea.c\n+++ b/lib/memarea/rte_memarea.c\n@@ -132,6 +132,7 @@ rte_memarea_create(const struct rte_memarea_param *init)\n \tTAILQ_INIT(&ma->elem_list);\n \tTAILQ_INIT(&ma->free_list);\n \tma->area_addr = addr;\n+\tma->top_addr = RTE_PTR_ADD(addr, init->total_sz - 1);\n \telem = addr;\n \telem->size = init->total_sz - sizeof(struct memarea_elem);\n \telem->cookie = MEMAREA_FREE_ELEM_COOKIE;\n@@ -198,6 +199,15 @@ memarea_add_node(struct rte_memarea *ma, struct memarea_elem *elem, size_t need_\n \telem->size = align_size;\n }\n \n+static inline void *\n+memarea_alloc_backup(struct rte_memarea *ma, size_t size, uint32_t cookie)\n+{\n+\tvoid *ptr = rte_memarea_alloc(ma->init.bak_memarea, size, cookie);\n+\tif (unlikely(ptr == NULL))\n+\t\tma->bak_alloc_fails++;\n+\treturn ptr;\n+}\n+\n void *\n rte_memarea_alloc(struct rte_memarea *ma, size_t size, uint32_t cookie)\n {\n@@ -219,6 +229,8 @@ rte_memarea_alloc(struct rte_memarea *ma, size_t size, uint32_t cookie)\n \t\tptr = RTE_PTR_ADD(elem, sizeof(struct memarea_elem));\n \t\tbreak;\n \t}\n+\tif (unlikely(ptr == NULL && ma->init.bak_memarea != NULL))\n+\t\tptr = memarea_alloc_backup(ma, size, cookie);\n \tif (unlikely(ptr == NULL))\n \t\tma->alloc_fails++;\n \tmemarea_unlock(ma);\n@@ -281,6 +293,12 @@ rte_memarea_update_refcnt(struct rte_memarea *ma, void *ptr, int16_t value)\n \t\treturn;\n \n \tmemarea_lock(ma);\n+\tif (unlikely(ptr < ma->area_addr || ptr > ma->top_addr)) {\n+\t\trte_memarea_update_refcnt(ma->init.bak_memarea, ptr, value);\n+\t\tmemarea_unlock(ma);\n+\t\treturn;\n+\t}\n+\n \tif (unlikely(elem->refcnt <= 0 || elem->refcnt + value < 0)) {\n \t\tRTE_LOG(ERR, MEMAREA,\n \t\t\t\"memarea: %s cookie: 0x%x curr refcnt: %d update refcnt: %d check fail!\\n\",\n@@ -371,10 +389,14 @@ rte_memarea_dump(struct rte_memarea *ma, FILE *f, bool dump_all)\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+\tif (ma->init.bak_memarea)\n+\t\tfprintf(f, \" backup-memarea-name: %s\\n\", ma->init.bak_memarea->init.name);\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 (ma->init.bak_memarea)\n+\t\tfprintf(f, \" backup_alloc_fails: %\" PRIu64 \"\\n\", ma->bak_alloc_fails);\n \tif (dump_all)\n \t\tmemarea_dump_all(ma, f);\n \tmemarea_unlock(ma);\ndiff --git a/lib/memarea/rte_memarea.h b/lib/memarea/rte_memarea.h\nindex 4bf2f36c7c..815d0e3d75 100644\n--- a/lib/memarea/rte_memarea.h\n+++ b/lib/memarea/rte_memarea.h\n@@ -40,6 +40,13 @@\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+ * - It provides backup memory mechanism, the memarea could use another memarea\n+ * as a backup. It will attempts to allocate object from backup memarea when\n+ * the current memarea failed to allocate.\n+ * @note If the backup memarea is set improperly, loops may occur (e.g.\n+ * memarea-1's backup is memarea-2, and memarea-2's backup is memarea-1) and\n+ * the program will hangs, it is the responsibility of the application to\n+ * ensure that the loops do not form.\n */\n \n #include <stdbool.h>\n@@ -106,6 +113,10 @@ struct rte_memarea_param {\n \t\t */\n \t\tstruct rte_memarea *user_memarea;\n \t};\n+\t/** Backup memarea, which is used to handle the scenario where the\n+\t * current memarea allocation failure.\n+\t */\n+\tstruct rte_memarea *bak_memarea;\n };\n \n /**\n", "prefixes": [ "v6", "07/10" ] }{ "id": 117698, "url": "