On Tue, Mar 23, 2021 at 09:52:27PM +0800, Yanan Wang wrote:
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
.../testing/selftests/kvm/include/test_util.h | 2 ++ tools/testing/selftests/kvm/lib/test_util.c | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+)
Reviewed-by: Andrew Jones drjones@redhat.com