]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: selftests: Move per-VM GPA into perf_test_args
authorSean Christopherson <seanjc@google.com>
Thu, 11 Nov 2021 00:03:06 +0000 (00:03 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 16 Nov 2021 12:43:26 +0000 (07:43 -0500)
Move the per-VM GPA into perf_test_args instead of storing it as a
separate global variable.  It's not obvious that guest_test_phys_mem
holds a GPA, nor that it's connected/coupled with per_vcpu->gpa.

No functional change intended.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Ben Gardon <bgardon@google.com>
Signed-off-by: David Matlack <dmatlack@google.com>
Message-Id: <20211111000310.1435032-9-dmatlack@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/include/perf_test_util.h
tools/testing/selftests/kvm/lib/perf_test_util.c
tools/testing/selftests/kvm/memslot_modification_stress_test.c

index 20aec72fe7b8957b79381f919362cd0e50857bc6..d7cde1ab2a85a91cb4159dbcd793f911f5a8a321 100644 (file)
@@ -29,6 +29,7 @@ struct perf_test_vcpu_args {
 struct perf_test_args {
        struct kvm_vm *vm;
        uint64_t host_page_size;
+       uint64_t gpa;
        uint64_t guest_page_size;
        int wr_fract;
 
@@ -37,13 +38,6 @@ struct perf_test_args {
 
 extern struct perf_test_args perf_test_args;
 
-/*
- * Guest physical memory offset of the testing memory slot.
- * This will be set to the topmost valid physical address minus
- * the test memory size.
- */
-extern uint64_t guest_test_phys_mem;
-
 struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus,
                                   uint64_t vcpu_memory_bytes, int slots,
                                   enum vm_mem_backing_src_type backing_src);
index d9c6bcb7964d81b4e4cb97f841e6a169a271e197..0fc2d834c1c7a24ea75975f4142268cc7caa4f38 100644 (file)
@@ -10,8 +10,6 @@
 
 struct perf_test_args perf_test_args;
 
-uint64_t guest_test_phys_mem;
-
 /*
  * Guest virtual memory offset of the testing memory slot.
  * Must not conflict with identity mapped test code.
@@ -97,20 +95,18 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus,
                    guest_num_pages, vm_get_max_gfn(vm), vcpus,
                    vcpu_memory_bytes);
 
-       guest_test_phys_mem = (vm_get_max_gfn(vm) - guest_num_pages) *
-                             pta->guest_page_size;
-       guest_test_phys_mem = align_down(guest_test_phys_mem, backing_src_pagesz);
+       pta->gpa = (vm_get_max_gfn(vm) - guest_num_pages) * pta->guest_page_size;
+       pta->gpa = align_down(pta->gpa, backing_src_pagesz);
 #ifdef __s390x__
        /* Align to 1M (segment size) */
-       guest_test_phys_mem = align_down(guest_test_phys_mem, 1 << 20);
+       pta->gpa = align_down(pta->gpa, 1 << 20);
 #endif
-       pr_info("guest physical test memory offset: 0x%lx\n", guest_test_phys_mem);
+       pr_info("guest physical test memory offset: 0x%lx\n", pta->gpa);
 
        /* Add extra memory slots for testing */
        for (i = 0; i < slots; i++) {
                uint64_t region_pages = guest_num_pages / slots;
-               vm_paddr_t region_start = guest_test_phys_mem +
-                       region_pages * pta->guest_page_size * i;
+               vm_paddr_t region_start = pta->gpa + region_pages * pta->guest_page_size * i;
 
                vm_userspace_mem_region_add(vm, backing_src, region_start,
                                            PERF_TEST_MEM_SLOT_INDEX + i,
@@ -118,7 +114,7 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus,
        }
 
        /* Do mapping for the demand paging memory slot */
-       virt_map(vm, guest_test_virt_mem, guest_test_phys_mem, guest_num_pages);
+       virt_map(vm, guest_test_virt_mem, pta->gpa, guest_num_pages);
 
        ucall_init(vm, NULL);
 
@@ -148,13 +144,12 @@ void perf_test_setup_vcpus(struct kvm_vm *vm, int vcpus,
                                         (vcpu_id * vcpu_memory_bytes);
                        vcpu_args->pages = vcpu_memory_bytes /
                                           pta->guest_page_size;
-                       vcpu_args->gpa = guest_test_phys_mem +
-                                        (vcpu_id * vcpu_memory_bytes);
+                       vcpu_args->gpa = pta->gpa + (vcpu_id * vcpu_memory_bytes);
                } else {
                        vcpu_args->gva = guest_test_virt_mem;
                        vcpu_args->pages = (vcpus * vcpu_memory_bytes) /
                                           pta->guest_page_size;
-                       vcpu_args->gpa = guest_test_phys_mem;
+                       vcpu_args->gpa = pta->gpa;
                }
 
                vcpu_args_set(vm, vcpu_id, 1, vcpu_id);
index 4cfcafea9f5a6eb60a3188425697e8c3dcd3c1e5..d105180d5e8c16b31001003d72b100c58cb10752 100644 (file)
@@ -80,7 +80,7 @@ static void add_remove_memslot(struct kvm_vm *vm, useconds_t delay,
         * Add the dummy memslot just below the perf_test_util memslot, which is
         * at the top of the guest physical address space.
         */
-       gpa = guest_test_phys_mem - pages * vm_get_page_size(vm);
+       gpa = perf_test_args.gpa - pages * vm_get_page_size(vm);
 
        for (i = 0; i < nr_modifications; i++) {
                usleep(delay);