Skip to content

Commit

Permalink
Merge pull request #3689 from zhenyzha/check_pagesize
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulYuuu authored May 9, 2023
2 parents 82e2de2 + dbf5604 commit 8cf36d7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
15 changes: 6 additions & 9 deletions qemu/tests/cfg/check_basepage_size.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
kill_vm = yes
start_vm = no
mem = 4096
get_page_size = 'getconf PAGE_SIZE'
Host_RHEL.m8:
page_size_host = 65536
Host_RHEL.m9:
page_size_host = 4096
RHEL.8:
page_size_guest = 65536
RHEL.9:
page_size_guest = 4096
get_basic_page = "getconf PAGE_SIZE"
local_pglist = "/sys/kernel/mm/hugepages/"
basic_page_list = "4096 16384 65536"
mapping_pgsize_4k = "hugepages-1048576kB hugepages-2048kB hugepages-32768kB hugepages-64kB"
mapping_pgsize_16k = "hugepages-1048576kB hugepages-2048kB hugepages-32768kB"
mapping_pgsize_64k = "hugepages-16777216kB hugepages-2048kB hugepages-524288kB"
40 changes: 31 additions & 9 deletions qemu/tests/check_basepage_size.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,57 @@
import os

from avocado.utils import process

from virttest import env_process
from virttest import error_context

from virttest.utils_numeric import normalize_data_size


@error_context.context_aware
def run(test, params, env):
"""
Check the basic page size.
Steps:
1) Check system configuration basic page size on host.
2) Boot a guest on the host.
3) Check system configuration basic page size on guest.
2) Check the basic page size mapping to the hugepage size on host.
3) Boot a guest on the host.
4) Check system configuration basic page size on guest.
5) Check the basic page size mapping to the hugepage size on guest.
:params test: QEMU test object.
:params params: Dictionary with the test parameters.
:params env: Dictionary with test environment.
"""
get_page_size = params.get('get_page_size')
get_basic_page = params.get('get_basic_page')
local_pglist = params.get('local_pglist')
basic_page_list = params.objects('basic_page_list')

test.log.info("Check system configuration basic page size on host.")
host_page_size = process.system_output(get_page_size).decode()
if host_page_size != params.get("page_size_host"):
test.fail("Host page size is %s not as expected." % host_page_size)
host_basic_page = process.system_output(get_basic_page).decode()
if host_basic_page not in basic_page_list:
test.fail("Host basic page size is %s not as expected." % host_basic_page)

test.log.info("Check the basic page size mapping to the hugepage size on host.")
host_basic_page = normalize_data_size("%sB" % host_basic_page, "K")
hugepage_list = params.objects("mapping_pgsize_%sk" % host_basic_page)
host_local_pglist = os.listdir(local_pglist)
if sorted(host_local_pglist) != sorted(hugepage_list):
test.fail("Host huge page size is %s not as expected." % host_local_pglist)

params["start_vm"] = "yes"
env_process.preprocess_vm(test, params, env, params["main_vm"])
vm = env.get_vm(params["main_vm"])
session = vm.wait_for_login()

test.log.info("Check system configuration basic page size on guest.")
guest_page_size = session.cmd(get_page_size).strip()
if guest_page_size != params.get("page_size_guest"):
test.fail("Guest page size is %s not as expected." % guest_page_size)
guest_basic_page = session.cmd(get_basic_page).strip()
if guest_basic_page not in basic_page_list:
test.fail("Guest page size is %s not as expected." % guest_basic_page)

test.log.info("Check the basic page size mapping to the hugepage size on guest.")
guest_basic_page = normalize_data_size("%sB" % guest_basic_page, "K")
hugepage_list = params.objects("mapping_pgsize_%sk" % guest_basic_page)
guest_local_pglist = session.cmd("ls %s" % local_pglist).strip().split()
if sorted(guest_local_pglist) != sorted(hugepage_list):
test.fail("Guest huge page size is %s not as expected." % guest_local_pglist)

0 comments on commit 8cf36d7

Please sign in to comment.