Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755506Ab1EDUvn (ORCPT ); Wed, 4 May 2011 16:51:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18002 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754150Ab1EDUvk (ORCPT ); Wed, 4 May 2011 16:51:40 -0400 Date: Wed, 4 May 2011 23:51:01 +0300 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: Rusty Russell , Carsten Otte , Christian Borntraeger , linux390@de.ibm.com, Martin Schwidefsky , Heiko Carstens , Shirley Ma , lguest@lists.ozlabs.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, Krishna Kumar , Tom Lendacky , steved@us.ibm.com, habanero@linux.vnet.ibm.com Subject: [PATCH 04/18] virtio: don't delay avail index update Message-ID: <6306caf796b0ebe38bb9acf9b54d18b1effbfc8f.1304541919.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mutt-Fcc: =sent User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2147 Lines: 64 Update avail index immediately instead of upon kick: for virtio-net RX this helps parallelism with the host. Signed-off-by: Michael S. Tsirkin --- drivers/virtio/virtio_ring.c | 15 +++++---------- 1 files changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 059e02d..507d6eb 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -86,8 +86,6 @@ struct vring_virtqueue unsigned int num_free; /* Head of free buffer list. */ unsigned int free_head; - /* Number we've added since last sync. */ - unsigned int num_added; /* Last used index we've seen. */ u16 last_used_idx; @@ -224,8 +222,12 @@ add_head: /* Put entry in available array (but don't update avail->idx until they * do sync). FIXME: avoid modulus here? */ - avail = (vq->vring.avail->idx + vq->num_added++) % vq->vring.num; + avail = vq->vring.avail->idx % vq->vring.num; vq->vring.avail->ring[avail] = head; + /* Descriptors and available array need to be set before we expose the + * new available array entries. */ + virtio_wmb(); + vq->vring.avail->idx++; pr_debug("Added buffer head %i to %p\n", head, vq); END_USE(vq); @@ -238,12 +240,6 @@ void virtqueue_kick(struct virtqueue *_vq) { struct vring_virtqueue *vq = to_vvq(_vq); START_USE(vq); - /* Descriptors and available array need to be set before we expose the - * new available array entries. */ - virtio_wmb(); - - vq->vring.avail->idx += vq->num_added; - vq->num_added = 0; /* Need to update avail index before checking if we should notify */ virtio_mb(); @@ -430,7 +426,6 @@ struct virtqueue *vring_new_virtqueue(unsigned int num, vq->notify = notify; vq->broken = false; vq->last_used_idx = 0; - vq->num_added = 0; list_add_tail(&vq->vq.list, &vdev->vqs); #ifdef DEBUG vq->in_use = false; -- 1.7.5.53.gc233e -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/