close
Skip to content

Commit 8df792d

Browse files
tests: enable aarch64 SMT topology coverage
Update integration tests to verify SMT can be configured on aarch64 and that guest CPU topology reflects the configured thread count. Add focused 2-vCPU and 4-vCPU cases that assert two threads per core. Signed-off-by: Nathan Chen <nathanc@nvidia.com>
1 parent c23e6d4 commit 8df792d

3 files changed

Lines changed: 44 additions & 25 deletions

File tree

‎tests/integration_tests/functional/test_api.py‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,15 +348,8 @@ def test_api_machine_config(uvm):
348348
response = test_microvm.api.machine_config.get()
349349
assert response.json()["smt"] is False
350350

351-
# Test that smt=True errors on ARM.
352-
if platform.machine() == "x86_64":
353-
test_microvm.api.machine_config.patch(smt=True)
354-
elif platform.machine() == "aarch64":
355-
expected_msg = (
356-
"Enabling simultaneous multithreading is not supported on aarch64"
357-
)
358-
with pytest.raises(RuntimeError, match=expected_msg):
359-
test_microvm.api.machine_config.patch(smt=True)
351+
# Test that smt=True is accepted.
352+
test_microvm.api.machine_config.patch(smt=True)
360353

361354
# Test invalid mem_size_mib < 0.
362355
with pytest.raises(RuntimeError):

‎tests/integration_tests/functional/test_cmd_line_start.py‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import json
66
import os
7-
import platform
87
import re
98
import shutil
109
from pathlib import Path
@@ -204,8 +203,8 @@ def test_config_bad_machine_config(uvm, vm_config_file):
204203
@pytest.mark.parametrize(
205204
"test_config",
206205
[
207-
("framework/vm_config_cpu_template_C3.json", True, False),
208-
("framework/vm_config_smt_true.json", False, True),
206+
("framework/vm_config_cpu_template_C3.json", True),
207+
("framework/vm_config_smt_true.json", False),
209208
],
210209
)
211210
def test_config_machine_config_params(uvm, test_config):
@@ -216,7 +215,7 @@ def test_config_machine_config_params(uvm, test_config):
216215

217216
# Test configuration determines if the file is a valid config or not
218217
# based on the CPU
219-
vm_config_file, cpu_template_used, smt_used = test_config
218+
vm_config_file, cpu_template_used = test_config
220219

221220
_configure_vm_from_json(test_microvm, vm_config_file)
222221
test_microvm.jailer.extra_args.update({"no-api": None})
@@ -226,8 +225,6 @@ def test_config_machine_config_params(uvm, test_config):
226225
should_fail = False
227226
if cpu_template_used and "C3" not in SUPPORTED_CPU_TEMPLATES:
228227
should_fail = True
229-
if smt_used and (platform.machine() == "aarch64"):
230-
should_fail = True
231228

232229
if should_fail:
233230
test_microvm.check_any_log_message(

‎tests/integration_tests/functional/test_topology.py‎

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from packaging import version
1010

1111
import framework.utils_cpuid as utils
12+
from framework.artifacts import GUEST_KERNEL_DEFAULT, pin_guest_kernel
1213
from framework.properties import global_props
1314
from framework.utils import get_kernel_version
1415

@@ -35,7 +36,7 @@ def _check_cpu_topology(
3536
expected_lscpu_output = {
3637
"CPU(s)": str(expected_cpu_count),
3738
"On-line CPU(s) list": expected_cpus_list,
38-
"Thread(s) per core": "1",
39+
"Thread(s) per core": str(expected_threads_per_core),
3940
"Core(s) per cluster": str(
4041
int(expected_cpu_count / expected_threads_per_core)
4142
),
@@ -59,14 +60,16 @@ def _check_cpu_topology(
5960
"depth 7": f"{expected_cpu_count} PU (type #3)",
6061
}
6162
else:
63+
threads_per_core = expected_threads_per_core
64+
cores = int(expected_cpu_count / threads_per_core)
6265
expected_hwloc_output = {
6366
"depth 0": "1 Machine (type #0)",
6467
"depth 1": "1 Package (type #1)",
6568
"depth 2": "1 L3Cache (type #6)",
66-
"depth 3": f"{expected_cpu_count} L2Cache (type #5)",
67-
"depth 4": f"{expected_cpu_count} L1dCache (type #4)",
68-
"depth 5": f"{expected_cpu_count} L1iCache (type #9)",
69-
"depth 6": f"{expected_cpu_count} Core (type #2)",
69+
"depth 3": f"{cores if threads_per_core > 1 else expected_cpu_count} L2Cache (type #5)",
70+
"depth 4": f"{cores if threads_per_core > 1 else expected_cpu_count} L1dCache (type #4)",
71+
"depth 5": f"{cores if threads_per_core > 1 else expected_cpu_count} L1iCache (type #9)",
72+
"depth 6": f"{cores} Core (type #2)",
7073
"depth 7": f"{expected_cpu_count} PU (type #3)",
7174
}
7275

@@ -192,15 +195,43 @@ def _check_cache_topology_arm(test_microvm, no_cpus, kernel_version_tpl):
192195
assert guest_slice == host_slice
193196

194197

198+
@pin_guest_kernel(GUEST_KERNEL_DEFAULT)
199+
@pytest.mark.parametrize("num_vcpus", [2, 4])
200+
def test_aarch64_smt_threads_per_core(uvm, num_vcpus):
201+
"""
202+
Check the guest-visible SMT topology without asserting cache hierarchy details.
203+
"""
204+
if PLATFORM != "aarch64":
205+
pytest.skip("This test verifies aarch64 SMT topology.")
206+
207+
vm = uvm
208+
vm.spawn()
209+
vm.basic_config(vcpu_count=num_vcpus, smt=True)
210+
vm.add_net_iface()
211+
vm.start()
212+
213+
utils.check_guest_cpuid_output(
214+
vm,
215+
"lscpu",
216+
None,
217+
":",
218+
{
219+
"CPU(s)": str(num_vcpus),
220+
"On-line CPU(s) list": "0,1" if num_vcpus == 2 else "0-3",
221+
"Thread(s) per core": "2",
222+
"Core(s) per cluster": str(num_vcpus // 2),
223+
"Cluster(s)": "1",
224+
"NUMA node(s)": "1",
225+
},
226+
)
227+
228+
195229
@pytest.mark.parametrize("num_vcpus", [1, 2, 16])
196230
@pytest.mark.parametrize("htt", [True, False], ids=["HTT_ON", "HTT_OFF"])
197231
def test_cpu_topology(uvm, num_vcpus, htt):
198232
"""
199233
Check the CPU topology for a microvm with the specified config.
200234
"""
201-
if htt and PLATFORM == "aarch64":
202-
pytest.skip("SMT is configurable only on x86.")
203-
204235
# TODO:Remove (or adapt) this once we unify the way we expose the CPU cache hierarchy on
205236
# Aarch64 systems.
206237
if version.parse(get_kernel_version()) >= version.parse("6.14"):
@@ -232,8 +263,6 @@ def test_cache_topology(uvm, num_vcpus, htt):
232263
"""
233264
Check the cache topology for a microvm with the specified config.
234265
"""
235-
if htt and PLATFORM == "aarch64":
236-
pytest.skip("SMT is configurable only on x86.")
237266
vm = uvm
238267
vm.spawn()
239268
vm.basic_config(vcpu_count=num_vcpus, smt=htt)

0 commit comments

Comments
 (0)