All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars Ganrot <lga@napatech.com>
To: "Michael S. Tsirkin" <mst@redhat.com>,
	"virtio@lists.oasis-open.org" <virtio@lists.oasis-open.org>,
	"virtio-dev@lists.oasis-open.org"
	<virtio-dev@lists.oasis-open.org>
Subject: RE: [virtio-dev] [PATCH v10 13/13] split-ring: in order feature
Date: Wed, 28 Mar 2018 08:23:38 +0000	[thread overview]
Message-ID: <ee81d80dd7d4497a97f924be66e17227@napatech.com> (raw)
In-Reply-To: <1520629942-36324-14-git-send-email-mst@redhat.com>

Hi Michael et al

> Behalf Of Michael S. Tsirkin
> Sent: 9. marts 2018 22:24
> 
> For a split ring, require that drivers use descriptors in order too.
> This allows devices to skip reading the available ring.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
[snip]
> 
> +If VIRTIO_F_IN_ORDER has been negotiated, and when making a descriptor
> +with VRING_DESC_F_NEXT set in \field{flags} at offset $x$ in the table
> +available to the device, driver MUST set \field{next} to $0$ for the
> +last descriptor in the table (where $x = queue\_size - 1$) and to $x +
> +1$ for the rest of the descriptors.
> +
>  \subsubsection{Indirect Descriptors}\label{sec:Basic Facilities of a Virtio
> Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
> 
>  Some devices benefit by concurrently dispatching a large number @@ -247,6
> +257,10 @@ chained by \field{next}. An indirect descriptor without a valid
> \field{next}  A single indirect descriptor  table can include both device-
> readable and device-writable descriptors.
> 
> +If VIRTIO_F_IN_ORDER has been negotiated, indirect descriptors use
> +sequential indices, in-order: index 0 followed by index 1 followed by
> +index 2, etc.
> +
>  \drivernormative{\paragraph}{Indirect Descriptors}{Basic Facilities of a Virtio
> Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
> The driver MUST NOT set the VIRTQ_DESC_F_INDIRECT flag unless the
>  VIRTIO_F_INDIRECT_DESC feature was negotiated.   The driver MUST NOT
> @@ -259,6 +273,10 @@ the device.
>  A driver MUST NOT set both VIRTQ_DESC_F_INDIRECT and
> VIRTQ_DESC_F_NEXT  in \field{flags}.
> 
> +If VIRTIO_F_IN_ORDER has been negotiated, indirect descriptors MUST
> +appear sequentially, with \field{next} taking the value of 1 for the
> +1st descriptor, 2 for the 2nd one, etc.
> +
>  \devicenormative{\paragraph}{Indirect Descriptors}{Basic Facilities of a Virtio
> Device / Virtqueues / The Virtqueue Descriptor Table / Indirect Descriptors}
> The device MUST ignore the write-only flag
> (\field{flags}\&VIRTQ_DESC_F_WRITE) in the descriptor that refers to an
> indirect table.
> 

The use of VIRTIO_F_IN_ORDER for split-ring can eliminate some accesses to the virtq_avail.ring and virtq_used.ring. However I'm wondering if the proposed descriptor ordering for multi-element buffers couldn't be tweaked to be more HW friendly.  Currently even with the VIRTIO_F_IN_ORDER negotiated, there is no way of knowing if, or how many chained descriptors follow the descriptor pointed to by the virtq_avail.idx. A chain has to be inspected one descriptor at a time until virtq_desc.flags[VIRTQ_DESC_F_NEXT]=0. This is awkward for HW offload, where you want to DMA all available descriptors in one shot, instead of iterating based on the contents of received DMA data. As currently defined, HW would have to find a compromise between likely chain length, and cost of additional DMA transfers. This leads to a performance penalty for all chained descriptors, and in case the length assumption is wrong the impact can be significant.

Now, what if the VIRTIO_F_IN_ORDER instead required chained buffers to place the last element at the lowest index, and the head-element (to which virtq_avail.idx points) at the highest index? Then all the chained element descriptors would be included in a DMA of the descriptor table from the previous virtq_avail.idx+1 to the current virtq_avail.idx. The "backward" order of the chained descriptors shouldn't pose an issue as such (at least not in HW).

Best Regards,

-Lars

---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


  reply	other threads:[~2018-03-28  8:23 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-09 21:23 [virtio] [PATCH v10 00/13] packed ring layout spec Michael S. Tsirkin
2018-03-09 21:23 ` [virtio] [PATCH v10 01/13] introduction: document bitfield notation Michael S. Tsirkin
2018-03-09 21:23 ` [virtio] [PATCH v10 02/13] content: move 1.0 queue format out to a separate section Michael S. Tsirkin
2018-03-09 21:23 ` [virtio] [PATCH v10 03/13] content: move ring text out to a separate file Michael S. Tsirkin
2018-03-09 21:23 ` [virtio] [PATCH v10 04/13] content: move virtqueue operation description Michael S. Tsirkin
2018-03-09 21:23 ` [virtio] [PATCH v10 05/13] content: len -> used length, used ring -> vq Michael S. Tsirkin
2018-03-09 21:23 ` [virtio] [PATCH v10 07/13] content: generalize rest of text Michael S. Tsirkin
2018-03-09 21:23 ` [virtio] [PATCH v10 06/13] content: generalize transport ring part naming Michael S. Tsirkin
2018-03-09 21:23 ` [virtio] [PATCH v10 08/13] split-ring: generalize text Michael S. Tsirkin
2018-03-09 21:23 ` [virtio] [PATCH v10 10/13] packed virtqueues: more efficient virtqueue layout Michael S. Tsirkin
2018-03-09 21:23 ` [virtio] [PATCH v10 09/13] split-ring: typo: aligment Michael S. Tsirkin
2018-03-09 21:23 ` [virtio] [PATCH v10 11/13] content: in-order buffer use Michael S. Tsirkin
2018-03-09 21:23 ` [virtio] [PATCH v10 12/13] packed-ring: add in order support Michael S. Tsirkin
2018-03-09 21:23 ` [virtio] [PATCH v10 13/13] split-ring: in order feature Michael S. Tsirkin
2018-03-28  8:23   ` Lars Ganrot [this message]
2018-03-28 14:38     ` [virtio] Re: [virtio-dev] " Michael S. Tsirkin
2018-03-28 16:12       ` Lars Ganrot
2018-03-29 14:42         ` [virtio] " Michael S. Tsirkin
2018-03-29 18:23           ` Lars Ganrot
2018-03-29 19:12             ` [virtio] " Michael S. Tsirkin
2018-04-03  7:19               ` Lars Ganrot
2018-04-03 11:47                 ` [virtio] " Michael S. Tsirkin
2018-04-04 15:03                   ` Lars Ganrot
2018-04-04 16:07                     ` [virtio] " Michael S. Tsirkin
2018-04-05  7:18                       ` Lars Ganrot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ee81d80dd7d4497a97f924be66e17227@napatech.com \
    --to=lga@napatech.com \
    --cc=mst@redhat.com \
    --cc=virtio-dev@lists.oasis-open.org \
    --cc=virtio@lists.oasis-open.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.