* [PATCH 0/2] selftests/kvm: Fixes for demand paging test
@ 2023-04-27 20:11 Peter Xu
2023-04-27 20:11 ` [PATCH 1/2] selftests/kvm: Setup vcpu_alias only for minor mode test Peter Xu
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Peter Xu @ 2023-04-27 20:11 UTC (permalink / raw)
To: linux-kernel, kvm
Cc: Sean Christopherson, Paolo Bonzini, James Houghton, peterx,
Anish Moorthy
Two trivial fixes per subject, please see each patch, thanks.
Peter Xu (2):
selftests/kvm: Setup vcpu_alias only for minor mode test
selftests/kvm: Allow dump per-vcpu info for uffd threads
.../testing/selftests/kvm/demand_paging_test.c | 17 +++++++++--------
.../selftests/kvm/lib/userfaultfd_util.c | 4 ++--
2 files changed, 11 insertions(+), 10 deletions(-)
--
2.39.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] selftests/kvm: Setup vcpu_alias only for minor mode test
2023-04-27 20:11 [PATCH 0/2] selftests/kvm: Fixes for demand paging test Peter Xu
@ 2023-04-27 20:11 ` Peter Xu
2023-04-27 20:35 ` James Houghton
2023-04-27 20:11 ` [PATCH 2/2] selftests/kvm: Allow dump per-vcpu info for uffd threads Peter Xu
2023-06-02 1:23 ` [PATCH 0/2] selftests/kvm: Fixes for demand paging test Sean Christopherson
2 siblings, 1 reply; 6+ messages in thread
From: Peter Xu @ 2023-04-27 20:11 UTC (permalink / raw)
To: linux-kernel, kvm
Cc: Sean Christopherson, Paolo Bonzini, James Houghton, peterx,
Anish Moorthy
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@redhat.com>
---
.../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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] selftests/kvm: Allow dump per-vcpu info for uffd threads
2023-04-27 20:11 [PATCH 0/2] selftests/kvm: Fixes for demand paging test Peter Xu
2023-04-27 20:11 ` [PATCH 1/2] selftests/kvm: Setup vcpu_alias only for minor mode test Peter Xu
@ 2023-04-27 20:11 ` Peter Xu
2023-04-27 20:34 ` James Houghton
2023-06-02 1:23 ` [PATCH 0/2] selftests/kvm: Fixes for demand paging test Sean Christopherson
2 siblings, 1 reply; 6+ messages in thread
From: Peter Xu @ 2023-04-27 20:11 UTC (permalink / raw)
To: linux-kernel, kvm
Cc: Sean Christopherson, Paolo Bonzini, James Houghton, peterx,
Anish Moorthy
There's one PER_VCPU_DEBUG in per-vcpu uffd threads but it's never hit.
Trigger that when quit in normal ways (kick pollfd[1]), meanwhile fix the
number of nanosec calculation.
Signed-off-by: Peter Xu <peterx@redhat.com>
---
tools/testing/selftests/kvm/lib/userfaultfd_util.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/kvm/lib/userfaultfd_util.c b/tools/testing/selftests/kvm/lib/userfaultfd_util.c
index 92cef20902f1..271f63891581 100644
--- a/tools/testing/selftests/kvm/lib/userfaultfd_util.c
+++ b/tools/testing/selftests/kvm/lib/userfaultfd_util.c
@@ -70,7 +70,7 @@ static void *uffd_handler_thread_fn(void *arg)
r = read(pollfd[1].fd, &tmp_chr, 1);
TEST_ASSERT(r == 1,
"Error reading pipefd in UFFD thread\n");
- return NULL;
+ break;
}
if (!(pollfd[0].revents & POLLIN))
@@ -103,7 +103,7 @@ static void *uffd_handler_thread_fn(void *arg)
ts_diff = timespec_elapsed(start);
PER_VCPU_DEBUG("userfaulted %ld pages over %ld.%.9lds. (%f/sec)\n",
pages, ts_diff.tv_sec, ts_diff.tv_nsec,
- pages / ((double)ts_diff.tv_sec + (double)ts_diff.tv_nsec / 100000000.0));
+ pages / ((double)ts_diff.tv_sec + (double)ts_diff.tv_nsec / NSEC_PER_SEC));
return NULL;
}
--
2.39.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] selftests/kvm: Allow dump per-vcpu info for uffd threads
2023-04-27 20:11 ` [PATCH 2/2] selftests/kvm: Allow dump per-vcpu info for uffd threads Peter Xu
@ 2023-04-27 20:34 ` James Houghton
0 siblings, 0 replies; 6+ messages in thread
From: James Houghton @ 2023-04-27 20:34 UTC (permalink / raw)
To: Peter Xu
Cc: linux-kernel, kvm, Sean Christopherson, Paolo Bonzini,
Anish Moorthy
On Thu, Apr 27, 2023 at 1:11 PM Peter Xu <peterx@redhat.com> wrote:
>
> There's one PER_VCPU_DEBUG in per-vcpu uffd threads but it's never hit.
>
> Trigger that when quit in normal ways (kick pollfd[1]), meanwhile fix the
> number of nanosec calculation.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: James Houghton <jthoughton@google.com>
> ---
> tools/testing/selftests/kvm/lib/userfaultfd_util.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/lib/userfaultfd_util.c b/tools/testing/selftests/kvm/lib/userfaultfd_util.c
> index 92cef20902f1..271f63891581 100644
> --- a/tools/testing/selftests/kvm/lib/userfaultfd_util.c
> +++ b/tools/testing/selftests/kvm/lib/userfaultfd_util.c
> @@ -70,7 +70,7 @@ static void *uffd_handler_thread_fn(void *arg)
> r = read(pollfd[1].fd, &tmp_chr, 1);
> TEST_ASSERT(r == 1,
> "Error reading pipefd in UFFD thread\n");
> - return NULL;
> + break;
> }
>
> if (!(pollfd[0].revents & POLLIN))
> @@ -103,7 +103,7 @@ static void *uffd_handler_thread_fn(void *arg)
> ts_diff = timespec_elapsed(start);
> PER_VCPU_DEBUG("userfaulted %ld pages over %ld.%.9lds. (%f/sec)\n",
> pages, ts_diff.tv_sec, ts_diff.tv_nsec,
> - pages / ((double)ts_diff.tv_sec + (double)ts_diff.tv_nsec / 100000000.0));
> + pages / ((double)ts_diff.tv_sec + (double)ts_diff.tv_nsec / NSEC_PER_SEC));
I almost confused this fix for [1]. Thanks for catching this!
[1]: https://lore.kernel.org/kvm/20230223001805.2971237-1-amoorthy@google.com/
>
> return NULL;
> }
> --
> 2.39.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] selftests/kvm: Setup vcpu_alias only for minor mode test
2023-04-27 20:11 ` [PATCH 1/2] selftests/kvm: Setup vcpu_alias only for minor mode test Peter Xu
@ 2023-04-27 20:35 ` James Houghton
0 siblings, 0 replies; 6+ messages in thread
From: James Houghton @ 2023-04-27 20:35 UTC (permalink / raw)
To: Peter Xu
Cc: linux-kernel, kvm, Sean Christopherson, Paolo Bonzini,
Anish Moorthy
On Thu, Apr 27, 2023 at 1:11 PM Peter Xu <peterx@redhat.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@redhat.com>
Reviewed-by: James Houghton <jthoughton@google.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
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] selftests/kvm: Fixes for demand paging test
2023-04-27 20:11 [PATCH 0/2] selftests/kvm: Fixes for demand paging test Peter Xu
2023-04-27 20:11 ` [PATCH 1/2] selftests/kvm: Setup vcpu_alias only for minor mode test Peter Xu
2023-04-27 20:11 ` [PATCH 2/2] selftests/kvm: Allow dump per-vcpu info for uffd threads Peter Xu
@ 2023-06-02 1:23 ` Sean Christopherson
2 siblings, 0 replies; 6+ messages in thread
From: Sean Christopherson @ 2023-06-02 1:23 UTC (permalink / raw)
To: Sean Christopherson, linux-kernel, kvm, Peter Xu
Cc: Paolo Bonzini, James Houghton, Anish Moorthy
On Thu, 27 Apr 2023 16:11:10 -0400, Peter Xu wrote:
> Two trivial fixes per subject, please see each patch, thanks.
>
> Peter Xu (2):
> selftests/kvm: Setup vcpu_alias only for minor mode test
> selftests/kvm: Allow dump per-vcpu info for uffd threads
>
> .../testing/selftests/kvm/demand_paging_test.c | 17 +++++++++--------
> .../selftests/kvm/lib/userfaultfd_util.c | 4 ++--
> 2 files changed, 11 insertions(+), 10 deletions(-)
>
> [...]
Applied to kvm-x86 selftests, thanks!
[1/2] selftests/kvm: Setup vcpu_alias only for minor mode test
https://github.com/kvm-x86/linux/commit/ba125de35da5
[2/2] selftests/kvm: Allow dump per-vcpu info for uffd threads
https://github.com/kvm-x86/linux/commit/21912a653d7d
--
https://github.com/kvm-x86/linux/tree/next
https://github.com/kvm-x86/linux/tree/fixes
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-06-02 1:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-27 20:11 [PATCH 0/2] selftests/kvm: Fixes for demand paging test Peter Xu
2023-04-27 20:11 ` [PATCH 1/2] selftests/kvm: Setup vcpu_alias only for minor mode test Peter Xu
2023-04-27 20:35 ` James Houghton
2023-04-27 20:11 ` [PATCH 2/2] selftests/kvm: Allow dump per-vcpu info for uffd threads Peter Xu
2023-04-27 20:34 ` James Houghton
2023-06-02 1:23 ` [PATCH 0/2] selftests/kvm: Fixes for demand paging test Sean Christopherson
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.