From patchwork Mon Sep 28 11:22:09 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 50433 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 n8SIOIGZ022793 for ; Mon, 28 Sep 2009 18:24:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752441AbZI1SYL (ORCPT ); Mon, 28 Sep 2009 14:24:11 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752394AbZI1SYK (ORCPT ); Mon, 28 Sep 2009 14:24:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43581 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752144AbZI1SYJ (ORCPT ); Mon, 28 Sep 2009 14:24:09 -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 n8SIOCZP024864 for ; Mon, 28 Sep 2009 14:24:13 -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 n8SIOCPr010148; Mon, 28 Sep 2009 14:24:12 -0400 Received: from amt.cnet (vpn-10-27.str.redhat.com [10.32.10.27]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n8SIO9nQ007921; Mon, 28 Sep 2009 14:24:10 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 44DD155800E; Mon, 28 Sep 2009 15:23:38 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id n8SINZWT009857; Mon, 28 Sep 2009 15:23:35 -0300 Message-Id: <20090928112247.375362302@redhat.com> User-Agent: quilt/0.47-1 Date: Mon, 28 Sep 2009 08:22:09 -0300 From: Marcelo Tosatti To: kvm@vger.kernel.org Cc: avi@redhat.com, Marcelo Tosatti Subject: [patch 1/2] test: add wait parameter to on_cpu References: <20090928112208.841396420@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 To determine whether to wait for IPI to finish on remote cpu. Signed-off-by: Marcelo Tosatti --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: qemu-kvm/kvm/user/test/lib/x86/smp.c =================================================================== --- qemu-kvm.orig/kvm/user/test/lib/x86/smp.c +++ qemu-kvm/kvm/user/test/lib/x86/smp.c @@ -82,7 +82,7 @@ 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) +void on_cpu(int cpu, void (*function)(void *data), void *data, int wait) { spin_lock(&ipi_lock); if (cpu == smp_id()) @@ -93,9 +93,11 @@ void on_cpu(int cpu, void (*function)(vo 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) + ; + ipi_done = 0; + } } spin_unlock(&ipi_lock); } @@ -109,6 +111,6 @@ void smp_init(void) setup_smp_id(0); for (i = 1; i < cpu_count(); ++i) - on_cpu(i, setup_smp_id, 0); + on_cpu(i, setup_smp_id, 0, 1); } Index: qemu-kvm/kvm/user/test/lib/x86/smp.h =================================================================== --- qemu-kvm.orig/kvm/user/test/lib/x86/smp.h +++ qemu-kvm/kvm/user/test/lib/x86/smp.h @@ -9,7 +9,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(int cpu, void (*function)(void *data), void *data, int wait); void spin_lock(struct spinlock *lock); void spin_unlock(struct spinlock *lock); Index: qemu-kvm/kvm/user/test/x86/smptest.c =================================================================== --- qemu-kvm.orig/kvm/user/test/x86/smptest.c +++ qemu-kvm/kvm/user/test/x86/smptest.c @@ -20,6 +20,6 @@ int main() ncpus = cpu_count(); printf("found %d cpus\n", ncpus); for (i = 0; i < ncpus; ++i) - on_cpu(i, ipi_test, (void *)(long)i); + on_cpu(i, ipi_test, (void *)(long)i, 1); return 0; } Index: qemu-kvm/kvm/user/test/x86/vmexit.c =================================================================== --- qemu-kvm.orig/kvm/user/test/x86/vmexit.c +++ qemu-kvm/kvm/user/test/x86/vmexit.c @@ -63,14 +63,14 @@ static void nop(void *junk) static void ipi(void) { - on_cpu(1, nop, 0); + on_cpu(1, nop, 0, 1); } static void ipi_halt(void) { unsigned long long t; - on_cpu(1, nop, 0); + on_cpu(1, nop, 0, 1); t = rdtsc() + 2000; while (rdtsc() < t) ;