From: Andrew Jones Subject: [PATCH kvm-unit-tests 7/7] x86/vmexit: apply on_cpus Date: Thu, 1 Jun 2017 17:48:19 +0200 Message-ID: <20170601154819.18831-8-drjones@redhat.com> References: <20170601154819.18831-1-drjones@redhat.com> Cc: pbonzini@redhat.com, rkrcmar@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:51908 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752481AbdFAPsm (ORCPT ); Thu, 1 Jun 2017 11:48:42 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3ACE48047E for ; Thu, 1 Jun 2017 15:48:42 +0000 (UTC) In-Reply-To: <20170601154819.18831-1-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Andrew Jones --- 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