[dpdk-dev] [PATCH 2/2] mempool: fix pages computation to determine number of objects

Adrien Mazarguil adrien.mazarguil at 6wind.com
Mon May 25 18:27:46 CEST 2015


In rte_mempool_obj_iter(), even when a single page is required per object,
a loop checks that the the next page is contiguous and drops the first one
otherwise. This commit checks subsequent pages only when several are
required per object.

Also a minor fix for the amount of remaining space that prevents using the
entire region.

Fixes: 148f963fb532 ("xen: core library changes")

Signed-off-by: Adrien Mazarguil <adrien.mazarguil at 6wind.com>
---
 lib/librte_mempool/rte_mempool.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index d1a02a2..3c1efec 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -175,12 +175,17 @@ rte_mempool_obj_iter(void *vaddr, uint32_t elt_num, size_t elt_sz, size_t align,
 		pgn += j;
 
 		/* do we have enough space left for the next element. */
-		if (pgn >= pg_num)
+		if (pgn > pg_num)
 			break;
 
-		for (k = j;
+		/*
+		 * Compute k so that (k - j) is the number of contiguous
+		 * pages starting from index j. Note that there is at least
+		 * one page.
+		 */
+		for (k = j + 1;
 				k != pgn &&
-				paddr[k] + pg_sz == paddr[k + 1];
+				paddr[k - 1] + pg_sz == paddr[k];
 				k++)
 			;
 
-- 
2.1.0



More information about the dev mailing list