Skip to contentSkip to conversation

KVM: selftests: Remove duplicate VM in memslot_perf_test

PATCH In review Gavin Shan 3 participants 7 messages Jan 18, 2023 – Feb 8, 2023

Subsystems (3)
lore
Share & tools
lore

Gavin Shan

author
#0 lore raw

cover KVM: selftests: Remove duplicate VM in memslot_perf_test

PATCH[1] Removes the duplicate VM in memslot_perf_test PATCH[2] Assign guest page size in the sync area in prepare_vm()

Gavin Shan (2):
KVM: selftests: Remove duplicate VM in memslot_perf_test
KVM: selftests: Assign guest page size in sync area early in
memslot_perf_test

 tools/testing/selftests/kvm/memslot_perf_test.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
Signature · 1 line
2.23.0
author
#1 lore raw

PATCH 1/2 KVM: selftests: Remove duplicate VM in memslot_perf_test

There are two VMs created in prepare_vm(), which isn't necessary. To remove the second created and unnecessary VM.

---
 tools/testing/selftests/kvm/memslot_perf_test.c | 2 --
 1 file changed, 2 deletions(-)
tools/testing/selftests/kvm/memslot_perf_test.c +0 -2
index e6587e193490..adbbcca3e354 100644
@@ -308,8 +308,6 @@ static bool prepare_vm(struct vm_data *data, int nslots, uint64_t *maxslots,
 	data->hva_slots = malloc(sizeof(*data->hva_slots) * data->nslots);
 	TEST_ASSERT(data->hva_slots, "malloc() fail");
 
-	data->vm = __vm_create_with_one_vcpu(&data->vcpu, mempages, guest_code);
-
 	pr_info_v("Adding slots 1..%i, each slot with %"PRIu64" pages + %"PRIu64" extra pages last\n",
 		data->nslots, data->pages_per_slot, rempages);
 
Signature · 1 line
2.23.0
Reviewed-by on v1 1/2
#2 lore raw
Quoted 4 lines · Gavin Shan

There are two VMs created in prepare_vm(), which isn't necessary. To remove the second created and unnecessary VM.

It's weird that we ended with two __vm_create_with_one_vcpu() calls, it looks like the second one was accidentally (re-)introduced during 'kvmarm-6.2' merge, so maybe?:

Fixes eb5618911af0 ("Merge tag 'kvmarm-6.2' of https://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD")

Anyway, thanks for spotting this:

Thanks,
Maciej

author
#3 lore raw

Hi Maciej,

Quoted 6 lines · Maciej S. Szmigiero
Quoted 4 lines · Gavin Shan

There are two VMs created in prepare_vm(), which isn't necessary. To remove the second created and unnecessary VM.

Quoted 8 lines

It's weird that we ended with two __vm_create_with_one_vcpu() calls, it looks like the second one was accidentally (re-)introduced during 'kvmarm-6.2' merge, so maybe?:

Fixes eb5618911af0 ("Merge tag 'kvmarm-6.2' of https://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD")

Anyway, thanks for spotting this:

Thanks for your review. Right, it'd better to have the fix tag as your suggested. I think I probably needn't respin. I guess Paolo, Marc or Oliver may help to add the fix tag when it's merged.

Thanks,
Gavin

author
#4 lore raw

PATCH 2/2 KVM: selftests: Assign guest page size in sync area early in memslot_perf_test

In reply to Gavin Shan

The guest page size in the synchronization area is needed by all test cases. So it's reasonable to set it in the unified preparation function (prepare_vm()).

---
 tools/testing/selftests/kvm/memslot_perf_test.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/testing/selftests/kvm/memslot_perf_test.c +1 -2
index adbbcca3e354..4210cd21d159 100644
@@ -347,6 +347,7 @@ static bool prepare_vm(struct vm_data *data, int nslots, uint64_t *maxslots,
 	virt_map(data->vm, MEM_GPA, MEM_GPA, data->npages);
 
 	sync = (typeof(sync))vm_gpa2hva(data, MEM_SYNC_GPA, NULL);
+	sync->guest_page_size = data->vm->page_size;
 	atomic_init(&sync->start_flag, false);
 	atomic_init(&sync->exit_flag, false);
 	atomic_init(&sync->sync_flag, false);
@@ -808,8 +809,6 @@ static bool test_execute(int nslots, uint64_t *maxslots,
 	}
 
 	sync = (typeof(sync))vm_gpa2hva(data, MEM_SYNC_GPA, NULL);
-
-	sync->guest_page_size = data->vm->page_size;
 	if (tdata->prepare &&
 	    !tdata->prepare(data, sync, maxslots)) {
 		ret = false;
Signature · 1 line
2.23.0
#6 lore raw
In reply to Gavin Shan
Quoted 9 lines · Gavin Shan

PATCH[1] Removes the duplicate VM in memslot_perf_test PATCH[2] Assign guest page size in the sync area in prepare_vm()

Gavin Shan (2):
KVM: selftests: Remove duplicate VM in memslot_perf_test
KVM: selftests: Assign guest page size in sync area early in
memslot_perf_test

[...]

Applied to kvm-x86 selftests, thanks!

[1/2] KVM: selftests: Remove duplicate VM in memslot_perf_test

      https://github.com/kvm-x86/linux/commit/e5b426879fc3
[2/2] KVM: selftests: Assign guest page size in sync area early in memslot_perf_test
      https://github.com/kvm-x86/linux/commit/45f679550d72

--
https://github.com/kvm-x86/linux/tree/next
https://github.com/kvm-x86/linux/tree/fixes