DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Rybchenko <arybchenko@solarflare.com>
To: Anatoly Burakov <anatoly.burakov@intel.com>, <dev@dpdk.org>
Cc: Olivier Matz <olivier.matz@6wind.com>, <thomas@monjalon.net>,
	<konstantin.ananyev@intel.com>, <shreyansh.jain@nxp.com>
Subject: Re: [dpdk-dev] [PATCH] mempool: fix virt address mempool population
Date: Tue, 15 May 2018 16:04:23 +0300	[thread overview]
Message-ID: <0d2ca8e2-58fa-78ca-03ab-1e965f20b436@solarflare.com> (raw)
In-Reply-To: <014e66f8e34cb87fa126b7494ad644ef9ac68978.1526313945.git.anatoly.burakov@intel.com>

On 05/14/2018 07:06 PM, Anatoly Burakov wrote:
> Currently, populate_virt will check if mempool is already populated.
> This will cause inability to reserve multi-chunk mempools if
> contiguous memory is not a hard requirement, because if allocating
> all-contiguous memory fails, mempool will retry with virtual addresses
> and will call populate_virt. It seems that the original code never
> anticipated more than one non-physically contiguous area.
>
> Fix it by removing the check in populate virt. populate_anon() function
> calls populate_virt() also, and it can be reasonably inferred that it is
> expecting that virtual area is not already populated. Even though a
> similar check is already in place there, also add the check that was
> part of populate_virt() just in case.
>
> Fixes: aab4f62d6c1c ("mempool: support no hugepage mode")
> Cc: olivier.matz@6wind.com
>
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>   lib/librte_mempool/rte_mempool.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
> index 9f1a425..8c8b9f8 100644
> --- a/lib/librte_mempool/rte_mempool.c
> +++ b/lib/librte_mempool/rte_mempool.c
> @@ -492,9 +492,6 @@ rte_mempool_populate_virt(struct rte_mempool *mp, char *addr,
>   	size_t off, phys_len;
>   	int ret, cnt = 0;
>   
> -	/* mempool must not be populated */
> -	if (mp->nb_mem_chunks != 0)
> -		return -EEXIST;
>   	/* address and len must be page-aligned */
>   	if (RTE_PTR_ALIGN_CEIL(addr, pg_sz) != addr)
>   		return -EINVAL;
> @@ -771,7 +768,7 @@ rte_mempool_populate_anon(struct rte_mempool *mp)
>   	char *addr;
>   
>   	/* mempool is already populated, error */
> -	if (!STAILQ_EMPTY(&mp->mem_list)) {
> +	if ((!STAILQ_EMPTY(&mp->mem_list)) || mp->nb_mem_chunks != 0) {

I've seen the description above.
I see no point to add the check here since it is basically duplication.
nb_mem_chunks is incremented when chunk is added to mem_list and
decremented when chunk is removed from mem_list.
However, it is not a problem anyway. So, OK to go as is.

>   		rte_errno = EINVAL;
>   		return 0;
>   	}

Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>

      parent reply	other threads:[~2018-05-15 13:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-14 16:06 Anatoly Burakov
2018-05-14 18:48 ` Thomas Monjalon
2018-05-15  7:58   ` Burakov, Anatoly
2018-05-15 11:28     ` Olivier Matz
2018-05-15 14:32       ` Thomas Monjalon
2018-05-15 13:04 ` Andrew Rybchenko [this message]

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=0d2ca8e2-58fa-78ca-03ab-1e965f20b436@solarflare.com \
    --to=arybchenko@solarflare.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@intel.com \
    --cc=olivier.matz@6wind.com \
    --cc=shreyansh.jain@nxp.com \
    --cc=thomas@monjalon.net \
    /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).