Skip to content

Commit

Permalink
Raise and catch hugepage size err
Browse files Browse the repository at this point in the history
  • Loading branch information
mcgov committed Jan 8, 2025
1 parent 21abd2a commit d491202
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 6 additions & 6 deletions lisa/tools/hugepages.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from enum import Enum
from typing import Any, Set

from assertpy import assert_that

from lisa.executable import Tool
from lisa.tools.echo import Echo
from lisa.tools.free import Free
Expand Down Expand Up @@ -84,10 +82,12 @@ def _enable_hugepages(
)
total_request_pages = request_space_kb // hugepage_size_kb.value
pages_per_numa_node = total_request_pages // numa_nodes
assert_that(pages_per_numa_node).described_as(
"Must request huge page count > 0. Verify this system has enough "
"free memory to allocate ~2GB of hugepages"
).is_greater_than(0)
if pages_per_numa_node <= 0:
raise NotEnoughMemoryException(
"Must request huge page count > 0. Verify this system has enough "
"free memory to allocate ~2GB of hugepages"
)

for i in range(numa_nodes):
# nr_hugepages will be written with the number calculated
# based on 2MB hugepages if not specified, subject to change
Expand Down
5 changes: 4 additions & 1 deletion microsoft/testsuites/dpdk/dpdkutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,10 @@ def initialize_node_resources(

# init and enable hugepages (required by dpdk)
hugepages = node.tools[Hugepages]
hugepages.init_hugepages(hugepage_size, minimum_gb=4)
try:
hugepages.init_hugepages(hugepage_size, minimum_gb=4)
except NotEnoughMemoryException as err:
raise SkippedException(err)

assert_that(len(node.nics)).described_as(
"Test needs at least 1 NIC on the test node."
Expand Down

0 comments on commit d491202

Please sign in to comment.