From c766c3d12b1bb5e791cff3f34c733f18ce5cdd18 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Thu, 9 May 2024 21:57:54 +0800
Subject: [PATCH] require at least two segs per memseg lists in map-perfect
 mode

---
 lib/eal/common/eal_common_dynmem.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/eal/common/eal_common_dynmem.c b/lib/eal/common/eal_common_dynmem.c
index 89e2acd..7f270a0 100644
--- a/lib/eal/common/eal_common_dynmem.c
+++ b/lib/eal/common/eal_common_dynmem.c
@@ -229,8 +229,14 @@ eal_dynmem_memseg_lists_init(void)
 				"n_segs:%i socket_id:%i hugepage_sz:%" PRIu64 "\n",
 			n_seglists, n_segs, socket_id, pagesz);
 
-		if (internal_conf->map_perfect)
+		if (internal_conf->map_perfect) {
 			need_n_segs = eal_sec_get_num_pages(used_hp, pagesz, socket_id);
+			/*
+			 * commit 51a5a72e2a (eal/linux: fix legacy mem init with many segments) require
+			 * at least 2 segs per memseg list
+			 */
+			need_n_segs = RTE_MAX(2, need_n_segs);
+		}
 		else
 			need_n_segs = n_segs;
 
-- 
2.27.0

