[PATCH kvm-unit-tests 7/7] x86/vmexit: apply on_cpus

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx>
---
 x86/vmexit.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/x86/vmexit.c b/x86/vmexit.c
index 8d2bf1a31982..7533ef3a3e0a 100644
--- a/x86/vmexit.c
+++ b/x86/vmexit.c
@@ -419,24 +419,20 @@ static struct test tests[] = {
 };
 
 unsigned iterations;
-static atomic_t nr_cpus_done;
+void (*func)(void);
 
-static void run_test(void *_func)
+static void run_test(void)
 {
     int i;
-    void (*func)(void) = _func;
 
     for (i = 0; i < iterations; ++i)
         func();
-
-    atomic_inc(&nr_cpus_done);
 }
 
 static bool do_test(struct test *test)
 {
 	int i;
 	unsigned long long t1, t2;
-        void (*func)(void);
 
         iterations = 32;
 
@@ -463,11 +459,7 @@ static bool do_test(struct test *test)
 			for (i = 0; i < iterations; ++i)
 				func();
 		} else {
-			atomic_set(&nr_cpus_done, 0);
-			for (i = cpu_count(); i > 0; i--)
-				on_cpu_async(i-1, run_test, func);
-			while (atomic_read(&nr_cpus_done) < cpu_count())
-				;
+			on_cpus(run_test);
 		}
 		t2 = rdtsc();
 	} while ((t2 - t1) < GOAL);
@@ -475,7 +467,7 @@ static bool do_test(struct test *test)
 	return test->next;
 }
 
-static void enable_nx(void *junk)
+static void enable_nx(void)
 {
 	if (cpuid(0x80000001).d & (1 << 20))
 		wrmsr(MSR_EFER, rdmsr(MSR_EFER) | EFER_NX_MASK);
@@ -509,8 +501,7 @@ int main(int ac, char **av)
 	nr_cpus = cpu_count();
 
 	irq_enable();
-	for (i = cpu_count(); i > 0; i--)
-		on_cpu(i-1, enable_nx, 0);
+	on_cpus(enable_nx);
 
 	fadt = find_acpi_table_addr(FACP_SIGNATURE);
 	pm_tmr_blk = fadt->pm_tmr_blk;
-- 
2.9.4




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux