From patchwork Tue Jun 1 15:12:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 54224 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DF963B7D1E for ; Wed, 2 Jun 2010 01:26:51 +1000 (EST) Received: from localhost ([127.0.0.1]:59932 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJTMb-0000Be-AG for incoming@patchwork.ozlabs.org; Tue, 01 Jun 2010 11:26:45 -0400 Received: from [140.186.70.92] (port=35552 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJTIi-0006mB-Cw for qemu-devel@nongnu.org; Tue, 01 Jun 2010 11:22:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OJTDT-0006o4-RL for qemu-devel@nongnu.org; Tue, 01 Jun 2010 11:17:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14797) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OJTDT-0006nj-IZ for qemu-devel@nongnu.org; Tue, 01 Jun 2010 11:17:19 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o51FHBkY010440 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 1 Jun 2010 11:17:11 -0400 Received: from redhat.com (vpn2-9-97.ams2.redhat.com [10.36.9.97]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o51FH8dp010536; Tue, 1 Jun 2010 11:17:08 -0400 Date: Tue, 1 Jun 2010 18:12:57 +0300 From: "Michael S. Tsirkin" To: Rusty Russell , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, qemu-devel@nongnu.org Message-ID: <20100601151257.GA11704@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] Re: [PATCHv3 0/2] virtio: put last seen used index into ring itself X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Tue, Jun 01, 2010 at 05:47:08PM +0300, Michael S. Tsirkin wrote: > Changes from v2: added padding between avail idx and flags, > and changed virtio to only publish used index when callbacks > are enabled. Here's the updated spec patch. Signed-off-by: Michael S. Tsirkin diff --git a/virtio-spec.lyx b/virtio-spec.lyx index ed35893..a2dcd76 100644 --- a/virtio-spec.lyx +++ b/virtio-spec.lyx @@ -1803,6 +1803,36 @@ next \emph default descriptor entry (modulo the ring size). This starts at 0, and increases. +\change_inserted 0 1274966643 + +\end_layout + +\begin_layout Standard + +\change_inserted 0 1274968378 +When PUBLISH_USED feature flag has +\emph on +not +\emph default + been negotiated, the ring follows the +\begin_inset Quotes eld +\end_inset + +flags +\begin_inset Quotes erd +\end_inset + + and the +\begin_inset Quotes eld +\end_inset + +idx +\begin_inset Quotes erd +\end_inset + + fields: +\change_unchanged + \end_layout \begin_layout Standard @@ -1845,7 +1875,143 @@ struct vring_avail { \end_layout +\begin_layout Standard + +\change_inserted 0 1274968432 +\begin_inset CommandInset label +LatexCommand label +name "PUBLISH_USED-feature" + +\end_inset + +When PUBLISH_USED feature flag has been negotiated, the control structure + including the +\begin_inset Quotes eld +\end_inset + +flags and the +\begin_inset Quotes eld +\end_inset + +idx +\begin_inset Quotes erd +\end_inset + + fields follows the ring. + This leaves the room for the +\begin_inset Quotes eld +\end_inset + +last_seen_used_idx +\begin_inset Quotes erd +\end_inset + + field, which indicates the most recent +\begin_inset Quotes eld +\end_inset + +idx +\begin_inset Quotes erd +\end_inset + + value observed by guest in the used ring (see +\begin_inset CommandInset ref +LatexCommand ref +reference "sub:Used-Ring" + +\end_inset + + below): +\end_layout + +\begin_layout Standard + +\change_inserted 0 1274967396 +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +\change_inserted 0 1274967404 + +struct vring_avail { +\end_layout + +\begin_layout Plain Layout + +\change_inserted 0 1275404889 + + u16 ring[qsz]; /* qsz is the Queue Size field read from device */ +\end_layout + +\begin_layout Plain Layout + +\change_inserted 0 1275404891 + + u16 idx; +\end_layout + +\begin_layout Plain Layout + +\change_inserted 0 1275404921 + + u8 pad[254] /* Padding to avoid sharing cache line between flags and + idx fields. + */ +\end_layout + +\begin_layout Plain Layout + +\change_inserted 0 1274967533 + +#define VRING_AVAIL_F_NO_INTERRUPT 1 +\end_layout + +\begin_layout Plain Layout + +\change_inserted 0 1274967533 + + u16 flags; +\end_layout + +\begin_layout Plain Layout + +\change_inserted 0 1274968345 + + u16 last_seen_used_idx; +\end_layout + +\begin_layout Plain Layout + +\change_inserted 0 1274967396 + +}; +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard + +\change_inserted 0 1274967715 +If the ring is large enough, the second layout maintains the control and + ring structures on separate cache lines. +\end_layout + \begin_layout Subsection + +\change_inserted 0 1274968415 +\begin_inset CommandInset label +LatexCommand label +name "sub:Used-Ring" + +\end_inset + + +\change_unchanged Used Ring \end_layout @@ -2391,12 +2557,20 @@ status open \begin_layout Plain Layout -while (vq->last_seen_used != vring->used.idx) { +while (vq->last_seen_used +\change_inserted 0 1274968316 +_idx +\change_unchanged + != vring->used.idx) { \end_layout \begin_layout Plain Layout - struct vring_used_elem *e = vring.used->ring[vq->last_seen_used%vsz]; + struct vring_used_elem *e = vring.used->ring[vq->last_seen_used +\change_inserted 0 1274968326 +_idx +\change_unchanged +%vsz]; \end_layout \begin_layout Plain Layout @@ -2406,7 +2580,11 @@ while (vq->last_seen_used != vring->used.idx) { \begin_layout Plain Layout - vq->last_seen_used++; + vq->last_seen_used +\change_inserted 0 1274968321 +_idx +\change_unchanged +++; \end_layout \begin_layout Plain Layout @@ -2419,6 +2597,15 @@ while (vq->last_seen_used != vring->used.idx) { \end_layout +\begin_layout Standard + +\change_inserted 0 1275405042 +If PUBLISH_USED feature is negotiated, last_seen_used value should be published + to the device in the avail ring. + This value is used by the host for interrupt mitigation, so it only need + to be updated when interrupts are enabled. +\end_layout + \begin_layout Subsection Dealing With Configuration Changes \end_layout @@ -2986,6 +3173,47 @@ struct vring_avail { \begin_layout Plain Layout }; +\change_inserted 0 1274966477 + +\end_layout + +\begin_layout Plain Layout + +\end_layout + +\begin_layout Plain Layout + +\change_inserted 0 1274966484 + +struct vring_avail_ctrl { +\end_layout + +\begin_layout Plain Layout + +\change_inserted 0 1274966489 + + __u16 flags; +\end_layout + +\begin_layout Plain Layout + +\change_inserted 0 1274966494 + + __u16 idx; +\end_layout + +\begin_layout Plain Layout + +\change_inserted 0 1274966499 + + __u16 last_used_idx; +\end_layout + +\begin_layout Plain Layout + +\change_inserted 0 1274966474 + +}; \end_layout \begin_layout Plain Layout @@ -3349,6 +3577,28 @@ reference "sub:Indirect-Descriptors" \end_inset . +\change_inserted 0 1274967762 + +\end_layout + +\begin_layout Description + +\change_inserted 0 1274967926 +VIRTIO_F_RING_PUBLISH_USED +\begin_inset space ~ +\end_inset + +(29) Negotiating this feature indicates that the avail ring layout includes + the used index observed by driver, see +\begin_inset CommandInset ref +LatexCommand ref +reference "PUBLISH_USED-feature" + +\end_inset + +. +\change_unchanged + \end_layout \begin_layout Description