Skip to content

Commit 68008a2

Browse files
committed
test: run throughput perf tests with secret freedom enabled
Aadditionally parametrize some of our throughput performance tests (network, block and vsock) by memory config, so that they run with secret freedom (and hence bounce buffering) enabled. Also add it to the boottime test, because bouncing can impact the time taken to read the rootfs. Skip them on m6g.metal because secret freedom does not work here for architectural reasons (and our patches do not take this into account, so trying to use secret freedom here would result in host kernel panics). Signed-off-by: Patrick Roy <[email protected]>
1 parent f5ecd7f commit 68008a2

File tree

6 files changed

+72
-25
lines changed

6 files changed

+72
-25
lines changed

tests/conftest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,22 @@ def io_engine(request):
386386
return request.param
387387

388388

389+
secret_free_test_cases = [False]
390+
if (
391+
global_props.host_linux_version_metrics == "next"
392+
and global_props.instance != "m6g.metal"
393+
):
394+
secret_free_test_cases.append(True)
395+
396+
397+
@pytest.fixture(params=secret_free_test_cases)
398+
def memory_config(request):
399+
"""Differently configured swiotlb regions. Only supported on aarch64"""
400+
if not request.param:
401+
return None
402+
return {"secret_free": request.param}
403+
404+
389405
@pytest.fixture
390406
def results_dir(request):
391407
"""

tests/framework/microvm.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ def __init__(
249249
self.disks_vhost_user = {}
250250
self.vcpus_count = None
251251
self.mem_size_bytes = None
252+
self.memory_config = None
252253
self.cpu_template_name = "None"
253254
# The given custom CPU template will be set in basic_config() but could
254255
# be overwritten via set_cpu_template().
@@ -463,6 +464,11 @@ def dimensions(self):
463464
"rootfs": self.rootfs_file.name,
464465
"vcpus": str(self.vcpus_count),
465466
"guest_memory": f"{self.mem_size_bytes / (1024 * 1024)}MB",
467+
**(
468+
{k: str(v) for k, v in self.memory_config.items()}
469+
if self.memory_config
470+
else {}
471+
),
466472
}
467473

468474
@property
@@ -730,6 +736,7 @@ def basic_config(
730736
rootfs_io_engine=None,
731737
cpu_template: Optional[str] = None,
732738
enable_entropy_device=False,
739+
memory_config=None,
733740
):
734741
"""Shortcut for quickly configuring a microVM.
735742
@@ -748,15 +755,23 @@ def basic_config(
748755
749756
Reference: file:../../src/vmm/src/vmm_config/boot_source.rs::DEFAULT_KERNEL_CMDLINE
750757
"""
758+
# Have to do it this way as otherwise A/B-tests fail if the 'A' revision
759+
# of Firecracker doesn't know about the mem_config parameter.
760+
kwargs = {}
761+
if memory_config is not None:
762+
kwargs["mem_config"] = memory_config
763+
751764
self.api.machine_config.put(
752765
vcpu_count=vcpu_count,
753766
smt=smt,
754767
mem_size_mib=mem_size_mib,
755768
track_dirty_pages=track_dirty_pages,
756769
huge_pages=huge_pages,
770+
**kwargs,
757771
)
758772
self.vcpus_count = vcpu_count
759773
self.mem_size_bytes = mem_size_mib * 2**20
774+
self.memory_config = memory_config
760775

761776
if self.custom_cpu_template is not None:
762777
self.set_cpu_template(self.custom_cpu_template)

tests/integration_tests/performance/test_block_ab.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,20 @@ def test_block_performance(
163163
fio_block_size,
164164
fio_engine,
165165
io_engine,
166+
memory_config,
166167
metrics,
167168
):
168169
"""
169170
Execute block device emulation benchmarking scenarios.
170171
"""
172+
if memory_config is not None and "6.1" not in guest_kernel_acpi.name:
173+
pytest.skip("swiotlb only supported on aarch64/6.1")
174+
171175
vm = microvm_factory.build(guest_kernel_acpi, rootfs, monitor_memory=False)
172176
vm.spawn(log_level="Info", emit_metrics=True)
173-
vm.basic_config(vcpu_count=vcpus, mem_size_mib=GUEST_MEM_MIB)
177+
vm.basic_config(
178+
vcpu_count=vcpus, mem_size_mib=GUEST_MEM_MIB, memory_config=memory_config
179+
)
174180
vm.add_net_iface()
175181
# Add a secondary block device for benchmark tests.
176182
fs = drive_tools.FilesystemFile(

tests/integration_tests/performance/test_boottime.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
import pytest
1010

11-
from framework.properties import global_props
12-
1311
# Regex for obtaining boot time from some string.
1412
TIMESTAMP_LOG_REGEX = r"Guest-boot-time\s+\=\s+(\d+)\s+us"
1513

@@ -19,14 +17,6 @@
1917
)
2018

2119

22-
DIMENSIONS = {
23-
"instance": global_props.instance,
24-
"cpu_model": global_props.cpu_model,
25-
"host_os": global_props.host_os,
26-
"host_kernel": "linux-" + global_props.host_linux_version_metrics,
27-
}
28-
29-
3020
def _get_microvm_boottime(vm):
3121
"""Auxiliary function for asserting the expected boot time."""
3222
boot_time_us = None
@@ -75,19 +65,18 @@ def find_events(log_data):
7565
)
7666
@pytest.mark.nonci
7767
def test_boottime(
78-
microvm_factory, guest_kernel_acpi, rootfs_rw, vcpu_count, mem_size_mib, metrics
68+
microvm_factory,
69+
guest_kernel_acpi,
70+
rootfs_rw,
71+
vcpu_count,
72+
mem_size_mib,
73+
memory_config,
74+
metrics,
7975
):
8076
"""Test boot time with different guest configurations"""
8177

82-
metrics.set_dimensions(
83-
{
84-
**DIMENSIONS,
85-
"performance_test": "test_boottime",
86-
"guest_kernel": guest_kernel_acpi.name,
87-
"vcpus": str(vcpu_count),
88-
"mem_size_mib": str(mem_size_mib),
89-
}
90-
)
78+
if memory_config is not None and "6.1" not in guest_kernel_acpi.name:
79+
pytest.skip("swiotlb only supported on aarch64/6.1")
9180

9281
for _ in range(10):
9382
vm = microvm_factory.build(guest_kernel_acpi, rootfs_rw)
@@ -98,10 +87,14 @@ def test_boottime(
9887
mem_size_mib=mem_size_mib,
9988
boot_args=DEFAULT_BOOT_ARGS + " init=/usr/local/bin/init",
10089
enable_entropy_device=True,
90+
memory_config=memory_config,
10191
)
10292
vm.add_net_iface()
10393
vm.start()
10494
vm.pin_threads(0)
95+
96+
metrics.set_dimensions({"performance_test": "test_boottime", **vm.dimensions})
97+
10598
boottime_us = _get_microvm_boottime(vm)
10699
metrics.put_metric("boot_time", boottime_us, unit="Microseconds")
107100
timestamps = find_events(vm.log_data)

tests/integration_tests/performance/test_network_ab.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,21 @@ def consume_ping_output(ping_putput, request_per_round):
3636

3737

3838
@pytest.fixture
39-
def network_microvm(request, microvm_factory, guest_kernel_acpi, rootfs):
39+
def network_microvm(request, microvm_factory, guest_kernel_acpi, rootfs, memory_config):
4040
"""Creates a microvm with the networking setup used by the performance tests in this file.
4141
This fixture receives its vcpu count via indirect parameterization"""
4242

43+
if memory_config is not None and "6.1" not in guest_kernel_acpi.name:
44+
pytest.skip("swiotlb only supported on aarch64/6.1")
45+
4346
guest_mem_mib = 1024
4447
guest_vcpus = request.param
4548

4649
vm = microvm_factory.build(guest_kernel_acpi, rootfs, monitor_memory=False)
4750
vm.spawn(log_level="Info", emit_metrics=True)
48-
vm.basic_config(vcpu_count=guest_vcpus, mem_size_mib=guest_mem_mib)
51+
vm.basic_config(
52+
vcpu_count=guest_vcpus, mem_size_mib=guest_mem_mib, memory_config=memory_config
53+
)
4954
vm.add_net_iface()
5055
vm.start()
5156
vm.pin_threads(0)

tests/integration_tests/performance/test_vsock_ab.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,14 @@ def guest_command(self, port_offset):
7373
@pytest.mark.parametrize("payload_length", ["64K", "1024K"], ids=["p64K", "p1024K"])
7474
@pytest.mark.parametrize("mode", ["g2h", "h2g", "bd"])
7575
def test_vsock_throughput(
76-
microvm_factory, guest_kernel_acpi, rootfs, vcpus, payload_length, mode, metrics
76+
microvm_factory,
77+
guest_kernel_acpi,
78+
rootfs,
79+
vcpus,
80+
payload_length,
81+
mode,
82+
metrics,
83+
memory_config,
7784
):
7885
"""
7986
Test vsock throughput for multiple vm configurations.
@@ -84,10 +91,15 @@ def test_vsock_throughput(
8491
if mode == "bd" and vcpus < 2:
8592
pytest.skip("bidrectional test only done with at least 2 vcpus")
8693

94+
if memory_config is not None and "6.1" not in guest_kernel_acpi.name:
95+
pytest.skip("swiotlb only supported on aarch64/6.1")
96+
8797
mem_size_mib = 1024
8898
vm = microvm_factory.build(guest_kernel_acpi, rootfs, monitor_memory=False)
8999
vm.spawn(log_level="Info", emit_metrics=True)
90-
vm.basic_config(vcpu_count=vcpus, mem_size_mib=mem_size_mib)
100+
vm.basic_config(
101+
vcpu_count=vcpus, mem_size_mib=mem_size_mib, memory_config=memory_config
102+
)
91103
vm.add_net_iface()
92104
# Create a vsock device
93105
vm.api.vsock.put(vsock_id="vsock0", guest_cid=3, uds_path="/" + VSOCK_UDS_PATH)

0 commit comments

Comments
 (0)