Skip to content

Commit a00d324

Browse files
authored
Merge pull request #4252 from mcasquer/3321_netperf_numa_node
netperf: implements dynamic NUMA binding
2 parents 2eb49fd + 7de1eb7 commit a00d324

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

generic/tests/cfg/netperf.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
- netperf: install setup image_copy unattended_install.cdrom
22
virt_test_type = qemu libvirt
33
type = netperf
4+
not_preprocess = yes
45
kill_vm = yes
56
image_snapshot = yes
67
setup_ksm = no
@@ -32,7 +33,6 @@
3233
# bridge_force_create=yes
3334
# bridge_nic1 =
3435
#numa configration
35-
numa_node = -1
3636
netperf_with_numa = yes
3737
# configure netperf test parameters, some seconds will be took to
3838
# wait all the clients work, this wait time should be less than

generic/tests/netperf.py

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@
55
import time
66

77
from avocado.utils import process
8-
from virttest import error_context, remote, utils_misc, utils_net, utils_test, virt_vm
8+
from virttest import (
9+
env_process,
10+
error_context,
11+
remote,
12+
utils_misc,
13+
utils_net,
14+
utils_test,
15+
virt_vm,
16+
)
917

1018
from provider import netperf_base, win_driver_utils
1119

@@ -136,8 +144,29 @@ def mtu_set(mtu):
136144
"The ethenet device does not support jumbo," "cancel test"
137145
)
138146

139-
vm = env.get_vm(params["main_vm"])
140-
vm.verify_alive()
147+
pinned_node = 0
148+
host_numa = utils_misc.NumaInfo()
149+
node_list = host_numa.online_nodes_withcpumem
150+
mem = int(params["mem"])
151+
mem_kb = mem * 1024
152+
try:
153+
for node in node_list:
154+
node_mem_free = int(host_numa.read_from_node_meminfo(node, "MemFree"))
155+
if node_mem_free > mem_kb:
156+
pinned_node = node
157+
break
158+
params["qemu_command_prefix"] = f"numactl -m {pinned_node}"
159+
vm_name = params["main_vm"]
160+
env_process.process(
161+
test, params, env, env_process.preprocess_image, env_process.preprocess_vm
162+
)
163+
vm = env.get_vm(vm_name)
164+
vm.verify_alive()
165+
except virt_vm.VMCreateError as e:
166+
if f"node argument {pinned_node} is out of range" in str(e):
167+
test.cancel(f"The node: {pinned_node} used for VM pinning is not valid")
168+
test.error(e)
169+
141170
login_timeout = int(params.get("login_timeout", 360))
142171

143172
config_cmds = params.get("config_cmds")

0 commit comments

Comments
 (0)