summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/include/test_util.h
diff options
context:
space:
mode:
authorYanan Wang <wangyanan55@huawei.com>2021-03-30 11:08:52 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2021-04-20 11:18:52 +0300
commit3b70c4d128a7781f507fa072d60ce5df3fdfcaa6 (patch)
tree88bcc10c07cd03addc7ce82763ffc4ceb5183945 /tools/testing/selftests/kvm/include/test_util.h
parent6436430e29fb250c140c94a8fcc218a832dcaf74 (diff)
downloadlinux-3b70c4d128a7781f507fa072d60ce5df3fdfcaa6.tar.xz
KVM: selftests: Add a helper to get system configured THP page size
If we want to have some tests about transparent hugepages, the system configured THP hugepage size should better be known by the tests, which can be used for kinds of alignment or guest memory accessing of vcpus... So it makes sense to add a helper to get the transparent hugepage size. With VM_MEM_SRC_ANONYMOUS_THP specified in vm_userspace_mem_region_add(), we now stat /sys/kernel/mm/transparent_hugepage to check whether THP is configured in the host kernel before madvise(). Based on this, we can also read file /sys/kernel/mm/transparent_hugepage/hpage_pmd_size to get THP hugepage size. Signed-off-by: Yanan Wang <wangyanan55@huawei.com> Reviewed-by: Ben Gardon <bgardon@google.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Message-Id: <20210330080856.14940-7-wangyanan55@huawei.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools/testing/selftests/kvm/include/test_util.h')
-rw-r--r--tools/testing/selftests/kvm/include/test_util.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/include/test_util.h b/tools/testing/selftests/kvm/include/test_util.h
index b7f41399f22c..ef24c76ba89a 100644
--- a/tools/testing/selftests/kvm/include/test_util.h
+++ b/tools/testing/selftests/kvm/include/test_util.h
@@ -78,6 +78,8 @@ struct vm_mem_backing_src_alias {
enum vm_mem_backing_src_type type;
};
+bool thp_configured(void);
+size_t get_trans_hugepagesz(void);
void backing_src_help(void);
enum vm_mem_backing_src_type parse_backing_src_type(const char *type_name);