All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Michael Roth <michael.roth@amd.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	pbonzini@redhat.com, vannapurve@google.com
Subject: Re: [PATCH gmem] KVM: selftests: Fix gmem conversion tests for multiple vCPUs
Date: Mon, 23 Oct 2023 11:06:49 -0700	[thread overview]
Message-ID: <ZTa2OWVjSOUtm0Ea@google.com> (raw)
In-Reply-To: <ZS8wdNtAoSvH_jpX@google.com>

On Tue, Oct 17, 2023, Sean Christopherson wrote:
> On Mon, Oct 16, 2023, Michael Roth wrote:
> > +			vm_mem_add(vm, src_type, BASE_DATA_GPA + size * i,
> > +				   BASE_DATA_SLOT + i, size / vm->page_size,
> > +				   KVM_MEM_PRIVATE, memfd, size * i);
> 
> But I think that's a moot point, because isn't it easier to do this?
> 
> diff --git a/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c b/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c
> index c04e7d61a585..c99073098f98 100644
> --- a/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c
> @@ -367,6 +367,7 @@ static void test_mem_conversions(enum vm_mem_backing_src_type src_type, uint32_t
>          */
>         const size_t size = align_up(PER_CPU_DATA_SIZE, get_backing_src_pagesz(src_type));
>         const size_t memfd_size = size * nr_vcpus;
> +       const size_t slot_size = memfd_size / nr_memslots;
>         struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
>         pthread_t threads[KVM_MAX_VCPUS];
>         uint64_t gmem_flags;
> @@ -390,7 +391,7 @@ static void test_mem_conversions(enum vm_mem_backing_src_type src_type, uint32_t
>  
>         for (i = 0; i < nr_memslots; i++)
>                 vm_mem_add(vm, src_type, BASE_DATA_GPA + size * i,
> -                          BASE_DATA_SLOT + i, size / vm->page_size,
> +                          BASE_DATA_SLOT + i, slot_size / vm->page_size,
>                            KVM_MEM_PRIVATE, memfd, size * i);

This isn't quite right, the stride and offset needs to be per-memslot too.  Argh,
I created quite the mess by trying to take a shortcut for testing multiple memslots,
i.e. by only allowing '1' or "nr_vcpus" memslots.  Much of the code assumes that
ranges can't be covered by multiple memslots, e.g. the UCALL_SYNC handler assumes
the entire range is contiguous in the host virtual address space.

And I think there's meaningful coverage we're not getting, e.g. as is I don't think
we're testing KVM_SET_MEMORY_ATTRIBUTES across multiple memslots (thankfully we
seem to have gotten the KVM side of things correct).

I'll post a small series to clean up the mess and let the user specify the number
of memslots (with some restrictions to keep the code relatively simple).

      reply	other threads:[~2023-10-23 18:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-16 18:47 [PATCH gmem] KVM: selftests: Fix gmem conversion tests for multiple vCPUs Michael Roth
2023-10-18  1:10 ` Sean Christopherson
2023-10-23 18:06   ` Sean Christopherson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZTa2OWVjSOUtm0Ea@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.roth@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=vannapurve@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.