From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753949Ab0EGDYB (ORCPT ); Thu, 6 May 2010 23:24:01 -0400 Received: from ozlabs.org ([203.10.76.45]:51028 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753654Ab0EGDYA (ORCPT ); Thu, 6 May 2010 23:24:00 -0400 From: Rusty Russell To: Avi Kivity Subject: Re: [Qemu-devel] [PATCH RFC] virtio: put last seen used index into =?iso-8859-1?q?ring=09itself?= Date: Fri, 7 May 2010 12:53:52 +0930 User-Agent: KMail/1.13.2 (Linux/2.6.32-21-generic; KDE/4.4.2; i686; ; ) Cc: "Michael S. Tsirkin" , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, qemu-devel@nongnu.org References: <20100505205814.GA7090@redhat.com> <4BE29320.5090506@redhat.com> In-Reply-To: <4BE29320.5090506@redhat.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201005071253.53393.rusty@rustcorp.com.au> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 6 May 2010 07:30:00 pm Avi Kivity wrote: > On 05/05/2010 11:58 PM, Michael S. Tsirkin wrote: > > + /* We publish the last-seen used index at the end of the available ring. > > + * It is at the end for backwards compatibility. */ > > + vr->last_used_idx =&(vr)->avail->ring[num]; > > + /* Verify that last used index does not spill over the used ring. */ > > + BUG_ON((void *)vr->last_used_idx + > > + sizeof *vr->last_used_idx> (void *)vr->used); > > } > > > > Shouldn't this be on its own cache line? It's next to the available ring; because that's where the guest publishes its data. That whole page is guest-write, host-read. Putting it on a cacheline by itself would be a slight pessimization; the host cpu would have to get the last_used_idx cacheline and the avail descriptor cacheline every time. This way, they are sometimes the same cacheline. Hope that clarifies, Rusty. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rusty Russell Subject: Re: [Qemu-devel] [PATCH RFC] virtio: put last seen used index into =?iso-8859-1?q?ring=09itself?= Date: Fri, 7 May 2010 12:53:52 +0930 Message-ID: <201005071253.53393.rusty@rustcorp.com.au> References: <20100505205814.GA7090@redhat.com> <4BE29320.5090506@redhat.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Cc: "Michael S. Tsirkin" , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, qemu-devel@nongnu.org To: Avi Kivity Return-path: In-Reply-To: <4BE29320.5090506@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Thu, 6 May 2010 07:30:00 pm Avi Kivity wrote: > On 05/05/2010 11:58 PM, Michael S. Tsirkin wrote: > > + /* We publish the last-seen used index at the end of the available ring. > > + * It is at the end for backwards compatibility. */ > > + vr->last_used_idx =&(vr)->avail->ring[num]; > > + /* Verify that last used index does not spill over the used ring. */ > > + BUG_ON((void *)vr->last_used_idx + > > + sizeof *vr->last_used_idx> (void *)vr->used); > > } > > > > Shouldn't this be on its own cache line? It's next to the available ring; because that's where the guest publishes its data. That whole page is guest-write, host-read. Putting it on a cacheline by itself would be a slight pessimization; the host cpu would have to get the last_used_idx cacheline and the avail descriptor cacheline every time. This way, they are sometimes the same cacheline. Hope that clarifies, Rusty. From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1OAEAX-0001b9-GL for qemu-devel@nongnu.org; Thu, 06 May 2010 23:24:05 -0400 Received: from [140.186.70.92] (port=54788 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OAEAV-0001XE-Ox for qemu-devel@nongnu.org; Thu, 06 May 2010 23:24:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OAEAU-0000ef-BI for qemu-devel@nongnu.org; Thu, 06 May 2010 23:24:03 -0400 Received: from ozlabs.org ([203.10.76.45]:33821) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OAEAT-0000eJ-Sh for qemu-devel@nongnu.org; Thu, 06 May 2010 23:24:02 -0400 From: Rusty Russell Subject: Re: [Qemu-devel] [PATCH RFC] virtio: put last seen used index into =?iso-8859-1?q?ring=09itself?= Date: Fri, 7 May 2010 12:53:52 +0930 References: <20100505205814.GA7090@redhat.com> <4BE29320.5090506@redhat.com> In-Reply-To: <4BE29320.5090506@redhat.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201005071253.53393.rusty@rustcorp.com.au> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, "Michael S. Tsirkin" On Thu, 6 May 2010 07:30:00 pm Avi Kivity wrote: > On 05/05/2010 11:58 PM, Michael S. Tsirkin wrote: > > + /* We publish the last-seen used index at the end of the available ring. > > + * It is at the end for backwards compatibility. */ > > + vr->last_used_idx =&(vr)->avail->ring[num]; > > + /* Verify that last used index does not spill over the used ring. */ > > + BUG_ON((void *)vr->last_used_idx + > > + sizeof *vr->last_used_idx> (void *)vr->used); > > } > > > > Shouldn't this be on its own cache line? It's next to the available ring; because that's where the guest publishes its data. That whole page is guest-write, host-read. Putting it on a cacheline by itself would be a slight pessimization; the host cpu would have to get the last_used_idx cacheline and the avail descriptor cacheline every time. This way, they are sometimes the same cacheline. Hope that clarifies, Rusty.