Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DPDK: use multiple mbufs #3582

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions lisa/tools/hugepages.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
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 @@ -63,13 +65,14 @@ def get_hugepage_sizes_in_kb(self) -> Set[int]:
hugepage_sizes.add(int(matched_hugepage.group("hugepage_size_in_kb")))
return hugepage_sizes

def _enable_hugepages(self, hugepage_size_kb: HugePageSize) -> None:
def _enable_hugepages(
self, hugepage_size_kb: HugePageSize, request_space_kb: int
) -> None:
echo = self.node.tools[Echo]
meminfo = self.node.tools[Free]
nics_count = len(self.node.nics.get_nic_names())
numa_nodes = self.node.tools[Lscpu].get_numa_node_count()
# ask for enough space, note that we enable pages per numa node

request_space_kb = (nics_count - 1) * 1024 * 1024 * numa_nodes * 2
free_memory_kb = meminfo.get_free_memory_kb()

if free_memory_kb < request_space_kb:
Expand All @@ -79,24 +82,29 @@ def _enable_hugepages(self, hugepage_size_kb: HugePageSize) -> None:
f"Requesting {request_space_kb} KB found {free_memory_kb} "
"KB free."
)

request_pages = request_space_kb // hugepage_size_kb.value
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)
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
# this based on further discussion
echo.write_to_file(
f"{request_pages}",
f"{pages_per_numa_node}",
self.node.get_pure_path(
f"/sys/devices/system/node/node{i}/hugepages/"
f"hugepages-{hugepage_size_kb.value}kB/nr_hugepages"
),
sudo=True,
)

def init_hugepages(self, hugepage_size: HugePageSize) -> None:
def init_hugepages(self, hugepage_size: HugePageSize, minimum_gb: int = 2) -> None:
mount = self.node.tools[Mount]
hugepage_sizes = self.get_hugepage_sizes_in_kb()
minimum_kb = minimum_gb * 1024 * 1024
if hugepage_size.value not in hugepage_sizes:
raise UnsupportedOperationException(
f"Supported hugepage sizes in kB are: {hugepage_sizes}."
Expand All @@ -109,4 +117,6 @@ def init_hugepages(self, hugepage_size: HugePageSize) -> None:
fs_type=FileSystem.hugetlbfs,
options=f"pagesize={hugepage_size.value}KB",
)
self._enable_hugepages(hugepage_size_kb=hugepage_size)
self._enable_hugepages(
hugepage_size_kb=hugepage_size, request_space_kb=minimum_kb
)
1 change: 1 addition & 0 deletions microsoft/testsuites/dpdk/dpdktestpmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ def generate_testpmd_command(
f"{self._testpmd_install_path} {core_list} "
f"{nic_include_info} -- --forward-mode={mode} "
f"-a --stats-period 2 --nb-cores={forwarding_cores} {extra_args} "
"--mbuf-size=2048,8096"
)

def run_for_n_seconds(self, cmd: str, timeout: int) -> str:
Expand Down
2 changes: 1 addition & 1 deletion microsoft/testsuites/dpdk/dpdkutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def initialize_node_resources(

# init and enable hugepages (required by dpdk)
hugepages = node.tools[Hugepages]
hugepages.init_hugepages(hugepage_size)
hugepages.init_hugepages(hugepage_size, minimum_gb=4)

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