Reduce dependency on internal details of EAL memory subsystem, and
simplify code.

Signed-off-by: Anatoly Burakov <anatoly.bura...@intel.com>
Tested-by: Santosh Shukla <santosh.shu...@caviumnetworks.com>
Tested-by: Hemant Agrawal <hemant.agra...@nxp.com>
---
 lib/librte_mempool/Makefile      |  3 +++
 lib/librte_mempool/meson.build   |  3 +++
 lib/librte_mempool/rte_mempool.c | 24 ++++++++++++------------
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/lib/librte_mempool/Makefile b/lib/librte_mempool/Makefile
index 24e735a..1f85d34 100644
--- a/lib/librte_mempool/Makefile
+++ b/lib/librte_mempool/Makefile
@@ -13,6 +13,9 @@ EXPORT_MAP := rte_mempool_version.map
 
 LIBABIVER := 3
 
+# memseg walk is not yet part of stable API
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 # all source are stored in SRCS-y
 SRCS-$(CONFIG_RTE_LIBRTE_MEMPOOL) +=  rte_mempool.c
 SRCS-$(CONFIG_RTE_LIBRTE_MEMPOOL) +=  rte_mempool_ops.c
diff --git a/lib/librte_mempool/meson.build b/lib/librte_mempool/meson.build
index 712720f..89506c5 100644
--- a/lib/librte_mempool/meson.build
+++ b/lib/librte_mempool/meson.build
@@ -5,3 +5,6 @@ version = 3
 sources = files('rte_mempool.c', 'rte_mempool_ops.c')
 headers = files('rte_mempool.h')
 deps += ['ring']
+
+# memseg walk is not yet part of stable API
+allow_experimental_apis = true
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 4660cc2..9731d4c 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -99,23 +99,23 @@ static unsigned optimize_object_size(unsigned obj_size)
        return new_obj_size * RTE_MEMPOOL_ALIGN;
 }
 
+static int
+find_min_pagesz(const struct rte_memseg *ms, void *arg)
+{
+       size_t *min = arg;
+
+       if (ms->hugepage_sz < *min)
+               *min = ms->hugepage_sz;
+
+       return 0;
+}
+
 static size_t
 get_min_page_size(void)
 {
-       const struct rte_mem_config *mcfg =
-                       rte_eal_get_configuration()->mem_config;
-       int i;
        size_t min_pagesz = SIZE_MAX;
 
-       for (i = 0; i < RTE_MAX_MEMSEG; i++) {
-               const struct rte_memseg *ms = &mcfg->memseg[i];
-
-               if (ms->addr == NULL)
-                       continue;
-
-               if (ms->hugepage_sz < min_pagesz)
-                       min_pagesz = ms->hugepage_sz;
-       }
+       rte_memseg_walk(find_min_pagesz, &min_pagesz);
 
        return min_pagesz == SIZE_MAX ? (size_t) getpagesize() : min_pagesz;
 }
-- 
2.7.4

Reply via email to