Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/62477/?format=api
http://patchwork.dpdk.org/api/patches/62477/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20191105153707.14645-3-olivier.matz@6wind.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": "<20191105153707.14645-3-olivier.matz@6wind.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20191105153707.14645-3-olivier.matz@6wind.com", "date": "2019-11-05T15:37:01", "name": "[v4,2/7] mempool: reduce wasted space on mempool populate", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "e61870ecee20e04f487039beb565ca8cbd344eda", "submitter": { "id": 8, "url": "http://patchwork.dpdk.org/api/people/8/?format=api", "name": "Olivier Matz", "email": "olivier.matz@6wind.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/20191105153707.14645-3-olivier.matz@6wind.com/mbox/", "series": [ { "id": 7258, "url": "http://patchwork.dpdk.org/api/series/7258/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=7258", "date": "2019-11-05T15:36:59", "name": "mempool: avoid objects allocations across pages", "version": 4, "mbox": "http://patchwork.dpdk.org/series/7258/mbox/" } ], "comments": "http://patchwork.dpdk.org/api/patches/62477/comments/", "check": "fail", "checks": "http://patchwork.dpdk.org/api/patches/62477/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 dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id A7FE3A04A2;\n\tTue, 5 Nov 2019 16:37:28 +0100 (CET)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id C3A811BFB0;\n\tTue, 5 Nov 2019 16:37:22 +0100 (CET)", "from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com\n [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id 57DE71BF9F\n for <dev@dpdk.org>; Tue, 5 Nov 2019 16:37:19 +0100 (CET)", "from glumotte.dev.6wind.com. (unknown [10.16.0.195])\n by proxy.6wind.com (Postfix) with ESMTP id 3A8A533B0EF;\n Tue, 5 Nov 2019 16:37:19 +0100 (CET)" ], "From": "Olivier Matz <olivier.matz@6wind.com>", "To": "dev@dpdk.org", "Cc": "Anatoly Burakov <anatoly.burakov@intel.com>,\n Andrew Rybchenko <arybchenko@solarflare.com>,\n Ferruh Yigit <ferruh.yigit@linux.intel.com>,\n \"Giridharan, Ganesan\" <ggiridharan@rbbn.com>,\n Jerin Jacob Kollanukkaran <jerinj@marvell.com>,\n \"Kiran Kumar Kokkilagadda\" <kirankumark@marvell.com>,\n Stephen Hemminger <sthemmin@microsoft.com>,\n Thomas Monjalon <thomas@monjalon.net>,\n Vamsi Krishna Attunuru <vattunuru@marvell.com>,\n Hemant Agrawal <hemant.agrawal@nxp.com>, Nipun Gupta <nipun.gupta@nxp.com>,\n David Marchand <david.marchand@redhat.com>", "Date": "Tue, 5 Nov 2019 16:37:01 +0100", "Message-Id": "<20191105153707.14645-3-olivier.matz@6wind.com>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20191105153707.14645-1-olivier.matz@6wind.com>", "References": "<20190719133845.32432-1-olivier.matz@6wind.com>\n <20191105153707.14645-1-olivier.matz@6wind.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[dpdk-dev] [PATCH v4 2/7] mempool: reduce wasted space on mempool\n\tpopulate", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "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", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "The size returned by rte_mempool_op_calc_mem_size_default() is aligned\nto the specified page size. Therefore, with big pages, the returned size\ncan be much more that what we really need to populate the mempool.\n\nFor instance, populating a mempool that requires 1.1GB of memory with\n1GB hugepages can result in allocating 2GB of memory.\n\nThis problem is hidden most of the time due to the allocation method of\nrte_mempool_populate_default(): when try_iova_contig_mempool=true, it\nfirst tries to allocate an iova contiguous area, without the alignment\nconstraint. If it fails, it fallbacks to an aligned allocation that does\nnot require to be iova-contiguous. This can also fallback into several\nsmaller aligned allocations.\n\nThis commit changes rte_mempool_op_calc_mem_size_default() to relax the\nalignment constraint to a cache line and to return a smaller size.\n\nSigned-off-by: Olivier Matz <olivier.matz@6wind.com>\nReviewed-by: Andrew Rybdhenko <arybchenko@solarflare.com>\nAcked-by: Nipun Gupta <nipun.gupta@nxp.com>\n---\n lib/librte_mempool/rte_mempool.c | 7 ++---\n lib/librte_mempool/rte_mempool.h | 9 +++----\n lib/librte_mempool/rte_mempool_ops.c | 4 ++-\n lib/librte_mempool/rte_mempool_ops_default.c | 28 +++++++++++++++-----\n 4 files changed, 30 insertions(+), 18 deletions(-)", "diff": "diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c\nindex 88e49c751..4e0d576f5 100644\n--- a/lib/librte_mempool/rte_mempool.c\n+++ b/lib/librte_mempool/rte_mempool.c\n@@ -477,11 +477,8 @@ rte_mempool_populate_default(struct rte_mempool *mp)\n \t * wasting some space this way, but it's much nicer than looping around\n \t * trying to reserve each and every page size.\n \t *\n-\t * However, since size calculation will produce page-aligned sizes, it\n-\t * makes sense to first try and see if we can reserve the entire memzone\n-\t * in one contiguous chunk as well (otherwise we might end up wasting a\n-\t * 1G page on a 10MB memzone). If we fail to get enough contiguous\n-\t * memory, then we'll go and reserve space page-by-page.\n+\t * If we fail to get enough contiguous memory, then we'll go and\n+\t * reserve space in smaller chunks.\n \t *\n \t * We also have to take into account the fact that memory that we're\n \t * going to allocate from can belong to an externally allocated memory\ndiff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h\nindex 0fe8aa7b8..78b687bb6 100644\n--- a/lib/librte_mempool/rte_mempool.h\n+++ b/lib/librte_mempool/rte_mempool.h\n@@ -458,7 +458,7 @@ typedef unsigned (*rte_mempool_get_count)(const struct rte_mempool *mp);\n * @param[out] align\n * Location for required memory chunk alignment.\n * @return\n- * Required memory size aligned at page boundary.\n+ * Required memory size.\n */\n typedef ssize_t (*rte_mempool_calc_mem_size_t)(const struct rte_mempool *mp,\n \t\tuint32_t obj_num, uint32_t pg_shift,\n@@ -477,11 +477,8 @@ typedef ssize_t (*rte_mempool_calc_mem_size_t)(const struct rte_mempool *mp,\n * that pages are grouped in subsets of physically continuous pages big\n * enough to store at least one object.\n *\n- * Minimum size of memory chunk is a maximum of the page size and total\n- * element size.\n- *\n- * Required memory chunk alignment is a maximum of page size and cache\n- * line size.\n+ * Minimum size of memory chunk is the total element size.\n+ * Required memory chunk alignment is the cache line size.\n */\n ssize_t rte_mempool_op_calc_mem_size_default(const struct rte_mempool *mp,\n \t\tuint32_t obj_num, uint32_t pg_shift,\ndiff --git a/lib/librte_mempool/rte_mempool_ops.c b/lib/librte_mempool/rte_mempool_ops.c\nindex e02eb702c..22c5251eb 100644\n--- a/lib/librte_mempool/rte_mempool_ops.c\n+++ b/lib/librte_mempool/rte_mempool_ops.c\n@@ -100,7 +100,9 @@ rte_mempool_ops_get_count(const struct rte_mempool *mp)\n \treturn ops->get_count(mp);\n }\n \n-/* wrapper to notify new memory area to external mempool */\n+/* wrapper to calculate the memory size required to store given number\n+ * of objects\n+ */\n ssize_t\n rte_mempool_ops_calc_mem_size(const struct rte_mempool *mp,\n \t\t\t\tuint32_t obj_num, uint32_t pg_shift,\ndiff --git a/lib/librte_mempool/rte_mempool_ops_default.c b/lib/librte_mempool/rte_mempool_ops_default.c\nindex 4e2bfc82d..f6aea7662 100644\n--- a/lib/librte_mempool/rte_mempool_ops_default.c\n+++ b/lib/librte_mempool/rte_mempool_ops_default.c\n@@ -12,7 +12,7 @@ rte_mempool_op_calc_mem_size_default(const struct rte_mempool *mp,\n \t\t\t\t size_t *min_chunk_size, size_t *align)\n {\n \tsize_t total_elt_sz;\n-\tsize_t obj_per_page, pg_num, pg_sz;\n+\tsize_t obj_per_page, pg_sz, objs_in_last_page;\n \tsize_t mem_size;\n \n \ttotal_elt_sz = mp->header_size + mp->elt_size + mp->trailer_size;\n@@ -33,14 +33,30 @@ rte_mempool_op_calc_mem_size_default(const struct rte_mempool *mp,\n \t\t\tmem_size =\n \t\t\t\tRTE_ALIGN_CEIL(total_elt_sz, pg_sz) * obj_num;\n \t\t} else {\n-\t\t\tpg_num = (obj_num + obj_per_page - 1) / obj_per_page;\n-\t\t\tmem_size = pg_num << pg_shift;\n+\t\t\t/* In the best case, the allocator will return a\n+\t\t\t * page-aligned address. For example, with 5 objs,\n+\t\t\t * the required space is as below:\n+\t\t\t * | page0 | page1 | page2 (last) |\n+\t\t\t * |obj0 |obj1 |xxx|obj2 |obj3 |xxx|obj4|\n+\t\t\t * <------------- mem_size ------------->\n+\t\t\t */\n+\t\t\tobjs_in_last_page = ((obj_num - 1) % obj_per_page) + 1;\n+\t\t\t/* room required for the last page */\n+\t\t\tmem_size = objs_in_last_page * total_elt_sz;\n+\t\t\t/* room required for other pages */\n+\t\t\tmem_size += ((obj_num - objs_in_last_page) /\n+\t\t\t\tobj_per_page) << pg_shift;\n+\n+\t\t\t/* In the worst case, the allocator returns a\n+\t\t\t * non-aligned pointer, wasting up to\n+\t\t\t * total_elt_sz. Add a margin for that.\n+\t\t\t */\n+\t\t\t mem_size += total_elt_sz - 1;\n \t\t}\n \t}\n \n-\t*min_chunk_size = RTE_MAX((size_t)1 << pg_shift, total_elt_sz);\n-\n-\t*align = RTE_MAX((size_t)RTE_CACHE_LINE_SIZE, (size_t)1 << pg_shift);\n+\t*min_chunk_size = total_elt_sz;\n+\t*align = RTE_CACHE_LINE_SIZE;\n \n \treturn mem_size;\n }\n", "prefixes": [ "v4", "2/7" ] }{ "id": 62477, "url": "