From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [PATCH kvm-unit-tests v2 6/8] x86/hyperv_synic: apply on_cpus Date: Tue, 13 Jun 2017 11:21:55 +0200 Message-ID: <20170613092157.32049-7-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]:5097 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752875AbdFMJWJ (ORCPT ); Tue, 13 Jun 2017 05:22:09 -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 DC1363DBC4 for ; Tue, 13 Jun 2017 09:22:08 +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_synic.c | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/x86/hyperv_synic.c b/x86/hyperv_synic.c index a08e69f7da5f..cf508f16fd5d 100644 --- a/x86/hyperv_synic.c +++ b/x86/hyperv_synic.c @@ -12,7 +12,6 @@ #define MAX_CPUS 4 static atomic_t isr_enter_count[MAX_CPUS]; -static atomic_t cpus_comp_count; static void synic_sint_auto_eoi_isr(isr_regs_t *regs) { @@ -91,7 +90,7 @@ static void synic_test_prepare(void *ctx) r = rdmsr(HV_X64_MSR_EOM); if (r != 0) { report("Hyper-V SynIC test, EOM read %#" PRIx64, false, r); - goto ret; + return; } wrmsr(HV_X64_MSR_SIMP, (u64)virt_to_phys(alloc_page()) | @@ -101,8 +100,6 @@ static void synic_test_prepare(void *ctx) wrmsr(HV_X64_MSR_SCONTROL, HV_SYNIC_CONTROL_ENABLE); synic_sints_prepare(smp_id()); -ret: - atomic_inc(&cpus_comp_count); } static void synic_sints_test(int dst_vcpu) @@ -125,7 +122,6 @@ static void synic_test(void *ctx) irq_enable(); synic_sints_test(dst_vcpu); - atomic_inc(&cpus_comp_count); } static void synic_test_cleanup(void *ctx) @@ -142,7 +138,6 @@ static void synic_test_cleanup(void *ctx) wrmsr(HV_X64_MSR_SCONTROL, 0); wrmsr(HV_X64_MSR_SIMP, 0); wrmsr(HV_X64_MSR_SIEFP, 0); - atomic_inc(&cpus_comp_count); } int main(int ac, char **av) @@ -156,40 +151,25 @@ int main(int ac, char **av) smp_init(); enable_apic(); - synic_prepare_sint_vecs(); - ncpus = cpu_count(); - if (ncpus > MAX_CPUS) { - ncpus = MAX_CPUS; - } + if (ncpus > MAX_CPUS) + report_abort("number cpus exceeds %d", MAX_CPUS); printf("ncpus = %d\n", ncpus); - atomic_set(&cpus_comp_count, 0); - for (i = 0; i < ncpus; i++) { - on_cpu_async(i, synic_test_prepare, (void *)read_cr3()); - } + synic_prepare_sint_vecs(); + printf("prepare\n"); - while (atomic_read(&cpus_comp_count) != ncpus) { - pause(); - } + on_cpus(synic_test_prepare, (void *)read_cr3()); - atomic_set(&cpus_comp_count, 0); for (i = 0; i < ncpus; i++) { printf("test %d -> %d\n", i, ncpus - 1 - i); on_cpu_async(i, synic_test, (void *)(ulong)(ncpus - 1 - i)); } - while (atomic_read(&cpus_comp_count) != ncpus) { + while (cpus_active() > 1) pause(); - } - atomic_set(&cpus_comp_count, 0); - for (i = 0; i < ncpus; i++) { - on_cpu_async(i, synic_test_cleanup, NULL); - } printf("cleanup\n"); - while (atomic_read(&cpus_comp_count) != ncpus) { - pause(); - } + on_cpus(synic_test_cleanup, NULL); ok = true; for (i = 0; i < ncpus; ++i) { -- 2.9.4