Re: [PATCH 11/15] KVM: selftests: Create VM with adjusted number of guest pages for perf tests

From: Ben Gardon
Date: Wed Feb 10 2021 - 20:34:06 EST


On Wed, Feb 10, 2021 at 3:06 PM Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
>
> Use the already computed guest_num_pages when creating the so called
> extra VM pages for a perf test, and add a comment explaining why the
> pages are allocated as extra pages.
>
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>

Reviewed-by: Ben Gardon <bgardon@xxxxxxxxxx>

> ---
> tools/testing/selftests/kvm/lib/perf_test_util.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/lib/perf_test_util.c b/tools/testing/selftests/kvm/lib/perf_test_util.c
> index 982a86c8eeaa..9b0cfdf10772 100644
> --- a/tools/testing/selftests/kvm/lib/perf_test_util.c
> +++ b/tools/testing/selftests/kvm/lib/perf_test_util.c
> @@ -71,9 +71,12 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus,
> TEST_ASSERT(vcpu_memory_bytes % pta->guest_page_size == 0,
> "Guest memory size is not guest page size aligned.");
>
> - vm = vm_create_with_vcpus(mode, vcpus,
> - (vcpus * vcpu_memory_bytes) / pta->guest_page_size,
> - 0, guest_code, NULL);
> + /*
> + * Pass guest_num_pages to populate the page tables for test memory.
> + * The memory is also added to memslot 0, but that's a benign side
> + * effect as KVM allows aliasing HVAs in memslots.
> + */
> + vm = vm_create_with_vcpus(mode, vcpus, 0, guest_num_pages, guest_code, NULL);
> pta->vm = vm;
>
> /*
> --
> 2.30.0.478.g8a0d178c01-goog
>