KVM: selftests: Enable access_tracking_perf_test for arm64
v2 cover KVM: selftests: Enable access_tracking_perf_test for arm64
Small series to add support for arm64 to access_tracking_perf_test and correct a couple bugs along the way.
Tested on Ampere Altra w/ all supported guest modes.
v1 -> v2:
- Have perf_test_util indicate when to stop vCPU threads (Sean)
- Collect Gavin's R-b on the second patch. I left off Gavin's R-b on the first patch as it was retooled.
v1: https://lore.kernel.org/kvmarm/[email protected]/
Oliver Upton (2):
KVM: selftests: Have perf_test_util signal when to stop vCPUs
KVM: selftests: Build access_tracking_perf_test for arm64
tools/testing/selftests/kvm/Makefile | 1 + tools/testing/selftests/kvm/access_tracking_perf_test.c | 8 +------- tools/testing/selftests/kvm/include/perf_test_util.h | 3 +++ tools/testing/selftests/kvm/lib/perf_test_util.c | 3 +++ .../selftests/kvm/memslot_modification_stress_test.c | 6 +----- 5 files changed, 9 insertions(+), 12 deletions(-)
base-commit: 30a0b95b1335e12efef89dd78518ed3e4a71a763
Signature · 1 line
2.38.1.584.g0f3c55d4c2-goog
PATCH v2 1/2 KVM: selftests: Have perf_test_util signal when to stop vCPUs
Signal that a test run is complete through perf_test_args instead of having tests open code a similar solution. Ensure that the field resets to false at the beginning of a test run as the structure is reused between test runs, eliminating a couple of bugs:
access_tracking_perf_test hangs indefinitely on a subsequent test run, as 'done' remains true. The bug doesn't amount to much right now, as x86 supports a single guest mode. However, this is a precondition of enabling the test for other architectures with >1 guest mode, like arm64.
memslot_modification_stress_test has the exact opposite problem, where subsequent test runs complete immediately as 'run_vcpus' remains false.
--- tools/testing/selftests/kvm/access_tracking_perf_test.c | 8 +------- tools/testing/selftests/kvm/include/perf_test_util.h | 3 +++ tools/testing/selftests/kvm/lib/perf_test_util.c | 3 +++ .../selftests/kvm/memslot_modification_stress_test.c | 6 +----- 4 files changed, 8 insertions(+), 12 deletions(-)
tools/testing/selftests/kvm/access_tracking_perf_test.c +1 -7
@@ -58,9 +58,6 @@ static enum {ITERATION_MARK_IDLE , } iteration_work; -/* Set to true when vCPU threads should exit. */ -static bool done; -/* The iteration that was last completed by each vCPU. */ static int vcpu_last_completed_iteration[KVM_MAX_VCPUS ];
@@ -211,7 +208,7 @@ static bool spin_wait_for_next_iteration(int *current_iteration)int last_iteration = *current_iteration; do { - if (READ_ONCE(done)) + if (READ_ONCE(perf_test_args.stop_vcpus)) return false; *current_iteration = READ_ONCE(iteration);
@@ -321,9 +318,6 @@ static void run_test(enum vm_guest_mode mode, void *arg)mark_memory_idle (vm, nr_vcpus);access_memory (vm, nr_vcpus,ACCESS_READ ,"Reading from idle memory" ); -/* Set done to signal the vCPU threads to exit */ - done = true; -perf_test_join_vcpu_threads (nr_vcpus);perf_test_destroy_vm (vm); }
tools/testing/selftests/kvm/include/perf_test_util.h +3 -0
@@ -40,6 +40,9 @@ struct perf_test_args {/* Run vCPUs in L2 instead of L1, if the architecture supports it. */ bool nested; +/* Test is done, stop running vCPUs. */ +bool stop_vcpus; +struct perf_test_vcpu_args vcpu_args[KVM_MAX_VCPUS ]; };
tools/testing/selftests/kvm/lib/perf_test_util.c +3 -0
@@ -267,6 +267,7 @@ void perf_test_start_vcpu_threads(int nr_vcpus, vcpu_thread_fn = vcpu_fn;WRITE_ONCE (all_vcpu_threads_running, false); +WRITE_ONCE (perf_test_args.stop_vcpus, false);for (i =0 ; i < nr_vcpus; i++) {struct vcpu_thread *vcpu = &vcpu_threads[i];
@@ -289,6 +290,8 @@ void perf_test_join_vcpu_threads(int nr_vcpus) {int i; +WRITE_ONCE (perf_test_args.stop_vcpus, true); +for (i =0 ; i < nr_vcpus; i++)pthread_join (vcpu_threads[i].thread,NULL ); }
tools/testing/selftests/kvm/memslot_modification_stress_test.c +1 -5
@@ -34,8 +34,6 @@static int nr_vcpus =1 ;static uint64_t guest_percpu_mem_size =DEFAULT_PER_VCPU_MEM_SIZE ; -static bool run_vcpus = true; -static void vcpu_worker (struct perf_test_vcpu_args *vcpu_args) {struct kvm_vcpu *vcpu = vcpu_args->vcpu;
@@ -45,7 +43,7 @@ static void vcpu_worker(struct perf_test_vcpu_args *vcpu_args) run = vcpu->run;/* Let the guest access its memory until a stop signal is received */ -while (READ_ONCE (run_vcpus)) { +while (!READ_ONCE (perf_test_args.stop_vcpus)) { ret =_vcpu_run (vcpu);TEST_ASSERT (ret ==0 ,"vcpu_run failed: %d\n" , ret);
@@ -110,8 +108,6 @@ static void run_test(enum vm_guest_mode mode, void *arg)add_remove_memslot (vm, p->memslot_modification_delay, p->nr_memslot_modifications); - run_vcpus = false; -perf_test_join_vcpu_threads (nr_vcpus);pr_info ("All vCPU threads joined\n" );
Signature · 1 line
2.38.1.584.g0f3c55d4c2-goog
PATCH v2 2/2 KVM: selftests: Build access_tracking_perf_test for arm64
In reply to Oliver UptonDoes exactly what it says on the tin.
--- tools/testing/selftests/kvm/Makefile | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/kvm/Makefile +1 -0
@@ -156,6 +156,7 @@ TEST_GEN_PROGS_aarch64 += aarch64/psci_test TEST_GEN_PROGS_aarch64 += aarch64/vcpu_width_config TEST_GEN_PROGS_aarch64 += aarch64/vgic_init TEST_GEN_PROGS_aarch64 += aarch64/vgic_irq +TEST_GEN_PROGS_aarch64 += access_tracking_perf_test TEST_GEN_PROGS_aarch64 += demand_paging_test TEST_GEN_PROGS_aarch64 += dirty_log_test TEST_GEN_PROGS_aarch64 += dirty_log_perf_test
Signature · 1 line
2.38.1.584.g0f3c55d4c2-goog
Re: [PATCH v2 1/2] KVM: selftests: Have perf_test_util signal when to stop vCPUs
In reply to Oliver UptonQuoted 18 lines · Oliver Upton
Signal that a test run is complete through
perf_test_argsinstead of having tests open code a similar solution. Ensure that the field resets to false at the beginning of a test run as the structure is reused between test runs, eliminating a couple of bugs:
access_tracking_perf_testhangs indefinitely on a subsequent test run, as 'done' remains true. The bug doesn't amount to much right now, as x86 supports a single guest mode. However, this is a precondition of enabling the test for other architectures with >1 guest mode, like arm64.
memslot_modification_stress_testhas the exact opposite problem, where subsequent test runs complete immediately as 'run_vcpus' remains false.Co-developed-by Sean Christopherson <[email protected]>Signed-off-by Sean Christopherson <[email protected]>[oliver: added commit message, preserve spin_wait_for_next_iteration()]Signed-off-by Oliver Upton <[email protected]>
Quoted 7 lines
--- tools/testing/selftests/kvm/access_tracking_perf_test.c | 8 +------- tools/testing/selftests/kvm/include/perf_test_util.h | 3 +++ tools/testing/selftests/kvm/lib/perf_test_util.c | 3 +++ .../selftests/kvm/memslot_modification_stress_test.c | 6 +----- 4 files changed, 8 insertions(+), 12 deletions(-)
Quoted 100 lines
tools/testing/selftests/kvm/access_tracking_perf_test.c +1
-7@@ -58,9 +58,6 @@ static enum {ITERATION_MARK_IDLE , } iteration_work; -/* Set to true when vCPU threads should exit. */ -static bool done; -/* The iteration that was last completed by each vCPU. */ static int vcpu_last_completed_iteration[KVM_MAX_VCPUS ];@@ -211,7 +208,7 @@ static bool spin_wait_for_next_iteration(int *current_iteration)int last_iteration = *current_iteration; do { - if (READ_ONCE(done)) + if (READ_ONCE(perf_test_args.stop_vcpus)) return false; *current_iteration = READ_ONCE(iteration);@@ -321,9 +318,6 @@ static void run_test(enum vm_guest_mode mode, void *arg)mark_memory_idle (vm, nr_vcpus);access_memory (vm, nr_vcpus,ACCESS_READ ,"Reading from idle memory" ); -/* Set done to signal the vCPU threads to exit */ - done = true; -perf_test_join_vcpu_threads (nr_vcpus);perf_test_destroy_vm (vm); }tools/testing/selftests/kvm/include/perf_test_util.h +3
-0@@ -40,6 +40,9 @@ struct perf_test_args {/* Run vCPUs in L2 instead of L1, if the architecture supports it. */ bool nested; +/* Test is done, stop running vCPUs. */ +bool stop_vcpus; +struct perf_test_vcpu_args vcpu_args[KVM_MAX_VCPUS ]; };tools/testing/selftests/kvm/lib/perf_test_util.c +3
-0@@ -267,6 +267,7 @@ void perf_test_start_vcpu_threads(int nr_vcpus, vcpu_thread_fn = vcpu_fn;WRITE_ONCE (all_vcpu_threads_running, false); +WRITE_ONCE (perf_test_args.stop_vcpus, false);for (i =0 ; i < nr_vcpus; i++) {struct vcpu_thread *vcpu = &vcpu_threads[i];@@ -289,6 +290,8 @@ void perf_test_join_vcpu_threads(int nr_vcpus) {int i; +WRITE_ONCE (perf_test_args.stop_vcpus, true); +for (i =0 ; i < nr_vcpus; i++)pthread_join (vcpu_threads[i].thread,NULL ); }tools/testing/selftests/kvm/memslot_modification_stress_test.c +1
-5@@ -34,8 +34,6 @@static int nr_vcpus =1 ;static uint64_t guest_percpu_mem_size =DEFAULT_PER_VCPU_MEM_SIZE ; -static bool run_vcpus = true; -static void vcpu_worker (struct perf_test_vcpu_args *vcpu_args) {struct kvm_vcpu *vcpu = vcpu_args->vcpu;@@ -45,7 +43,7 @@ static void vcpu_worker(struct perf_test_vcpu_args *vcpu_args) run = vcpu->run;/* Let the guest access its memory until a stop signal is received */ -while (READ_ONCE (run_vcpus)) { +while (!READ_ONCE (perf_test_args.stop_vcpus)) { ret =_vcpu_run (vcpu);TEST_ASSERT (ret ==0 ,"vcpu_run failed: %d\n" , ret);@@ -110,8 +108,6 @@ static void run_test(enum vm_guest_mode mode, void *arg)add_remove_memslot (vm, p->memslot_modification_delay, p->nr_memslot_modifications); - run_vcpus = false; -perf_test_join_vcpu_threads (nr_vcpus);pr_info ("All vCPU threads joined\n" );
Quoted 11 lines · Oliver Upton
Small series to add support for arm64 to
access_tracking_perf_testand correct a couple bugs along the way.Tested on Ampere Altra w/ all supported guest modes.
v1 -> v2:
- Haveperf_test_utilindicate when to stop vCPU threads (Sean)
- Collect Gavin's R-b on the second patch. I left off Gavin's R-b on the first patch as it was retooled.[...]
Applied to next, thanks!
[1/2] KVM: selftests: Have perf_test_util signal when to stop vCPUs
commit: 9ec1eb1bcceec735fb3c9255cdcdbcc2acf860a0
[2/2] KVM: selftests: Build access_tracking_perf_test for arm64
commit: 4568180411e0fb5613e217da1c693466e39b9c27Cheers,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.