* [dpdk-stable] [PATCH v2] mempool: fix memory allocation in memzones during retry. [not found] <1594611634-7730-1-git-send-email-wangzhike@jd.com> @ 2020-07-14 7:26 ` Zhike Wang 2020-07-14 9:32 ` [dpdk-stable] [dpdk-dev] " Burakov, Anatoly 0 siblings, 1 reply; 3+ messages in thread From: Zhike Wang @ 2020-07-14 7:26 UTC (permalink / raw) To: dev; +Cc: olivier.matz, arybchenko, stable, Zhike Wang If allocation is successful on the first attempt, typically there is no problem since we allocated everything required and we'll terminate the loop (if memory chunk is really sufficient to populate required number of mempool elements). If the first attempt fails, we try to allocate half of mem_size and it succeed, we'll have one more iteration of the for-loop to allocate memory for remaining elements and should not try the next time with quarter of the mem_size. It is wrong that max_alloc_size is divided by 2 in the case of successful allocation as well, or invalid memory can be allocated, and leads to population failure, then errno other than ENOMEM may be returned. Fixes: 3a3d0c75b43e ("mempool: fix slow allocation of large pools") Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com> Signed-off-by: Zhike Wang <wangzhike@jd.com> --- lib/librte_mempool/rte_mempool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index a2bd249..7774f0c 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -635,7 +635,7 @@ struct pagesz_walk_arg { RTE_MIN((size_t)mem_size, max_alloc_size), mp->socket_id, mz_flags, align); - if (mz == NULL && rte_errno != ENOMEM) + if (mz != NULL || rte_errno != ENOMEM) break; max_alloc_size = RTE_MIN(max_alloc_size, -- 1.8.3.1 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH v2] mempool: fix memory allocation in memzones during retry. 2020-07-14 7:26 ` [dpdk-stable] [PATCH v2] mempool: fix memory allocation in memzones during retry Zhike Wang @ 2020-07-14 9:32 ` Burakov, Anatoly 2020-07-21 23:27 ` Thomas Monjalon 0 siblings, 1 reply; 3+ messages in thread From: Burakov, Anatoly @ 2020-07-14 9:32 UTC (permalink / raw) To: Zhike Wang, dev; +Cc: olivier.matz, arybchenko, stable On 14-Jul-20 8:26 AM, Zhike Wang wrote: > If allocation is successful on the first attempt, typically > there is no problem since we allocated everything required and > we'll terminate the loop (if memory chunk is really sufficient > to populate required number of mempool elements). > > If the first attempt fails, we try to allocate half > of mem_size and it succeed, we'll have one more iteration of > the for-loop to allocate memory for remaining elements and > should not try the next time with quarter of the mem_size. > > It is wrong that max_alloc_size is divided by 2 in the > case of successful allocation as well, or invalid memory > can be allocated, and leads to population failure, then errno > other than ENOMEM may be returned. > > Fixes: 3a3d0c75b43e ("mempool: fix slow allocation of large pools") > > Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com> > Signed-off-by: Zhike Wang <wangzhike@jd.com> > --- > lib/librte_mempool/rte_mempool.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c > index a2bd249..7774f0c 100644 > --- a/lib/librte_mempool/rte_mempool.c > +++ b/lib/librte_mempool/rte_mempool.c > @@ -635,7 +635,7 @@ struct pagesz_walk_arg { > RTE_MIN((size_t)mem_size, max_alloc_size), > mp->socket_id, mz_flags, align); > > - if (mz == NULL && rte_errno != ENOMEM) > + if (mz != NULL || rte_errno != ENOMEM) > break; > > max_alloc_size = RTE_MIN(max_alloc_size, > Acked-by: Anatoly Burakov <anatoly.burakov@intel.com> -- Thanks, Anatoly ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH v2] mempool: fix memory allocation in memzones during retry. 2020-07-14 9:32 ` [dpdk-stable] [dpdk-dev] " Burakov, Anatoly @ 2020-07-21 23:27 ` Thomas Monjalon 0 siblings, 0 replies; 3+ messages in thread From: Thomas Monjalon @ 2020-07-21 23:27 UTC (permalink / raw) To: Zhike Wang; +Cc: dev, olivier.matz, arybchenko, stable, Burakov, Anatoly 14/07/2020 11:32, Burakov, Anatoly: > On 14-Jul-20 8:26 AM, Zhike Wang wrote: > > If allocation is successful on the first attempt, typically > > there is no problem since we allocated everything required and > > we'll terminate the loop (if memory chunk is really sufficient > > to populate required number of mempool elements). > > > > If the first attempt fails, we try to allocate half > > of mem_size and it succeed, we'll have one more iteration of > > the for-loop to allocate memory for remaining elements and > > should not try the next time with quarter of the mem_size. > > > > It is wrong that max_alloc_size is divided by 2 in the > > case of successful allocation as well, or invalid memory > > can be allocated, and leads to population failure, then errno > > other than ENOMEM may be returned. > > > > Fixes: 3a3d0c75b43e ("mempool: fix slow allocation of large pools") Cc: stable@dpdk.org > > Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com> > > Signed-off-by: Zhike Wang <wangzhike@jd.com> > > Acked-by: Anatoly Burakov <anatoly.burakov@intel.com> Applied, thanks ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-07-21 23:27 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <1594611634-7730-1-git-send-email-wangzhike@jd.com> 2020-07-14 7:26 ` [dpdk-stable] [PATCH v2] mempool: fix memory allocation in memzones during retry Zhike Wang 2020-07-14 9:32 ` [dpdk-stable] [dpdk-dev] " Burakov, Anatoly 2020-07-21 23:27 ` Thomas Monjalon
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).