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 Hugepages: explicit selection of 1GB or 2MB #2948

Merged
merged 2 commits into from
Sep 13, 2023
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
102 changes: 100 additions & 2 deletions microsoft/testsuites/dpdk/dpdksuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def before_case(self, log: Logger, **kwargs: Any) -> None:

@TestCaseMetadata(
description="""
netvsc direct pmd version.
netvsc pmd version.
This test case checks DPDK can be built and installed correctly.
Prerequisites, accelerated networking must be enabled.
The VM should have at least two network interfaces,
Expand All @@ -89,7 +89,29 @@ def verify_dpdk_build_netvsc(

@TestCaseMetadata(
description="""
failsafe (azure default, recommended) version.
netvsc pmd version with 1GiB hugepages
This test case checks DPDK can be built and installed correctly.
Prerequisites, accelerated networking must be enabled.
The VM should have at least two network interfaces,
with one interface for management.
More details refer https://docs.microsoft.com/en-us/azure/virtual-network/setup-dpdk#prerequisites # noqa: E501
""",
priority=2,
requirement=simple_requirement(
min_core_count=8,
min_nic_count=2,
network_interface=Sriov(),
unsupported_features=[Gpu, Infiniband],
),
)
def verify_dpdk_build_gb_hugepages_netvsc(
self, node: Node, log: Logger, variables: Dict[str, Any]
) -> None:
verify_dpdk_build(node, log, variables, "netvsc", gibibyte_hugepages=True)

@TestCaseMetadata(
description="""
failsafe version with 1GiB hugepages.
This test case checks DPDK can be built and installed correctly.
Prerequisites, accelerated networking must be enabled.
The VM should have at least two network interfaces,
Expand All @@ -109,6 +131,28 @@ def verify_dpdk_build_failsafe(
) -> None:
verify_dpdk_build(node, log, variables, "failsafe")

@TestCaseMetadata(
description="""
failsafe version with 2MB hugepages
This test case checks DPDK can be built and installed correctly.
Prerequisites, accelerated networking must be enabled.
The VM should have at least two network interfaces,
with one interface for management.
More details: https://docs.microsoft.com/en-us/azure/virtual-network/setup-dpdk#prerequisites # noqa: E501
""",
priority=2,
requirement=simple_requirement(
min_core_count=8,
min_nic_count=2,
network_interface=Sriov(),
unsupported_features=[Gpu, Infiniband],
),
)
def verify_dpdk_build_gb_hugepages_failsafe(
self, node: Node, log: Logger, variables: Dict[str, Any]
) -> None:
verify_dpdk_build(node, log, variables, "failsafe", gibibyte_hugepages=True)

@TestCaseMetadata(
description="""
Install and run OVS+DPDK functional tests
Expand Down Expand Up @@ -569,6 +613,33 @@ def verify_dpdk_send_receive_failsafe(
except UnsupportedPackageVersionException as err:
raise SkippedException(err)

@TestCaseMetadata(
description="""
Tests a basic sender/receiver setup for default failsafe driver setup.
Sender sends the packets, receiver receives them.
We check both to make sure the received traffic is within the expected
order-of-magnitude.
Test uses 1GB hugepages.
""",
priority=2,
requirement=simple_requirement(
min_core_count=8,
min_nic_count=2,
network_interface=Sriov(),
min_count=2,
unsupported_features=[Gpu, Infiniband],
),
)
def verify_dpdk_send_receive_gb_hugepages_failsafe(
self, environment: Environment, log: Logger, variables: Dict[str, Any]
) -> None:
try:
verify_dpdk_send_receive(
environment, log, variables, "failsafe", gibibyte_hugepages=True
)
except UnsupportedPackageVersionException as err:
raise SkippedException(err)

@TestCaseMetadata(
description="""
Tests a basic sender/receiver setup for direct netvsc pmd setup.
Expand All @@ -593,6 +664,33 @@ def verify_dpdk_send_receive_netvsc(
except UnsupportedPackageVersionException as err:
raise SkippedException(err)

@TestCaseMetadata(
description="""
Tests a basic sender/receiver setup for direct netvsc pmd setup.
Sender sends the packets, receiver receives them.
We check both to make sure the received traffic is within the expected
order-of-magnitude.
Test uses 1GB hugepages.
""",
priority=2,
requirement=simple_requirement(
min_core_count=8,
min_nic_count=2,
network_interface=Sriov(),
min_count=2,
unsupported_features=[Gpu, Infiniband],
),
)
def verify_dpdk_send_receive_gb_hugepages_netvsc(
self, environment: Environment, log: Logger, variables: Dict[str, Any]
) -> None:
try:
verify_dpdk_send_receive(
environment, log, variables, "netvsc", gibibyte_hugepages=True
)
except UnsupportedPackageVersionException as err:
raise SkippedException(err)

@TestCaseMetadata(
description="""
UIO basic functionality test.
Expand Down
116 changes: 70 additions & 46 deletions microsoft/testsuites/dpdk/dpdkutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,21 @@ def __init__(self, _node: Node, _testpmd: DpdkTestpmd) -> None:
self.switch_sriov = True


def init_hugepages(node: Node) -> None:
def init_hugepages(node: Node, enable_gibibyte_hugepages: bool = False) -> None:
mount = node.tools[Mount]
mount.mount(name="nodev", point="/mnt/huge", fs_type=FileSystem.hugetlbfs)
mount.mount(
name="nodev",
point="/mnt/huge-1G",
fs_type=FileSystem.hugetlbfs,
options="pagesize=1G",
)
_enable_hugepages(node)
if enable_gibibyte_hugepages:
mount.mount(
name="nodev",
point="/mnt/huge-1G",
fs_type=FileSystem.hugetlbfs,
options="pagesize=1G",
)
else:
mount.mount(name="nodev", point="/mnt/huge", fs_type=FileSystem.hugetlbfs)
_enable_hugepages(node, enable_gibibyte_hugepages)


def _enable_hugepages(node: Node) -> None:
def _enable_hugepages(node: Node, enable_gibibyte_hugepages: bool = False) -> None:
echo = node.tools[Echo]

meminfo = node.tools[Free]
Expand All @@ -116,40 +118,44 @@ def _enable_hugepages(node: Node) -> None:
# default to enough for one nic if not enough is available
# this should be fine for tests on smaller SKUs

if memfree_2mb < request_pages_2mb:
node.log.debug(
"WARNING: Not enough 2MB pages available for DPDK! "
f"Requesting {request_pages_2mb} found {memfree_2mb} free. "
"Test may fail if it cannot allocate memory."
)
request_pages_2mb = 1024

if memfree_1mb < (request_pages_1gb * 2): # account for 2MB pages by doubling ask
node.log.debug(
"WARNING: Not enough 1GB pages available for DPDK! "
f"Requesting {(request_pages_1gb * 2)} found {memfree_1mb} free. "
"Test may fail if it cannot allocate memory."
)
if enable_gibibyte_hugepages:
if memfree_1mb < (
request_pages_1gb * 2
): # account for 2MB pages by doubling ask
node.log.debug(
"WARNING: Not enough 1GB pages available for DPDK! "
f"Requesting {(request_pages_1gb * 2)} found {memfree_1mb} free. "
"Test may fail if it cannot allocate memory."
)
request_pages_1gb = 1
else:
if memfree_2mb < request_pages_2mb:
node.log.debug(
"WARNING: Not enough 2MB pages available for DPDK! "
f"Requesting {request_pages_2mb} found {memfree_2mb} free. "
"Test may fail if it cannot allocate memory."
)
request_pages_2mb = 1024

for i in range(numa_nodes):
echo.write_to_file(
f"{request_pages_2mb}",
node.get_pure_path(
f"/sys/devices/system/node/node{i}/hugepages/"
"hugepages-2048kB/nr_hugepages"
),
sudo=True,
)

echo.write_to_file(
f"{request_pages_1gb}",
node.get_pure_path(
f"/sys/devices/system/node/node{i}/hugepages/"
"hugepages-1048576kB/nr_hugepages"
),
sudo=True,
)
if enable_gibibyte_hugepages:
echo.write_to_file(
f"{request_pages_1gb}",
node.get_pure_path(
f"/sys/devices/system/node/node{i}/hugepages/"
"hugepages-1048576kB/nr_hugepages"
),
sudo=True,
)
else:
echo.write_to_file(
f"{request_pages_2mb}",
node.get_pure_path(
f"/sys/devices/system/node/node{i}/hugepages/"
"hugepages-2048kB/nr_hugepages"
),
sudo=True,
)


def _set_forced_source_by_distro(node: Node, variables: Dict[str, Any]) -> None:
Expand Down Expand Up @@ -273,6 +279,7 @@ def initialize_node_resources(
variables: Dict[str, Any],
pmd: str,
sample_apps: Union[List[str], None] = None,
enable_gibibyte_hugepages: bool = False,
LiliDeng marked this conversation as resolved.
Show resolved Hide resolved
) -> DpdkTestResources:
_set_forced_source_by_distro(node, variables)
dpdk_source = variables.get("dpdk_source", PACKAGE_MANAGER_SOURCE)
Expand Down Expand Up @@ -317,7 +324,7 @@ def initialize_node_resources(
)

# init and enable hugepages (required by dpdk)
init_hugepages(node)
init_hugepages(node, enable_gibibyte_hugepages)

assert_that(len(node.nics)).described_as(
"Test needs at least 1 NIC on the test node."
Expand Down Expand Up @@ -431,7 +438,11 @@ def _run_command_with_testkit(


def init_nodes_concurrent(
environment: Environment, log: Logger, variables: Dict[str, Any], pmd: str
environment: Environment,
log: Logger,
variables: Dict[str, Any],
pmd: str,
enable_gibibyte_hugepages: bool = False,
) -> List[DpdkTestResources]:
# quick check when initializing, have each node ping the other nodes.
# When binding DPDK directly to the VF this helps ensure l2/l3 routes
Expand All @@ -441,7 +452,14 @@ def init_nodes_concurrent(
# Use threading module to parallelize the IO-bound node init.
test_kits = run_in_parallel(
[
partial(initialize_node_resources, node, log, variables, pmd)
partial(
initialize_node_resources,
node,
log,
variables,
pmd,
enable_gibibyte_hugepages=enable_gibibyte_hugepages,
)
for node in environment.nodes.list()
],
log,
Expand All @@ -455,9 +473,12 @@ def verify_dpdk_build(
variables: Dict[str, Any],
pmd: str,
multiple_queues: bool = False,
gibibyte_hugepages: bool = False,
) -> DpdkTestResources:
# setup and unwrap the resources for this test
test_kit = initialize_node_resources(node, log, variables, pmd)
test_kit = initialize_node_resources(
node, log, variables, pmd, enable_gibibyte_hugepages=gibibyte_hugepages
)
testpmd = test_kit.testpmd

# grab a nic and run testpmd
Expand Down Expand Up @@ -485,6 +506,7 @@ def verify_dpdk_send_receive(
pmd: str,
use_service_cores: int = 1,
multiple_queues: bool = False,
gibibyte_hugepages: bool = False,
) -> Tuple[DpdkTestResources, DpdkTestResources]:
# helpful to have the public ips labeled for debugging
external_ips = []
Expand All @@ -501,7 +523,9 @@ def verify_dpdk_send_receive(
# enables long-running tests to shakeQoS and SLB issue
test_duration: int = variables.get("dpdk_test_duration", 15)
kill_timeout = test_duration + 5
test_kits = init_nodes_concurrent(environment, log, variables, pmd)
test_kits = init_nodes_concurrent(
environment, log, variables, pmd, enable_gibibyte_hugepages=gibibyte_hugepages
)

check_send_receive_compatibility(test_kits)

Expand Down
Loading