qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/6] virtio,vhost: Add VIRTIO_F_IN_ORDER support
@ 2024-06-20 17:56 Jonah Palmer
  2024-06-20 17:56 ` [PATCH v3 1/6] virtio: Add bool to VirtQueueElement Jonah Palmer
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Jonah Palmer @ 2024-06-20 17:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: mst, raphael, kwolf, hreitz, jasowang, pbonzini, fam, eperezma,
	stefanha, qemu-block, schalla, leiyang, virtio-fs, si-wei.liu,
	boris.ostrovsky, jonah.palmer

The goal of these patches is to add support to a variety of virtio and
vhost devices for the VIRTIO_F_IN_ORDER transport feature. This feature
indicates that all buffers are used by the device in the same order in
which they were made available by the driver.

These patches attempt to implement a generalized, non-device-specific
solution to support this feature.

The core feature behind this solution is a buffer mechanism in the form
of a VirtQueue's used_elems VirtQueueElement array. This allows devices
who always use buffers in-order by default to have a minimal overhead
impact. Devices that may not always use buffers in-order likely will
experience a performance hit. How large that performance hit is will
depend on how frequently elements are completed out-of-order.

A VirtQueue whose device uses this feature will use its used_elems
VirtQueueElement array to hold used VirtQueueElements. The index that
used elements are placed in used_elems is the same index on the
used/descriptor ring that would satisfy the in-order requirement. In
other words, used elements are placed in their in-order locations on
used_elems and are only written to the used/descriptor ring once the
elements on used_elems are able to continue their expected order.

To differentiate between a "used" and "unused" element on the used_elems
array (a "used" element being an element that has returned from
processing and an "unused" element being an element that has not yet
been processed), we added a boolean 'in_order_filled' member to the
VirtQueueElement struct. This flag is set to true when the element comes
back from processing (virtqueue_ordered_fill) and then set back to false
once it's been written to the used/descriptor ring
(virtqueue_ordered_flush).

Testing:
========
Testing was done using the dpdk-testpmd application on both the host and
guest using the following configurations. Traffic was generated between
the host and guest after running 'start tx_first' on both the host and
guest dpdk-testpmd applications. Results are below after traffic was
generated for several seconds.

Relevant Qemu args:
-------------------
-chardev socket,id=char1,path=/tmp/vhost-user1,server=off
-chardev socket,id=char2,path=/tmp/vhost-user2,server=off
-netdev type=vhost-user,id=net1,chardev=char1,vhostforce=on,queues=1
-netdev type=vhost-user,id=net2,chardev=char2,vhostforce=on,queues=1
-device virtio-net-pci,in_order=true,packed=true,netdev=net1,
        mac=56:48:4f:53:54:00,mq=on,vectors=4,rx_queue_size=256
-device virtio-net-pci,in_order=true,packed=true,netdev=net2,
        mac=56:48:4f:53:54:01,mq=on,vectors=4,rx_queue_size=256

Host dpdk-testpmd command:
--------------------------
dpdk-testpmd -l 0,2,3,4,5 --socket-mem=1024 -n 4
    --vdev 'net_vhost0,iface=/tmp/vhost-user1'
    --vdev 'net_vhost1,iface=/tmp/vhost-user2' --
    --portmask=f -i --rxq=1 --txq=1 --nb-cores=4 --forward-mode=io

Guest dpdk-testpmd command:
---------------------------
dpdk-testpmd -l 0,1 -a 0000:00:02.0 -a 0000:00:03.0 -- --portmask=3
    --rxq=1 --txq=1 --nb-cores=1 --forward-mode=io -i

Results:
--------
+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++
RX-packets: 79067488       RX-dropped: 0             RX-total: 79067488
TX-packets: 79067552       TX-dropped: 0             TX-total: 79067552
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

---
v3: Drop Tested-by tags until patches are re-tested.
    Replace 'prev_avail_idx' with 'vq->last_avail_idx - 1' in
    virtqueue_split_pop.
    Remove redundant '+vq->vring.num' in 'max_steps' calculation in
    virtqueue_ordered_fill.
    Add test results to CV.

v2: Make 'in_order_filled' more descriptive.
    Change 'j' to more descriptive var name in virtqueue_split_pop.
    Use more definitive search conditional in virtqueue_ordered_fill.
    Avoid code duplication in virtqueue_ordered_flush.

v1: Move series from RFC to PATCH for submission.

Jonah Palmer (6):
  virtio: Add bool to VirtQueueElement
  virtio: virtqueue_pop - VIRTIO_F_IN_ORDER support
  virtio: virtqueue_ordered_fill - VIRTIO_F_IN_ORDER support
  virtio: virtqueue_ordered_flush - VIRTIO_F_IN_ORDER support
  vhost,vhost-user: Add VIRTIO_F_IN_ORDER to vhost feature bits
  virtio: Add VIRTIO_F_IN_ORDER property definition

 hw/block/vhost-user-blk.c    |   1 +
 hw/net/vhost_net.c           |   2 +
 hw/scsi/vhost-scsi.c         |   1 +
 hw/scsi/vhost-user-scsi.c    |   1 +
 hw/virtio/vhost-user-fs.c    |   1 +
 hw/virtio/vhost-user-vsock.c |   1 +
 hw/virtio/virtio.c           | 123 ++++++++++++++++++++++++++++++++++-
 include/hw/virtio/virtio.h   |   6 +-
 net/vhost-vdpa.c             |   1 +
 9 files changed, 134 insertions(+), 3 deletions(-)

-- 
2.43.0



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-06-24 14:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-20 17:56 [PATCH v3 0/6] virtio,vhost: Add VIRTIO_F_IN_ORDER support Jonah Palmer
2024-06-20 17:56 ` [PATCH v3 1/6] virtio: Add bool to VirtQueueElement Jonah Palmer
2024-06-20 17:56 ` [PATCH v3 2/6] virtio: virtqueue_pop - VIRTIO_F_IN_ORDER support Jonah Palmer
2024-06-20 17:56 ` [PATCH v3 3/6] virtio: virtqueue_ordered_fill " Jonah Palmer
2024-06-20 17:56 ` [PATCH v3 4/6] virtio: virtqueue_ordered_flush " Jonah Palmer
2024-06-20 17:56 ` [PATCH v3 5/6] vhost, vhost-user: Add VIRTIO_F_IN_ORDER to vhost feature bits Jonah Palmer via
2024-06-20 17:56 ` [PATCH v3 6/6] virtio: Add VIRTIO_F_IN_ORDER property definition Jonah Palmer
2024-06-20 18:40 ` [PATCH v3 0/6] virtio,vhost: Add VIRTIO_F_IN_ORDER support Eugenio Perez Martin
2024-06-24 14:57   ` Jonah Palmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).