Skip to content

Commit

Permalink
numa_prealloc_handling: Basic preallocation handling
Browse files Browse the repository at this point in the history
Creates a new case that measures the time that needs QEMU
to preallocate the memory with and without thread-context.

Signed-off-by: mcasquer <mcasquer@redhat.com>
  • Loading branch information
mcasquer committed Nov 20, 2023
1 parent 0aab577 commit def2dc4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
14 changes: 14 additions & 0 deletions qemu/tests/cfg/numa_prealloc_handling.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- numa_prealloc_handling:
no RHEL.6 RHEL.7 RHEL.8
no Host_RHEL.m6 Host_RHEL.m7 Host_RHEL.m8
required_qemu = [7.2,)
type = numa_prealloc_handling
virt_test_type = qemu
not_preprocess = yes
vms = ""
cmd_time_taskset = "{ time taskset -c 0"
cmd_qemu_binary_path = "/usr/libexec/qemu-kvm"
cmd_qemu_options = "-nographic -sandbox on,resourcecontrol=deny -monitor stdio -cpu host -object memory-backend-ram,id=mem0,size=20G,prealloc=on,prealloc-threads=4"
cmd_option_tc = ",prealloc-context=tc1 -object thread-context,id=tc1,cpu-affinity=1-7"
cmd_without_tc = "${cmd_time_taskset} ${cmd_qemu_binary_path} ${cmd_qemu_options} ; } 2>&1 | grep real"
cmd_with_tc = "${cmd_time_taskset} ${cmd_qemu_binary_path} ${cmd_qemu_options},${cmd_option_tc} ; } 2>&1 | grep real"
29 changes: 29 additions & 0 deletions qemu/tests/numa_prealloc_handling.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import re
from avocado.utils import process


def get_qemu_exec_time(cmd_line):
result = process.run(cmd_line, ignore_status=True, shell=True)
result = str(result.stdout).split("\\t")[-1].split("\\n")[0]
execution_time = int(re.sub("\\D", "", result))
return execution_time


def run(test, params, env):
"""
numa_prealloc_handling test
1) Measures the time takes QEMU to preallocate the memory
2) Checks the timing is shorter when thread-context is used
:param test: QEMU test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment
"""
cmd_without_tc = params.get("cmd_without_tc")
cmd_with_tc = params.get("cmd_with_tc")

execution_time = get_qemu_exec_time(cmd_without_tc)

execution_time_tc = get_qemu_exec_time(cmd_with_tc)

if execution_time <= execution_time_tc:
test.fail("There is no boot time speedup when using thread-context!")

0 comments on commit def2dc4

Please sign in to comment.