[PATCH] eal/linux: skip hugetlbfs locking for in-memory

David Marchand david.marchand at redhat.com
Tue Nov 17 10:22:17 CET 2026


When running with --in-memory, EAL uses anonymous hugepages via
memfd_create() and never needs hugetlbfs files.

However, hugepage_info_init() only skipped the mountpoint and
directory locking when no hugetlbfs mount was found.
When a mount existed, the code fell through to open and flock()
the hugepage directory regardless of --in-memory.

This causes initialization failures when EAL encounters a hugetlbfs
mount it cannot access (e.g., mounts owned by another component on
the system), even though in-memory mode does not need the mount at all.

Skip the mountpoint lookup and directory locking entirely when
--in-memory is set.
The hugepage sizes and counts are read from sysfs, which is all
that in-memory mode needs.

Fixes: 72b49ff623c4 ("mem: support --in-memory mode")
Cc: stable at dpdk.org

Signed-off-by: David Marchand <david.marchand at redhat.com>
---
 lib/eal/linux/eal_hugepage_info.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/lib/eal/linux/eal_hugepage_info.c b/lib/eal/linux/eal_hugepage_info.c
index 05c5b3f613..781eb3787b 100644
--- a/lib/eal/linux/eal_hugepage_info.c
+++ b/lib/eal/linux/eal_hugepage_info.c
@@ -480,6 +480,20 @@ hugepage_info_init(void)
 		hpi->hugepage_sz =
 			rte_str_to_size(&dirent->d_name[dirent_start_len]);
 
+#ifdef MAP_HUGE_SHIFT
+		/* if we have kernel support for reserving hugepages
+		 * through mmap, and we're in in-memory mode, treat this
+		 * page size as valid. we cannot be in legacy mode at
+		 * this point because we've checked this earlier in the
+		 * init process.
+		 */
+		if (internal_conf->in_memory) {
+			calc_num_pages(hpi, dirent, 0);
+			num_sizes++;
+			continue;
+		}
+#endif
+
 		/* first, check if we have a mountpoint */
 		if (get_hugepage_dir(hpi->hugepage_sz,
 			hpi->hugedir, sizeof(hpi->hugedir)) < 0) {
@@ -493,22 +507,6 @@ hugepage_info_init(void)
 					"%" PRIu64 " reserved, but no mounted "
 					"hugetlbfs found for that size",
 					num_pages, hpi->hugepage_sz);
-			/* if we have kernel support for reserving hugepages
-			 * through mmap, and we're in in-memory mode, treat this
-			 * page size as valid. we cannot be in legacy mode at
-			 * this point because we've checked this earlier in the
-			 * init process.
-			 */
-#ifdef MAP_HUGE_SHIFT
-			if (internal_conf->in_memory) {
-				EAL_LOG(DEBUG, "In-memory mode enabled, "
-					"hugepages of size %" PRIu64 " bytes "
-					"will be allocated anonymously",
-					hpi->hugepage_sz);
-				calc_num_pages(hpi, dirent, 0);
-				num_sizes++;
-			}
-#endif
 			continue;
 		}
 
-- 
2.56.1



More information about the dev mailing list