From: Andrew Jones <drjones@redhat.com>
To: Ben Gardon <bgardon@google.com>
Cc: kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
Paolo Bonzini <pbonzini@redhat.com>,
Cannon Matthews <cannonmatthews@google.com>,
Peter Xu <peterx@redhat.com>
Subject: Re: [PATCH 4/9] KVM: selftests: Pass args to vCPU instead of using globals
Date: Thu, 3 Oct 2019 09:38:05 +0200 [thread overview]
Message-ID: <20191003073805.jnuj3tqgxjiuvo7c@kamzik.brq.redhat.com> (raw)
In-Reply-To: <20190927161836.57978-5-bgardon@google.com>
On Fri, Sep 27, 2019 at 09:18:32AM -0700, Ben Gardon wrote:
> In preparation for supporting multiple vCPUs in the demand paging test,
> pass arguments to the vCPU instead of syncing globals to it.
>
> Signed-off-by: Ben Gardon <bgardon@google.com>
> ---
> .../selftests/kvm/demand_paging_test.c | 61 +++++++++++--------
> 1 file changed, 37 insertions(+), 24 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/demand_paging_test.c b/tools/testing/selftests/kvm/demand_paging_test.c
> index 19982a33a0ca2..8fd46e99d9e30 100644
> --- a/tools/testing/selftests/kvm/demand_paging_test.c
> +++ b/tools/testing/selftests/kvm/demand_paging_test.c
> @@ -44,7 +44,6 @@
> */
> static uint64_t host_page_size;
> static uint64_t guest_page_size;
> -static uint64_t guest_num_pages;
>
> static char *guest_data_prototype;
>
> @@ -65,14 +64,13 @@ static uint64_t guest_test_virt_mem = DEFAULT_GUEST_TEST_MEM;
> * Continuously write to the first 8 bytes of each page in the demand paging
> * memory region.
> */
> -static void guest_code(void)
> +static void guest_code(uint64_t gva, uint64_t pages)
> {
> int i;
>
> - for (i = 0; i < guest_num_pages; i++) {
> - uint64_t addr = guest_test_virt_mem;
> + for (i = 0; i < pages; i++) {
> + uint64_t addr = gva + (i * guest_page_size);
>
> - addr += i * guest_page_size;
> addr &= ~(host_page_size - 1);
> *(uint64_t *)addr = 0x0123456789ABCDEF;
> }
> @@ -84,18 +82,31 @@ static void guest_code(void)
> static void *host_test_mem;
> static uint64_t host_num_pages;
>
> +struct vcpu_thread_args {
> + uint64_t gva;
> + uint64_t pages;
> + struct kvm_vm *vm;
> + int vcpu_id;
> +};
> +
> static void *vcpu_worker(void *data)
> {
> int ret;
> - struct kvm_vm *vm = data;
> + struct vcpu_thread_args *args = (struct vcpu_thread_args *)data;
> + struct kvm_vm *vm = args->vm;
> + int vcpu_id = args->vcpu_id;
> + uint64_t gva = args->gva;
> + uint64_t pages = args->pages;
> struct kvm_run *run;
>
> - run = vcpu_state(vm, VCPU_ID);
> + vcpu_args_set(vm, vcpu_id, 2, gva, pages);
AArch64 doesn't implement vcpu_args_set(), but I see in the first patch
that you've added this test to AArch64 as well.
Wouldn't it be easier to just create a global array of size nr-vcpus for
each variable that needs to be shared with the guest? Then derive the
per-cpu index from the acpi-id or maybe abuse some msr for it. We could
probably even add some macros to build some type of a per-cpu framework.
Thanks,
drew
next prev parent reply other threads:[~2019-10-03 7:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-27 16:18 [PATCH 0/9] Create a userfaultfd demand paging test Ben Gardon
2019-09-27 16:18 ` [PATCH 1/9] KVM: selftests: Create a " Ben Gardon
2019-09-27 16:18 ` [PATCH 2/9] KVM: selftests: Add demand paging content to the " Ben Gardon
2019-09-29 7:11 ` Peter Xu
2019-09-27 16:18 ` [PATCH 3/9] KVM: selftests: Add memory size parameter " Ben Gardon
2019-09-27 16:18 ` [PATCH 4/9] KVM: selftests: Pass args to vCPU instead of using globals Ben Gardon
2019-10-03 7:38 ` Andrew Jones [this message]
2019-09-27 16:18 ` [PATCH 5/9] KVM: selftests: Support multiple vCPUs in demand paging test Ben Gardon
2019-09-27 16:18 ` [PATCH 6/9] KVM: selftests: Time guest demand paging Ben Gardon
2019-09-27 16:18 ` [PATCH 7/9] KVM: selftests: Add parameter to _vm_create for memslot 0 base paddr Ben Gardon
2019-10-03 8:10 ` Andrew Jones
2019-09-27 16:18 ` [PATCH 8/9] KVM: selftests: Support large VMs in demand paging test Ben Gardon
2019-09-29 7:22 ` [PATCH 0/9] Create a userfaultfd " Peter Xu
2019-09-30 17:02 ` Ben Gardon
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=20191003073805.jnuj3tqgxjiuvo7c@kamzik.brq.redhat.com \
--to=drjones@redhat.com \
--cc=bgardon@google.com \
--cc=cannonmatthews@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).