From patchwork Mon Oct 5 13:07:36 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 51800 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n95KFb53024930 for ; Mon, 5 Oct 2009 20:15:38 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754429AbZJEUKV (ORCPT ); Mon, 5 Oct 2009 16:10:21 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754035AbZJEUKT (ORCPT ); Mon, 5 Oct 2009 16:10:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58690 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753811AbZJEUKQ (ORCPT ); Mon, 5 Oct 2009 16:10:16 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n95K9ovx012650 for ; Mon, 5 Oct 2009 16:09:50 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n95K9nBf010371; Mon, 5 Oct 2009 16:09:49 -0400 Received: from amt.cnet (vpn-10-98.str.redhat.com [10.32.10.98]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n95K9lMD020155; Mon, 5 Oct 2009 16:09:48 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 33D7F58806F; Mon, 5 Oct 2009 17:09:40 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id n95K9cmC005716; Mon, 5 Oct 2009 17:09:38 -0300 Message-Id: <20091005130809.415119525@redhat.com> User-Agent: quilt/0.47-1 Date: Mon, 05 Oct 2009 10:07:36 -0300 From: Marcelo Tosatti To: kvm@vger.kernel.org Cc: avi@redhat.com, Marcelo Tosatti Subject: [patch 1/2] test: add on_cpu_async References: <20091005130735.194554408@redhat.com> Content-Disposition: inline; filename=add-wait-to-on-cpu X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Index: qemu-kvm-parallel-vmexit/kvm/user/test/lib/x86/smp.c =================================================================== --- qemu-kvm-parallel-vmexit.orig/kvm/user/test/lib/x86/smp.c +++ qemu-kvm-parallel-vmexit/kvm/user/test/lib/x86/smp.c @@ -82,24 +82,38 @@ static void setup_smp_id(void *data) asm ("mov %0, %%gs:0" : : "r"(apic_id()) : "memory"); } -void on_cpu(int cpu, void (*function)(void *data), void *data) +static void __on_cpu(int cpu, void (*function)(void *data), void *data, + int wait) { spin_lock(&ipi_lock); if (cpu == smp_id()) function(data); else { + ipi_done = 0; ipi_function = function; ipi_data = data; apic_icr_write(APIC_INT_ASSERT | APIC_DEST_PHYSICAL | APIC_DM_FIXED | IPI_VECTOR, cpu); - while (!ipi_done) - ; - ipi_done = 0; + if (wait) { + while (!ipi_done) + ; + } } spin_unlock(&ipi_lock); } +void on_cpu(int cpu, void (*function)(void *data), void *data) +{ + __on_cpu(cpu, function, data, 1); +} + +void on_cpu_async(int cpu, void (*function)(void *data), void *data) +{ + __on_cpu(cpu, function, data, 0); +} + + void smp_init(void) { int i; Index: qemu-kvm-parallel-vmexit/kvm/user/test/lib/x86/smp.h =================================================================== --- qemu-kvm-parallel-vmexit.orig/kvm/user/test/lib/x86/smp.h +++ qemu-kvm-parallel-vmexit/kvm/user/test/lib/x86/smp.h @@ -10,6 +10,7 @@ void smp_init(void); int cpu_count(void); int smp_id(void); void on_cpu(int cpu, void (*function)(void *data), void *data); +void on_cpu_async(int cpu, void (*function)(void *data), void *data); void spin_lock(struct spinlock *lock); void spin_unlock(struct spinlock *lock);