From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [PATCH kvm-unit-tests v2 5/8] x86/hyperv_stimer: apply on_cpus Date: Tue, 13 Jun 2017 11:21:54 +0200 Message-ID: <20170613092157.32049-6-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]:35994 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752841AbdFMJWH (ORCPT ); Tue, 13 Jun 2017 05:22:07 -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 62DDA1C13C2 for ; Tue, 13 Jun 2017 09:22:07 +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_stimer.c | 41 ++++++++--------------------------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/x86/hyperv_stimer.c b/x86/hyperv_stimer.c index 5292523709ea..a067c5097f88 100644 --- a/x86/hyperv_stimer.c +++ b/x86/hyperv_stimer.c @@ -19,8 +19,6 @@ #define SINT2_NUM 3 #define ONE_MS_IN_100NS 10000 -static atomic_t g_cpus_comp_count; -static int g_cpus_count; static struct spinlock g_synic_alloc_lock; struct stimer { @@ -216,10 +214,6 @@ static void synic_disable(void) synic_free_page(svcpu->msg_page); } -static void cpu_comp(void) -{ - atomic_inc(&g_cpus_comp_count); -} static void stimer_test_prepare(void *ctx) { @@ -229,7 +223,6 @@ static void stimer_test_prepare(void *ctx) synic_enable(); synic_sint_create(vcpu, SINT1_NUM, SINT1_VEC, false); synic_sint_create(vcpu, SINT2_NUM, SINT2_VEC, true); - cpu_comp(); } static void stimer_test_periodic(int vcpu, struct stimer *timer1, @@ -297,7 +290,6 @@ static void stimer_test(void *ctx) stimer_test_auto_enable_periodic(vcpu, timer1); irq_disable(); - cpu_comp(); } static void stimer_test_cleanup(void *ctx) @@ -308,20 +300,6 @@ static void stimer_test_cleanup(void *ctx) synic_sint_destroy(vcpu, SINT1_NUM); synic_sint_destroy(vcpu, SINT2_NUM); synic_disable(); - cpu_comp(); -} - -static void on_each_cpu_async_wait(void (*func)(void *ctx), void *ctx) -{ - int i; - - atomic_set(&g_cpus_comp_count, 0); - for (i = 0; i < g_cpus_count; i++) { - on_cpu_async(i, func, ctx); - } - while (atomic_read(&g_cpus_comp_count) != g_cpus_count) { - pause(); - } } static void stimer_test_all(void) @@ -332,20 +310,17 @@ static void stimer_test_all(void) smp_init(); enable_apic(); - handle_irq(SINT1_VEC, stimer_isr); - handle_irq(SINT2_VEC, stimer_isr_auto_eoi); - ncpus = cpu_count(); - if (ncpus > MAX_CPUS) { - ncpus = MAX_CPUS; - } - + if (ncpus > MAX_CPUS) + report_abort("number cpus exceeds %d", MAX_CPUS); printf("cpus = %d\n", ncpus); - g_cpus_count = ncpus; - on_each_cpu_async_wait(stimer_test_prepare, (void *)read_cr3()); - on_each_cpu_async_wait(stimer_test, NULL); - on_each_cpu_async_wait(stimer_test_cleanup, NULL); + handle_irq(SINT1_VEC, stimer_isr); + handle_irq(SINT2_VEC, stimer_isr_auto_eoi); + + on_cpus(stimer_test_prepare, (void *)read_cr3()); + on_cpus(stimer_test, NULL); + on_cpus(stimer_test_cleanup, NULL); } int main(int ac, char **av) -- 2.9.4