From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [PATCH kvm-unit-tests v2 4/8] x86/hyperv_clock: apply on_cpus Date: Tue, 13 Jun 2017 11:21:53 +0200 Message-ID: <20170613092157.32049-5-drjones@redhat.com> References: <20170613092157.32049-1-drjones@redhat.com> Cc: rkrcmar@redhat.com, pbonzini@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:53882 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752436AbdFMJWG (ORCPT ); Tue, 13 Jun 2017 05:22:06 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E0C747AE99 for ; Tue, 13 Jun 2017 09:22:05 +0000 (UTC) In-Reply-To: <20170613092157.32049-1-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Andrew Jones --- x86/hyperv_clock.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/x86/hyperv_clock.c b/x86/hyperv_clock.c index 6c4dd56f948d..9497269719b6 100644 --- a/x86/hyperv_clock.c +++ b/x86/hyperv_clock.c @@ -55,7 +55,6 @@ uint64_t hv_clock_read(void) return hvclock_tsc_to_ticks(&shadow, rdtsc()); } -atomic_t cpus_left; bool ok[MAX_CPU]; uint64_t loops[MAX_CPU]; @@ -99,7 +98,6 @@ static void hv_clock_test(void *data) if (!got_drift) printf("delta on CPU %d was %d...%d\n", smp_id(), min_delta, max_delta); barrier(); - atomic_dec(&cpus_left); } static void check_test(int ncpus) @@ -107,13 +105,7 @@ static void check_test(int ncpus) int i; bool pass; - atomic_set(&cpus_left, ncpus); - for (i = ncpus - 1; i >= 0; i--) - on_cpu_async(i, hv_clock_test, NULL); - - /* Wait for the end of other vcpu */ - while(atomic_read(&cpus_left)) - ; + on_cpus(hv_clock_test, NULL); pass = true; for (i = ncpus - 1; i >= 0; i--) @@ -134,7 +126,6 @@ static void hv_perf_test(void *data) } while(t < end); loops[smp_id()] = local_loops; - atomic_dec(&cpus_left); } static void perf_test(int ncpus) @@ -142,13 +133,7 @@ static void perf_test(int ncpus) int i; uint64_t total_loops; - atomic_set(&cpus_left, ncpus); - for (i = ncpus - 1; i >= 0; i--) - on_cpu_async(i, hv_perf_test, NULL); - - /* Wait for the end of other vcpu */ - while(atomic_read(&cpus_left)) - ; + on_cpus(hv_perf_test, NULL); total_loops = 0; for (i = ncpus - 1; i >= 0; i--) @@ -167,6 +152,10 @@ int main(int ac, char **av) setup_vm(); smp_init(); + ncpus = cpu_count(); + if (ncpus > MAX_CPU) + report_abort("number cpus exceeds %d", MAX_CPU); + hv_clock = alloc_page(); wrmsr(HV_X64_MSR_REFERENCE_TSC, (u64)(uintptr_t)hv_clock | 1); report("MSR value after enabling", @@ -195,10 +184,6 @@ int main(int ac, char **av) "TSC reference %" PRId64" (delta %" PRId64")\n", ref2, ref2 - ref1, tsc2, t2, t2 - t1); - ncpus = cpu_count(); - if (ncpus > MAX_CPU) - ncpus = MAX_CPU; - check_test(ncpus); perf_test(ncpus); -- 2.9.4