Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/64370/?format=api
http://patches.dpdk.org/api/patches/64370/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200109132742.15828-1-olivier.matz@6wind.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": "<20200109132742.15828-1-olivier.matz@6wind.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20200109132742.15828-1-olivier.matz@6wind.com", "date": "2020-01-09T13:27:42", "name": "mempool: fix slow allocation of large mempools", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "9ea23698deb3f165b0fadcb8d07809161b011c95", "submitter": { "id": 8, "url": "http://patches.dpdk.org/api/people/8/?format=api", "name": "Olivier Matz", "email": "olivier.matz@6wind.com" }, "delegate": { "id": 24651, "url": "http://patches.dpdk.org/api/users/24651/?format=api", "username": "dmarchand", "first_name": "David", "last_name": "Marchand", "email": "david.marchand@redhat.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20200109132742.15828-1-olivier.matz@6wind.com/mbox/", "series": [ { "id": 8038, "url": "http://patches.dpdk.org/api/series/8038/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=8038", "date": "2020-01-09T13:27:42", "name": "mempool: fix slow allocation of large mempools", "version": 1, "mbox": "http://patches.dpdk.org/series/8038/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/64370/comments/", "check": "fail", "checks": "http://patches.dpdk.org/api/patches/64370/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 D01E5A046B;\n\tThu, 9 Jan 2020 14:27:51 +0100 (CET)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id A22E21DD7C;\n\tThu, 9 Jan 2020 14:27:51 +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 567701DBA7;\n Thu, 9 Jan 2020 14:27:50 +0100 (CET)", "from glumotte.dev.6wind.com. (unknown [10.16.0.195])\n by proxy.6wind.com (Postfix) with ESMTP id 369FF366808;\n Thu, 9 Jan 2020 14:27:50 +0100 (CET)" ], "From": "Olivier Matz <olivier.matz@6wind.com>", "To": "dev@dpdk.org", "Cc": "Andrew Rybchenko <arybchenko@solarflare.com>,\n Anatoly Burakov <anatoly.burakov@intel.com>, stable@dpdk.org", "Date": "Thu, 9 Jan 2020 14:27:42 +0100", "Message-Id": "<20200109132742.15828-1-olivier.matz@6wind.com>", "X-Mailer": "git-send-email 2.20.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[dpdk-dev] [PATCH] mempool: fix slow allocation of large mempools", "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": "When allocating a mempool which is larger than the largest\navailable area, it can take a lot of time:\n\na- the mempool calculate the required memory size, and tries\n to allocate it, it fails\nb- then it tries to allocate the largest available area (this\n does not request new huge pages)\nc- add this zone to the mempool, this triggers the allocation\n of a mem hdr, which request a new huge page\nd- back to a- until mempool is populated or until there is no\n more memory\n\nThis can take a lot of time to finally fail (several minutes): in step\na- it takes all available hugepages on the system, then release them\nafter it fails.\n\nThe problem appeared with commit eba11e364614 (\"mempool: reduce wasted\nspace on populate\"), because smaller chunks are now allowed. Previously,\nit had to be at least one page size, which is not the case in step b-.\n\nTo fix this, implement our own way to allocate the largest available\narea instead of using the feature from memzone: if an allocation fails,\ntry to divide the size by 2 and retry. When the requested size falls\nbelow min_chunk_size, stop and return an error.\n\nFixes: eba11e364614 (\"mempool: reduce wasted space on populate\")\nCc: stable@dpdk.org\n\nSigned-off-by: Olivier Matz <olivier.matz@6wind.com>\n---\n lib/librte_mempool/rte_mempool.c | 29 ++++++++++++-----------------\n 1 file changed, 12 insertions(+), 17 deletions(-)", "diff": "diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c\nindex bda361ce6..03c8d984c 100644\n--- a/lib/librte_mempool/rte_mempool.c\n+++ b/lib/librte_mempool/rte_mempool.c\n@@ -481,6 +481,7 @@ rte_mempool_populate_default(struct rte_mempool *mp)\n \tunsigned mz_id, n;\n \tint ret;\n \tbool need_iova_contig_obj;\n+\tsize_t max_alloc_size = SIZE_MAX;\n \n \tret = mempool_ops_alloc_once(mp);\n \tif (ret != 0)\n@@ -560,30 +561,24 @@ rte_mempool_populate_default(struct rte_mempool *mp)\n \t\tif (min_chunk_size == (size_t)mem_size)\n \t\t\tmz_flags |= RTE_MEMZONE_IOVA_CONTIG;\n \n-\t\tmz = rte_memzone_reserve_aligned(mz_name, mem_size,\n+\t\t/* Allocate a memzone, retrying with a smaller area on ENOMEM */\n+\t\tdo {\n+\t\t\tmz = rte_memzone_reserve_aligned(mz_name,\n+\t\t\t\tRTE_MIN((size_t)mem_size, max_alloc_size),\n \t\t\t\tmp->socket_id, mz_flags, align);\n \n-\t\t/* don't try reserving with 0 size if we were asked to reserve\n-\t\t * IOVA-contiguous memory.\n-\t\t */\n-\t\tif (min_chunk_size < (size_t)mem_size && mz == NULL) {\n-\t\t\t/* not enough memory, retry with the biggest zone we\n-\t\t\t * have\n-\t\t\t */\n-\t\t\tmz = rte_memzone_reserve_aligned(mz_name, 0,\n-\t\t\t\t\tmp->socket_id, mz_flags, align);\n-\t\t}\n+\t\t\tif (mz == NULL && rte_errno != ENOMEM)\n+\t\t\t\tbreak;\n+\n+\t\t\tmax_alloc_size = RTE_MIN(max_alloc_size,\n+\t\t\t\t\t\t(size_t)mem_size) / 2;\n+\t\t} while (max_alloc_size >= min_chunk_size);\n+\n \t\tif (mz == NULL) {\n \t\t\tret = -rte_errno;\n \t\t\tgoto fail;\n \t\t}\n \n-\t\tif (mz->len < min_chunk_size) {\n-\t\t\trte_memzone_free(mz);\n-\t\t\tret = -ENOMEM;\n-\t\t\tgoto fail;\n-\t\t}\n-\n \t\tif (need_iova_contig_obj)\n \t\t\tiova = mz->iova;\n \t\telse\n", "prefixes": [] }{ "id": 64370, "url": "