From patchwork Thu Jun 4 18:08:22 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 27989 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 n54IFsnU002204 for ; Thu, 4 Jun 2009 18:15:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753463AbZFDSMv (ORCPT ); Thu, 4 Jun 2009 14:12:51 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753336AbZFDSMv (ORCPT ); Thu, 4 Jun 2009 14:12:51 -0400 Received: from mx2.redhat.com ([66.187.237.31]:50790 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753473AbZFDSMs (ORCPT ); Thu, 4 Jun 2009 14:12:48 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n54ICoQV019369 for ; Thu, 4 Jun 2009 14:12:50 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n54ICn9o002649; Thu, 4 Jun 2009 14:12:50 -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 n54IClof006170; Thu, 4 Jun 2009 14:12:48 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 02032680159; Thu, 4 Jun 2009 15:11:50 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id n54IBnPB014196; Thu, 4 Jun 2009 15:11:49 -0300 Message-Id: <20090604180938.958277548@localhost.localdomain> References: <20090604180820.644455695@localhost.localdomain> User-Agent: quilt/0.46-1 Date: Thu, 04 Jun 2009 15:08:22 -0300 From: Marcelo Tosatti To: avi@redhat.com, kvm@vger.kernel.org Cc: Marcelo Tosatti Subject: [patch 2/4] KVM: move coalesced_mmio locking to its own device Content-Disposition: inline; filename=coalesced-mmio-lock X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Move coalesced_mmio locking to its own device, instead of relying on kvm->lock. Signed-off-by: Marcelo Tosatti Index: kvm/virt/kvm/coalesced_mmio.c =================================================================== --- kvm.orig/virt/kvm/coalesced_mmio.c +++ kvm/virt/kvm/coalesced_mmio.c @@ -31,10 +31,6 @@ static int coalesced_mmio_in_range(struc if (!is_write) return 0; - /* kvm->lock is taken by the caller and must be not released before - * dev.read/write - */ - /* Are we able to batch it ? */ /* last is the first free entry @@ -70,7 +66,7 @@ static void coalesced_mmio_write(struct struct kvm_coalesced_mmio_dev *dev = to_mmio(this); struct kvm_coalesced_mmio_ring *ring = dev->kvm->coalesced_mmio_ring; - /* kvm->lock must be taken by caller before call to in_range()*/ + spin_lock(&dev->lock); /* copy data in first free entry of the ring */ @@ -79,6 +75,7 @@ static void coalesced_mmio_write(struct memcpy(ring->coalesced_mmio[ring->last].data, val, len); smp_wmb(); ring->last = (ring->last + 1) % KVM_COALESCED_MMIO_MAX; + spin_unlock(&dev->lock); } static void coalesced_mmio_destructor(struct kvm_io_device *this) @@ -101,6 +98,7 @@ int kvm_coalesced_mmio_init(struct kvm * dev = kzalloc(sizeof(struct kvm_coalesced_mmio_dev), GFP_KERNEL); if (!dev) return -ENOMEM; + spin_lock_init(&dev->lock); kvm_iodevice_init(&dev->dev, &coalesced_mmio_ops); dev->kvm = kvm; kvm->coalesced_mmio_dev = dev; Index: kvm/virt/kvm/coalesced_mmio.h =================================================================== --- kvm.orig/virt/kvm/coalesced_mmio.h +++ kvm/virt/kvm/coalesced_mmio.h @@ -12,6 +12,7 @@ struct kvm_coalesced_mmio_dev { struct kvm_io_device dev; struct kvm *kvm; + spinlock_t lock; int nb_zones; struct kvm_coalesced_mmio_zone zone[KVM_COALESCED_MMIO_ZONE_MAX]; };