DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] mempool: fix virt address mempool population
@ 2018-05-14 16:06 Anatoly Burakov
  2018-05-14 18:48 ` Thomas Monjalon
  2018-05-15 13:04 ` Andrew Rybchenko
  0 siblings, 2 replies; 6+ messages in thread
From: Anatoly Burakov @ 2018-05-14 16:06 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, thomas, konstantin.ananyev, arybchenko, shreyansh.jain

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) {
 		rte_errno = EINVAL;
 		return 0;
 	}
-- 
2.7.4

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] mempool: fix virt address mempool population
  2018-05-14 16:06 [dpdk-dev] [PATCH] mempool: fix virt address mempool population Anatoly Burakov
@ 2018-05-14 18:48 ` Thomas Monjalon
  2018-05-15  7:58   ` Burakov, Anatoly
  2018-05-15 13:04 ` Andrew Rybchenko
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Monjalon @ 2018-05-14 18:48 UTC (permalink / raw)
  To: Anatoly Burakov
  Cc: dev, Olivier Matz, konstantin.ananyev, arybchenko, shreyansh.jain

14/05/2018 18:06, Anatoly Burakov:
> 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")

If it is really the root cause, you need to add Cc: stable@dpdk.org.

> Cc: olivier.matz@6wind.com
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>

This patch looks sensible. It will wait some review,
so it is a candidate for -rc4.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] mempool: fix virt address mempool population
  2018-05-14 18:48 ` Thomas Monjalon
@ 2018-05-15  7:58   ` Burakov, Anatoly
  2018-05-15 11:28     ` Olivier Matz
  0 siblings, 1 reply; 6+ messages in thread
From: Burakov, Anatoly @ 2018-05-15  7:58 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, Olivier Matz, konstantin.ananyev, arybchenko, shreyansh.jain

On 14-May-18 7:48 PM, Thomas Monjalon wrote:
> 14/05/2018 18:06, Anatoly Burakov:
>> 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")
> 
> If it is really the root cause, you need to add Cc: stable@dpdk.org.

Yes. It's not as pressing for previous DPDK versions because this 
codepath wasn't triggered unless --no-huge was used, but it's still a bug.

> 
>> Cc: olivier.matz@6wind.com
>>
>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> 
> This patch looks sensible. It will wait some review,
> so it is a candidate for -rc4.
> 
> 
> 
> 
> 


-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] mempool: fix virt address mempool population
  2018-05-15  7:58   ` Burakov, Anatoly
@ 2018-05-15 11:28     ` Olivier Matz
  2018-05-15 14:32       ` Thomas Monjalon
  0 siblings, 1 reply; 6+ messages in thread
From: Olivier Matz @ 2018-05-15 11:28 UTC (permalink / raw)
  To: Burakov, Anatoly
  Cc: Thomas Monjalon, dev, konstantin.ananyev, arybchenko, shreyansh.jain

On Tue, May 15, 2018 at 08:58:06AM +0100, Burakov, Anatoly wrote:
> On 14-May-18 7:48 PM, Thomas Monjalon wrote:
> > 14/05/2018 18:06, Anatoly Burakov:
> > > 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")

Acked-by: Olivier Matz <olivier.matz@6wind.com>

> > If it is really the root cause, you need to add Cc: stable@dpdk.org.
> 
> Yes. It's not as pressing for previous DPDK versions because this codepath
> wasn't triggered unless --no-huge was used, but it's still a bug.

Agree we should queue it for stable, even if it's not that critical.

Thanks,
Olivier

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] mempool: fix virt address mempool population
  2018-05-14 16:06 [dpdk-dev] [PATCH] mempool: fix virt address mempool population Anatoly Burakov
  2018-05-14 18:48 ` Thomas Monjalon
@ 2018-05-15 13:04 ` Andrew Rybchenko
  1 sibling, 0 replies; 6+ messages in thread
From: Andrew Rybchenko @ 2018-05-15 13:04 UTC (permalink / raw)
  To: Anatoly Burakov, dev
  Cc: Olivier Matz, thomas, konstantin.ananyev, shreyansh.jain

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>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] mempool: fix virt address mempool population
  2018-05-15 11:28     ` Olivier Matz
@ 2018-05-15 14:32       ` Thomas Monjalon
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2018-05-15 14:32 UTC (permalink / raw)
  To: Burakov, Anatoly
  Cc: dev, Olivier Matz, konstantin.ananyev, arybchenko, shreyansh.jain

15/05/2018 13:28, Olivier Matz:
> On Tue, May 15, 2018 at 08:58:06AM +0100, Burakov, Anatoly wrote:
> > On 14-May-18 7:48 PM, Thomas Monjalon wrote:
> > > 14/05/2018 18:06, Anatoly Burakov:
> > > > 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")
> 
> Acked-by: Olivier Matz <olivier.matz@6wind.com>
> 
> > > If it is really the root cause, you need to add Cc: stable@dpdk.org.
> > 
> > Yes. It's not as pressing for previous DPDK versions because this codepath
> > wasn't triggered unless --no-huge was used, but it's still a bug.
> 
> Agree we should queue it for stable, even if it's not that critical.

Applied, thanks

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-05-15 14:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-14 16:06 [dpdk-dev] [PATCH] mempool: fix virt address mempool population 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 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).