From dbf56047827294e168cfd55831300e0917cff931 Mon Sep 17 00:00:00 2001 From: zhenyzha Date: Sun, 23 Apr 2023 15:05:17 +0800 Subject: [PATCH] check_basepage_size:Add mapping hugepage check 1. Update basic page size to dynamic checking method 2. Add mapping hugepage check Signed-off-by: zhenyzha --- qemu/tests/cfg/check_basepage_size.cfg | 15 ++++------ qemu/tests/check_basepage_size.py | 40 ++++++++++++++++++++------ 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/qemu/tests/cfg/check_basepage_size.cfg b/qemu/tests/cfg/check_basepage_size.cfg index 29ef7ad941..11a61c906e 100644 --- a/qemu/tests/cfg/check_basepage_size.cfg +++ b/qemu/tests/cfg/check_basepage_size.cfg @@ -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" diff --git a/qemu/tests/check_basepage_size.py b/qemu/tests/check_basepage_size.py index b19d3006b6..b425829f87 100644 --- a/qemu/tests/check_basepage_size.py +++ b/qemu/tests/check_basepage_size.py @@ -1,8 +1,12 @@ +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): @@ -10,19 +14,30 @@ 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"]) @@ -30,6 +45,13 @@ def run(test, params, env): 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)