Skip to content

Commit 30b343b

Browse files
authored
Merge branch 'main' into kvm-bindings-0.8.0-again
2 parents 4e65114 + 4a28b9c commit 30b343b

File tree

2 files changed

+54
-19
lines changed

2 files changed

+54
-19
lines changed

tests/integration_tests/functional/test_topology.py

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,35 +78,73 @@ def _check_cache_topology_x86(
7878
)
7979

8080

81-
def _check_cache_topology_arm(test_microvm, no_cpus):
81+
def _aarch64_parse_cache_info(test_microvm, no_cpus):
82+
def parse_cache_info(info: str):
83+
"One line looks like this: /sys/devices/system/cpu/cpuX/cache/{index}/{name}:{value}"
84+
cache_info = []
85+
for line in info.splitlines():
86+
parts = line.split("/")
87+
88+
index = int(parts[-2][-1])
89+
90+
name, value = parts[-1].split(":")
91+
92+
if len(cache_info) == index:
93+
cache_info.append({})
94+
cache_info[index][name] = value
95+
return cache_info
96+
8297
# We will check the cache topology by looking at what each cpu
8398
# contains as far as cache info.
8499
# For that we are iterating through the hierarchy of folders inside:
85100
# /sys/devices/system/cpu/cpuX/cache/indexY/type - the type of the cache
86101
# (i.e Instruction, Data, Unified)
87102
# /sys/devices/system/cpu/cpuX/cache/indexY/size - size of the cache
88103
# /sys/devices/system/cpu/cpuX/cache/indexY/level - L1, L2 or L3 cache.
89-
# There are 2 types of L1 cache (instruction and data) that is why the
90-
# "cache_info" variable below has 4 items.
91-
92-
sys_cpu = "/sys/devices/system/cpu"
93104
fields = ["level", "type", "size", "coherency_line_size", "number_of_sets"]
94-
95-
cmd = f"grep . {sys_cpu}/cpu{{0..{no_cpus-1}}}/cache/index*/{{{','.join(fields)}}} |sort"
105+
cmd = f"grep . /sys/devices/system/cpu/cpu{{0..{no_cpus-1}}}/cache/index*/{{{','.join(fields)}}} |sort"
96106

97107
_, guest_stdout, guest_stderr = test_microvm.ssh.run(cmd)
98108
assert guest_stderr == ""
99109

100-
res = subprocess.run(
110+
host_result = subprocess.run(
101111
cmd,
102112
shell=True,
103113
executable="/bin/bash",
104114
capture_output=True,
105115
check=True,
106116
encoding="ascii",
107117
)
108-
assert res.stderr == ""
109-
assert res.stdout == guest_stdout
118+
assert host_result.stderr == ""
119+
host_stdout = host_result.stdout
120+
121+
guest_cache_info = parse_cache_info(guest_stdout)
122+
host_cache_info = parse_cache_info(host_stdout)
123+
124+
return guest_cache_info, host_cache_info
125+
126+
127+
def _check_cache_topology_arm(test_microvm, no_cpus, kernel_version_tpl):
128+
guest_cache_info, host_cache_info = _aarch64_parse_cache_info(test_microvm, no_cpus)
129+
130+
# Starting from 6.3 kernel cache representation for aarch64 platform has changed.
131+
# It is no longer equivalent to the host cache representation.
132+
# The main change is in the level 1 cache, so for newer kernels we
133+
# compare only level 2 and level 3 caches
134+
if kernel_version_tpl < (6, 3):
135+
assert guest_cache_info == host_cache_info
136+
else:
137+
guest_first_non_level_1 = 0
138+
while guest_cache_info[guest_first_non_level_1]["level"] == "1":
139+
guest_first_non_level_1 += 1
140+
guest_slice = guest_cache_info[guest_first_non_level_1:]
141+
142+
host_first_non_level_1 = 0
143+
while host_cache_info[host_first_non_level_1]["level"] == "1":
144+
host_first_non_level_1 += 1
145+
host_slice = host_cache_info[host_first_non_level_1:]
146+
147+
assert guest_slice == host_slice
110148

111149

112150
@pytest.mark.skipif(
@@ -129,12 +167,6 @@ def test_cpu_topology(uvm_plain_any, num_vcpus, htt):
129167
)
130168

131169

132-
# TODO remove this check once the solution for keeping
133-
# an old cache representation is found.
134-
@pytest.mark.skipif(
135-
global_props.host_linux_version == "6.5" and PLATFORM == "aarch64",
136-
reason="6.5 kernel changes cache representation for aarch64.",
137-
)
138170
@pytest.mark.parametrize("num_vcpus", [1, 2, 16])
139171
@pytest.mark.parametrize("htt", [True, False])
140172
def test_cache_topology(uvm_plain_any, num_vcpus, htt):
@@ -151,6 +183,6 @@ def test_cache_topology(uvm_plain_any, num_vcpus, htt):
151183
if PLATFORM == "x86_64":
152184
_check_cache_topology_x86(vm, 1 if htt and num_vcpus > 1 else 0, num_vcpus - 1)
153185
elif PLATFORM == "aarch64":
154-
_check_cache_topology_arm(vm, num_vcpus)
186+
_check_cache_topology_arm(vm, num_vcpus, global_props.host_linux_version_tpl)
155187
else:
156188
raise Exception("This test is not run on this platform!")

tools/test-popular-containers/build_rootfs.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ function make_rootfs {
4343
umount -l mnt
4444
rmdir mnt
4545

46-
systemd-nspawn --pipe -i $IMG /bin/sh <<EOF
46+
# --timezone=off parameter is needed to prevent systemd-nspawn from
47+
# bind-mounting /etc/timezone, which causes a file conflict in Ubuntu 24.04
48+
systemd-nspawn --timezone=off --pipe -i $IMG /bin/sh <<EOF
4749
set -x
4850
. /etc/os-release
4951
passwd -d root
@@ -65,5 +67,6 @@ EOF
6567

6668
make_rootfs alpine:latest
6769
make_rootfs ubuntu:22.04
68-
make_rootfs ubuntu:23.04
70+
make_rootfs ubuntu:23.10
71+
make_rootfs ubuntu:24.04
6972
# make_rootfs ubuntu:latest

0 commit comments

Comments
 (0)