]> git.baikalelectronics.ru Git - kernel.git/commit
selftests: kvm: Add support for customized slot0 memory size
authorZhenzhong Duan <zhenzhong.duan@intel.com>
Tue, 8 Jun 2021 23:38:16 +0000 (07:38 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 8 Jun 2021 17:29:10 +0000 (13:29 -0400)
commit5d0bf1d3154e8727a4d9bde98a179d186cbf8484
treeff09930eb43c0805605e51e63bfdf2d52c07366e
parenta962a1190783297029ca6e2f3f73a98b5f71132b
selftests: kvm: Add support for customized slot0 memory size

Until commit 94eb786ccb79 ("selftests: kvm: make allocation of extra
memory take effect", 2021-05-27), parameter extra_mem_pages was used
only to calculate the page table size for all the memory chunks,
because real memory allocation happened with calls of
vm_userspace_mem_region_add() after vm_create_default().

Commit 94eb786ccb79 however changed the meaning of extra_mem_pages to
the size of memory slot 0.  This makes the memory allocation more
flexible, but makes it harder to account for the number of
pages needed for the page tables.  For example, memslot_perf_test
has a small amount of memory in slot 0 but a lot in other slots,
and adding that memory twice (both in slot 0 and with later
calls to vm_userspace_mem_region_add()) causes an error that
was fixed in commit 047e35ebec42 ("selftests: kvm: fix overlapping
addresses in memslot_perf_test", 2021-05-29)

Since both uses are sensible, add a new parameter slot0_mem_pages
to vm_create_with_vcpus() and some comments to clarify the meaning of
slot0_mem_pages and extra_mem_pages.  With this change,
memslot_perf_test can go back to passing the number of memory
pages as extra_mem_pages.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Message-Id: <20210608233816.423958-4-zhenzhong.duan@intel.com>
[Squashed in a single patch and rewrote the commit message. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/include/kvm_util.h
tools/testing/selftests/kvm/kvm_page_table_test.c
tools/testing/selftests/kvm/lib/kvm_util.c
tools/testing/selftests/kvm/lib/perf_test_util.c
tools/testing/selftests/kvm/memslot_perf_test.c