dts: fix hugepage configuration bug
Checks
Commit Message
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@iol.unh.edu>
---
dts/framework/testbed_model/linux_session.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Looks good.
Reviewed-by: Luca Vizzarro <luca.vizzarro@arm.com>
@@ -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: