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 <[email protected]>
  • Loading branch information
mcasquer committed Nov 22, 2023
1 parent 058c584 commit ef9d355
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
13 changes: 13 additions & 0 deletions qemu/tests/cfg/numa_prealloc_handling.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
- 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 = "/usr/bin/time -f %%e taskset -c 0"
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} %s ${cmd_qemu_options} 2>&1 | tail -1"
cmd_with_tc = "${cmd_time_taskset} %s ${cmd_qemu_options}${cmd_option_tc} 2>&1 | tail -1"
30 changes: 30 additions & 0 deletions qemu/tests/numa_prealloc_handling.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from avocado.utils import process
from virttest import utils_misc


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
"""
qemu_path = utils_misc.get_qemu_binary(params)

cmd_without_tc = params.get("cmd_without_tc") % qemu_path
cmd_with_tc = params.get("cmd_with_tc") % qemu_path

execution_time = float(process.getoutput(cmd_without_tc,
ignore_status=True,
shell=True))
test.log.debug("Execution time without thread_context: %f" % execution_time)

execution_time_tc = float(process.getoutput(cmd_with_tc,
ignore_status=True,
shell=True))
test.log.debug("Execution time with thread_context: %f" % execution_time_tc)

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

0 comments on commit ef9d355

Please sign in to comment.