Thread (3 messages) 3 messages, 2 authors, 2015-08-17

Re: [PATCH] mempool: fix the inverted pg_num check on create

From: Dan Aloni <hidden>
Date: 2015-08-17 10:50:05

On Mon, Aug 17, 2015 at 10:55:35AM +0200, Olivier MATZ wrote:
On 08/16/2015 09:08 PM, Dan Aloni wrote:
[..]
quoted
 	/* 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help