Skip to content

Commit b1d10ee

Browse files
author
Marc Zyngier
committed
Merge branch kvm-arm64/selftest/access-tracking into kvmarm-master/next
* kvm-arm64/selftest/access-tracking: : . : Small series to add support for arm64 to access_tracking_perf_test and : correct a couple bugs along the way. : : Patches courtesy of Oliver Upton. : . KVM: selftests: Build access_tracking_perf_test for arm64 KVM: selftests: Have perf_test_util signal when to stop vCPUs Signed-off-by: Marc Zyngier <[email protected]>
2 parents adde047 + 4568180 commit b1d10ee

File tree

5 files changed

+9
-12
lines changed

5 files changed

+9
-12
lines changed

tools/testing/selftests/kvm/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ TEST_GEN_PROGS_aarch64 += aarch64/psci_test
158158
TEST_GEN_PROGS_aarch64 += aarch64/vcpu_width_config
159159
TEST_GEN_PROGS_aarch64 += aarch64/vgic_init
160160
TEST_GEN_PROGS_aarch64 += aarch64/vgic_irq
161+
TEST_GEN_PROGS_aarch64 += access_tracking_perf_test
161162
TEST_GEN_PROGS_aarch64 += demand_paging_test
162163
TEST_GEN_PROGS_aarch64 += dirty_log_test
163164
TEST_GEN_PROGS_aarch64 += dirty_log_perf_test

tools/testing/selftests/kvm/access_tracking_perf_test.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ static enum {
5858
ITERATION_MARK_IDLE,
5959
} iteration_work;
6060

61-
/* Set to true when vCPU threads should exit. */
62-
static bool done;
63-
6461
/* The iteration that was last completed by each vCPU. */
6562
static int vcpu_last_completed_iteration[KVM_MAX_VCPUS];
6663

@@ -211,7 +208,7 @@ static bool spin_wait_for_next_iteration(int *current_iteration)
211208
int last_iteration = *current_iteration;
212209

213210
do {
214-
if (READ_ONCE(done))
211+
if (READ_ONCE(perf_test_args.stop_vcpus))
215212
return false;
216213

217214
*current_iteration = READ_ONCE(iteration);
@@ -321,9 +318,6 @@ static void run_test(enum vm_guest_mode mode, void *arg)
321318
mark_memory_idle(vm, nr_vcpus);
322319
access_memory(vm, nr_vcpus, ACCESS_READ, "Reading from idle memory");
323320

324-
/* Set done to signal the vCPU threads to exit */
325-
done = true;
326-
327321
perf_test_join_vcpu_threads(nr_vcpus);
328322
perf_test_destroy_vm(vm);
329323
}

tools/testing/selftests/kvm/include/perf_test_util.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ struct perf_test_args {
4040
/* Run vCPUs in L2 instead of L1, if the architecture supports it. */
4141
bool nested;
4242

43+
/* Test is done, stop running vCPUs. */
44+
bool stop_vcpus;
45+
4346
struct perf_test_vcpu_args vcpu_args[KVM_MAX_VCPUS];
4447
};
4548

tools/testing/selftests/kvm/lib/perf_test_util.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ void perf_test_start_vcpu_threads(int nr_vcpus,
267267

268268
vcpu_thread_fn = vcpu_fn;
269269
WRITE_ONCE(all_vcpu_threads_running, false);
270+
WRITE_ONCE(perf_test_args.stop_vcpus, false);
270271

271272
for (i = 0; i < nr_vcpus; i++) {
272273
struct vcpu_thread *vcpu = &vcpu_threads[i];
@@ -289,6 +290,8 @@ void perf_test_join_vcpu_threads(int nr_vcpus)
289290
{
290291
int i;
291292

293+
WRITE_ONCE(perf_test_args.stop_vcpus, true);
294+
292295
for (i = 0; i < nr_vcpus; i++)
293296
pthread_join(vcpu_threads[i].thread, NULL);
294297
}

tools/testing/selftests/kvm/memslot_modification_stress_test.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
static int nr_vcpus = 1;
3535
static uint64_t guest_percpu_mem_size = DEFAULT_PER_VCPU_MEM_SIZE;
3636

37-
static bool run_vcpus = true;
38-
3937
static void vcpu_worker(struct perf_test_vcpu_args *vcpu_args)
4038
{
4139
struct kvm_vcpu *vcpu = vcpu_args->vcpu;
@@ -45,7 +43,7 @@ static void vcpu_worker(struct perf_test_vcpu_args *vcpu_args)
4543
run = vcpu->run;
4644

4745
/* Let the guest access its memory until a stop signal is received */
48-
while (READ_ONCE(run_vcpus)) {
46+
while (!READ_ONCE(perf_test_args.stop_vcpus)) {
4947
ret = _vcpu_run(vcpu);
5048
TEST_ASSERT(ret == 0, "vcpu_run failed: %d\n", ret);
5149

@@ -110,8 +108,6 @@ static void run_test(enum vm_guest_mode mode, void *arg)
110108
add_remove_memslot(vm, p->memslot_modification_delay,
111109
p->nr_memslot_modifications);
112110

113-
run_vcpus = false;
114-
115111
perf_test_join_vcpu_threads(nr_vcpus);
116112
pr_info("All vCPU threads joined\n");
117113

0 commit comments

Comments
 (0)