From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=50284 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OIgfF-0004pa-WA for qemu-devel@nongnu.org; Sun, 30 May 2010 07:26:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OIgfE-0004xq-Vs for qemu-devel@nongnu.org; Sun, 30 May 2010 07:26:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64340) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OIgfE-0004xK-Om for qemu-devel@nongnu.org; Sun, 30 May 2010 07:26:44 -0400 Date: Sun, 30 May 2010 14:22:20 +0300 From: "Michael S. Tsirkin" Message-ID: <20100530112220.GA27611@redhat.com> References: <4BFF9366.5090103@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4BFF9366.5090103@redhat.com> Subject: [Qemu-devel] Re: [PATCHv2-RFC 0/2] virtio: put last seen used index into ring itself List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jes Sorensen Cc: qemu-devel@nongnu.org, Rusty Russell , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org On Fri, May 28, 2010 at 11:56:54AM +0200, Jes Sorensen wrote: > On 05/26/10 21:50, Michael S. Tsirkin wrote: > > Here's a rewrite of the original patch with a new layout. > > I haven't tested it yet so no idea how this performs, but > > I think this addresses the cache bounce issue raised by Avi. > > Posting for early flames/comments. > > > > Generally, the Host end of the virtio ring doesn't need to see where > > Guest is up to in consuming the ring. However, to completely understand > > what's going on from the outside, this information must be exposed. > > For example, host can reduce the number of interrupts by detecting > > that the guest is currently handling previous buffers. > > > > We add a feature bit so the guest can tell the host that it's writing > > out the current value there, if it wants to use that. > > > > This differs from original approach in that the used index > > is put after avail index (they are typically written out together). > > To avoid cache bounces on descriptor access, > > and make future extensions easier, we put the ring itself at start of > > page, and move the control after it. > > Hi Michael, > > It looks pretty good to me, however one thing I have been thinking of > while reading through it: > > Rather than storing a pointer within the ring struct, pointing into a > position within the same struct. How about storing a byte offset instead > and using a cast to get to the pointer position? That would avoid the > pointer dereference, which is less effective cache wise and harder for > the CPU to predict. > > Not sure whether it really matters performance wise, just a thought. > > Cheers, > Jes I think this won't work: when PUBLUSH_USED_IDX is negotiated, the pointer is to within the ring. -- MST