[PATCH] dts: fix hugepage configuration bug

Nicholas Pratte npratte at iol.unh.edu
Tue Jan 14 21:00:38 CET 2025


The dts framework checks for total hugepages of a specific size on a
system without first checking if such hugepages are supported. This
results in unhelpful error messages, since attempting to grab
information from a file/directory that does not exist creates undefined
behavior. This quick reorientation of the code prevents this, and
allows for easier error assessment.

Signed-off-by: Nicholas Pratte <npratte at iol.unh.edu>
---
 dts/framework/testbed_model/linux_session.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dts/framework/testbed_model/linux_session.py b/dts/framework/testbed_model/linux_session.py
index bda2d448f7..e3732f0827 100644
--- a/dts/framework/testbed_model/linux_session.py
+++ b/dts/framework/testbed_model/linux_session.py
@@ -90,12 +90,12 @@ def setup_hugepages(self, number_of: int, hugepage_size: int, force_first_numa:
             ConfigurationError: If the given `hugepage_size` is not supported by the OS.
         """
         self._logger.info("Getting Hugepage information.")
-        hugepages_total = self._get_hugepages_total(hugepage_size)
         if (
             f"hugepages-{hugepage_size}kB"
             not in self.send_command("ls /sys/kernel/mm/hugepages").stdout
         ):
             raise ConfigurationError("hugepage size not supported by operating system")
+        hugepages_total = self._get_hugepages_total(hugepage_size)
         self._numa_nodes = self._get_numa_nodes()
 
         if force_first_numa or hugepages_total < number_of:
-- 
2.47.1



More information about the dev mailing list