From: "Burakov, Anatoly" <anatoly.burakov@intel.com>
To: Olivier Matz <olivier.matz@6wind.com>, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] mempool: fix alignment of memzone length when populating
Date: Thu, 3 May 2018 09:03:02 +0100 [thread overview]
Message-ID: <0fa5ec0b-d528-12b1-d3f2-680b5f05242b@intel.com> (raw)
In-Reply-To: <20180502201349.15568-1-olivier.matz@6wind.com>
On 02-May-18 9:13 PM, Olivier Matz wrote:
> When populating a mempool with the default function, if there is not
> enough virtually contiguous memory for the whole mempool, it will be
> populated with several chunks. A chunk of the maximum available length
> is requested with:
>
> mz = rte_memzone_reserve_aligned(..., len=0, ..., align=x)
>
> If align is smaller than the page size, the length of the memzone may
> not be a multiple of the page size. This makes
> rte_mempool_populate_virt() to fail because it requires a page-aligned
> length. This patch forces the memzone length to be a multiple of page
> size.
>
> The problem can be reproduced easily by allocating more than available
> memory:
> ./build/app/testpmd -l 0,1 -- --total-num-mbufs=65536
> ...
> Cause: Creation of mbuf pool for socket 0 failed: Invalid argument
>
> After the patch, the error code is correct:
> ./build/app/testpmd -l 0,1 -- --total-num-mbufs=65536
> ...
> Cause: Creation of mbuf pool for socket 0 failed: Cannot allocate memory
>
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
> Fixes: ba0009560c30 ("mempool: support new allocation methods")
> ---
>
> Hi Anatoly,
>
> Another option to fix this issue could be to ensure that
> rte_memzone_reserve_aligned(..., len=0, ..., align=x) returns a length
> that is multiple of page size. Something like:
>
> mz = rte_memzone_reserve_aligned(mz_name, 0,
> - mp->socket_id, flags, align);
> + mp->socket_id, flags, RTE_MAX(pg_sz, align));
>
> Let me know if you prefer this way.
>
> Thanks,
> Olivier
>
>
> 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 cf5d124ec..78c3e95ec 100644
> --- a/lib/librte_mempool/rte_mempool.c
> +++ b/lib/librte_mempool/rte_mempool.c
> @@ -709,7 +709,7 @@ rte_mempool_populate_default(struct rte_mempool *mp)
> (void *)(uintptr_t)mz);
> else
> ret = rte_mempool_populate_virt(mp, mz->addr,
> - mz->len, pg_sz,
> + RTE_ALIGN_FLOOR(mz->len, pg_sz), pg_sz,
> rte_mempool_memchunk_mz_free,
> (void *)(uintptr_t)mz);
> if (ret < 0) {
>
Either way is OK by me.
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
--
Thanks,
Anatoly
next prev parent reply other threads:[~2018-05-03 8:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-02 20:13 Olivier Matz
2018-05-03 8:03 ` Burakov, Anatoly [this message]
2018-05-03 9:34 ` Andrew Rybchenko
2018-05-03 10:04 ` Olivier Matz
2018-05-07 8:18 ` [dpdk-dev] [PATCH v2] " Olivier Matz
2018-05-07 8:30 ` Andrew Rybchenko
2018-05-08 13:59 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0fa5ec0b-d528-12b1-d3f2-680b5f05242b@intel.com \
--to=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=olivier.matz@6wind.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).