Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/116806/?format=api
http://patches.dpdk.org/api/patches/116806/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20220924074951.31814-8-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": "<20220924074951.31814-8-fengchengwen@huawei.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20220924074951.31814-8-fengchengwen@huawei.com", "date": "2022-09-24T07:49:48", "name": "[v3,07/10] memarea: support backup memory mechanism", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "0bc24e60be708103487e4df32f72f3d0ed0181c5", "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/20220924074951.31814-8-fengchengwen@huawei.com/mbox/", "series": [ { "id": 24808, "url": "http://patches.dpdk.org/api/series/24808/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=24808", "date": "2022-09-24T07:49:41", "name": "introduce memarea library", "version": 3, "mbox": "http://patches.dpdk.org/series/24808/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/116806/comments/", "check": "pending", "checks": "http://patches.dpdk.org/api/patches/116806/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 94628A0542;\n\tSat, 24 Sep 2022 09:56:52 +0200 (CEST)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 338AF42C0B;\n\tSat, 24 Sep 2022 09:56:19 +0200 (CEST)", "from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255])\n by mails.dpdk.org (Postfix) with ESMTP id A806942BD8\n for <dev@dpdk.org>; Sat, 24 Sep 2022 09:56:11 +0200 (CEST)", "from dggpeml500024.china.huawei.com (unknown [172.30.72.54])\n by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MZLnp6lQqz1P6wh;\n Sat, 24 Sep 2022 15:51:58 +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, 24 Sep 2022 15:56: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 v3 07/10] memarea: support backup memory mechanism", "Date": "Sat, 24 Sep 2022 07:49:48 +0000", "Message-ID": "<20220924074951.31814-8-fengchengwen@huawei.com>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20220924074951.31814-1-fengchengwen@huawei.com>", "References": "<20220721044648.6817-1-fengchengwen@huawei.com>\n <20220924074951.31814-1-fengchengwen@huawei.com>", "MIME-Version": "1.0", "Content-Type": "text/plain", "X-Originating-IP": "[10.67.165.24]", "X-ClientProxiedBy": "dggems701-chm.china.huawei.com (10.3.19.178) 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 backup memory mechanism, the memarea could use\nanother memarea as a backup.\n\nSigned-off-by: Chengwen Feng <fengchengwen@huawei.com>\n---\n doc/guides/prog_guide/memarea_lib.rst | 3 +++\n lib/memarea/memarea_private.h | 2 ++\n lib/memarea/rte_memarea.c | 22 ++++++++++++++++++++++\n lib/memarea/rte_memarea.h | 7 +++++++\n 4 files changed, 34 insertions(+)", "diff": "diff --git a/doc/guides/prog_guide/memarea_lib.rst b/doc/guides/prog_guide/memarea_lib.rst\nindex c77012fe44..842d35f77a 100644\n--- a/doc/guides/prog_guide/memarea_lib.rst\n+++ b/doc/guides/prog_guide/memarea_lib.rst\n@@ -25,6 +25,9 @@ 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.\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 b70830d0bb..f45191aa7f 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 = (void *)((uintptr_t)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@@ -200,6 +201,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@@ -221,6 +231,8 @@ rte_memarea_alloc(struct rte_memarea *ma, size_t size, uint32_t cookie)\n \t\tptr = (void *)((uintptr_t)elem + sizeof(struct memarea_elem));\n \t\tbreak;\n \t}\n+\tif (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@@ -283,6 +295,12 @@ rte_memarea_update_refcnt(struct rte_memarea *ma, void *ptr, int16_t value)\n \t\treturn;\n \n \tmemarea_lock(ma);\n+\tif (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@@ -373,10 +391,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 10b8229c64..348febab7f 100644\n--- a/lib/memarea/rte_memarea.h\n+++ b/lib/memarea/rte_memarea.h\n@@ -39,6 +39,9 @@\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 */\n \n #include <stdbool.h>\n@@ -105,6 +108,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": [ "v3", "07/10" ] }{ "id": 116806, "url": "