DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] mempool: fix the inverted pg_num check on create
@ 2015-08-16 19:08 Dan Aloni
  2015-08-17  8:55 ` Olivier MATZ
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Aloni @ 2015-08-16 19:08 UTC (permalink / raw)
  To: Olivier Matz; +Cc: dev

The rest of the code expects pg_num <= RTE_DIM(mp->elt_pa).

Signed-off-by: Dan Aloni <dan@kernelim.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 8e185c545479..edcfa8bf9cb1 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -461,7 +461,7 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,
 	}
 
 	/* Check that pg_num and pg_shift parameters are valid. */
-	if (pg_num < RTE_DIM(mp->elt_pa) || pg_shift > MEMPOOL_PG_SHIFT_MAX) {
+	if (pg_num > RTE_DIM(mp->elt_pa) || pg_shift > MEMPOOL_PG_SHIFT_MAX) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
-- 
2.4.3

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

* Re: [dpdk-dev] [PATCH] mempool: fix the inverted pg_num check on create
  2015-08-16 19:08 [dpdk-dev] [PATCH] mempool: fix the inverted pg_num check on create Dan Aloni
@ 2015-08-17  8:55 ` Olivier MATZ
  2015-08-17 10:50   ` Dan Aloni
  0 siblings, 1 reply; 3+ messages in thread
From: Olivier MATZ @ 2015-08-17  8:55 UTC (permalink / raw)
  To: Dan Aloni; +Cc: dev

Hi,

On 08/16/2015 09:08 PM, Dan Aloni wrote:
> The rest of the code expects pg_num <= RTE_DIM(mp->elt_pa).
> 
> Signed-off-by: Dan Aloni <dan@kernelim.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 8e185c545479..edcfa8bf9cb1 100644
> --- a/lib/librte_mempool/rte_mempool.c
> +++ b/lib/librte_mempool/rte_mempool.c
> @@ -461,7 +461,7 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,
>  	}
>  
>  	/* Check that pg_num and pg_shift parameters are valid. */
> -	if (pg_num < RTE_DIM(mp->elt_pa) || pg_shift > MEMPOOL_PG_SHIFT_MAX) {
> +	if (pg_num > RTE_DIM(mp->elt_pa) || pg_shift > MEMPOOL_PG_SHIFT_MAX) {
>  		rte_errno = EINVAL;
>  		return NULL;
>  	}
> 


Could you give some details about the conditions to reproduce and the
consequences of the issue?

>From what I see, RTE_DIM(mp->elt_pa) is always 1:

	#define MEMPOOL_PG_NUM_DEFAULT  1
	struct rte_mempool {
		...
	        phys_addr_t elt_pa[MEMPOOL_PG_NUM_DEFAULT];
	}  __rte_cache_aligned;

>From rte_mempool_xmem_create() documentation, pg_num gives the size of
the paddr array, which is allocated by the caller. So I think there is
no issue here.

Regards,
Olivier

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

* Re: [dpdk-dev] [PATCH] mempool: fix the inverted pg_num check on create
  2015-08-17  8:55 ` Olivier MATZ
@ 2015-08-17 10:50   ` Dan Aloni
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Aloni @ 2015-08-17 10:50 UTC (permalink / raw)
  To: Olivier MATZ; +Cc: dev

On Mon, Aug 17, 2015 at 10:55:35AM +0200, Olivier MATZ wrote:
> On 08/16/2015 09:08 PM, Dan Aloni wrote:
[..]
> >  	/* Check that pg_num and pg_shift parameters are valid. */
> > -	if (pg_num < RTE_DIM(mp->elt_pa) || pg_shift > MEMPOOL_PG_SHIFT_MAX) {
> > +	if (pg_num > RTE_DIM(mp->elt_pa) || pg_shift > MEMPOOL_PG_SHIFT_MAX) {
> >  		rte_errno = EINVAL;
> >  		return NULL;

> 
> From what I see, RTE_DIM(mp->elt_pa) is always 1:
> 
> 	#define MEMPOOL_PG_NUM_DEFAULT  1
> 	struct rte_mempool {
> 		...
> 	        phys_addr_t elt_pa[MEMPOOL_PG_NUM_DEFAULT];
> 	}  __rte_cache_aligned;
> 
> From rte_mempool_xmem_create() documentation, pg_num gives the size of
> the paddr array, which is allocated by the caller. So I think there is
> no issue here.

You're right, I missed on the fact that mempool takes pg_num as its
run-time determined size of the array for both its dynamically allocated
copy and the caller's provided array.

The MEMPOOL_PG_NUM_DEFAULT macro is was a bit distracting in this. I
wanted to provide pg_num > 1 and it wasn't clear on whether to modify
the macro, or simply call the function :). So, never mind the patch.

-- 
Dan Aloni

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

end of thread, other threads:[~2015-08-17 10:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-16 19:08 [dpdk-dev] [PATCH] mempool: fix the inverted pg_num check on create Dan Aloni
2015-08-17  8:55 ` Olivier MATZ
2015-08-17 10:50   ` Dan Aloni

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).