[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CADrL8HWxdTBD5fKiK9BKRUFCghK_nd1oNOkykmh4RYbn4C7UgA@mail.gmail.com>
Date: Thu, 27 Apr 2023 13:35:11 -0700
From: James Houghton <jthoughton@...gle.com>
To: Peter Xu <peterx@...hat.com>
Cc: linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
Sean Christopherson <seanjc@...gle.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Anish Moorthy <amoorthy@...gle.com>
Subject: Re: [PATCH 1/2] selftests/kvm: Setup vcpu_alias only for minor mode test
On Thu, Apr 27, 2023 at 1:11 PM Peter Xu <peterx@...hat.com> wrote:
>
> This fixes two things:
>
> - Unbreaks MISSING mode test on anonymous memory type
>
> - Prefault alias mem before uffd thread creations, otherwise the uffd
> thread timing will be inaccurate when guest mem size is large, because
> it'll take prefault time into total time.
>
> Signed-off-by: Peter Xu <peterx@...hat.com>
Reviewed-by: James Houghton <jthoughton@...gle.com>
FWIW, it looks like this fixes this commit[1]. Not sure if it's worth
a Fixes: tag.
[1]: commit a93871d0ea9f ("KVM: selftests: Add a userfaultfd library")
> ---
> .../testing/selftests/kvm/demand_paging_test.c | 17 +++++++++--------
> 1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/demand_paging_test.c b/tools/testing/selftests/kvm/demand_paging_test.c
> index 2439c4043fed..9c18686b4f63 100644
> --- a/tools/testing/selftests/kvm/demand_paging_test.c
> +++ b/tools/testing/selftests/kvm/demand_paging_test.c
> @@ -128,6 +128,7 @@ static void prefault_mem(void *alias, uint64_t len)
>
> static void run_test(enum vm_guest_mode mode, void *arg)
> {
> + struct memstress_vcpu_args *vcpu_args;
> struct test_params *p = arg;
> struct uffd_desc **uffd_descs = NULL;
> struct timespec start;
> @@ -145,24 +146,24 @@ static void run_test(enum vm_guest_mode mode, void *arg)
> "Failed to allocate buffer for guest data pattern");
> memset(guest_data_prototype, 0xAB, demand_paging_size);
>
> + if (p->uffd_mode == UFFDIO_REGISTER_MODE_MINOR) {
> + for (i = 0; i < nr_vcpus; i++) {
> + vcpu_args = &memstress_args.vcpu_args[i];
> + prefault_mem(addr_gpa2alias(vm, vcpu_args->gpa),
> + vcpu_args->pages * memstress_args.guest_page_size);
> + }
> + }
> +
> if (p->uffd_mode) {
> uffd_descs = malloc(nr_vcpus * sizeof(struct uffd_desc *));
> TEST_ASSERT(uffd_descs, "Memory allocation failed");
> -
> for (i = 0; i < nr_vcpus; i++) {
> - struct memstress_vcpu_args *vcpu_args;
> void *vcpu_hva;
> - void *vcpu_alias;
>
> vcpu_args = &memstress_args.vcpu_args[i];
>
> /* Cache the host addresses of the region */
> vcpu_hva = addr_gpa2hva(vm, vcpu_args->gpa);
> - vcpu_alias = addr_gpa2alias(vm, vcpu_args->gpa);
> -
> - prefault_mem(vcpu_alias,
> - vcpu_args->pages * memstress_args.guest_page_size);
> -
> /*
> * Set up user fault fd to handle demand paging
> * requests.
> --
> 2.39.1
>
Powered by blists - more mailing lists