Skip to content

Commit

Permalink
DPDK: Remove support for vhost-user zero-copy.
Browse files Browse the repository at this point in the history
Support for vhost-user dequeue zero-copy was deprecated in OVS 2.14 with
the aim of removing it for OVS 2.15.

OVS only supports zero copy for vhost client mode, as such it will cease
to function due to DPDK commit [1]

Also DPDK is set to remove zero-copy functionality in DPDK 20.11 as
referenced by commit [2]

As such remove support from OVS.

[1] 715070ea10e6 ("vhost: prevent zero-copy with incompatible client mode")
[2] d21003c9dafa ("doc: announce removal of vhost zero-copy dequeue")

Signed-off-by: Ian Stokes <[email protected]>
Acked-by: Maxime Coquelin <[email protected]>
Acked-by: Ilya Maximets <[email protected]>
Acked-by: Kevin Traynor <[email protected]>
  • Loading branch information
istokes committed Oct 5, 2020
1 parent 80e74da commit 86f624e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 110 deletions.
76 changes: 2 additions & 74 deletions Documentation/topics/dpdk/vhost-user.rst
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,8 @@ The default value is ``false``.
fixes (like userfaulfd leak) was released in 3.0.1.

DPDK Post-copy feature requires avoiding to populate the guest memory
(application must not call mlock* syscall). So enabling mlockall and
dequeue zero-copy features is mis-compatible with post-copy feature.
(application must not call mlock* syscall). So enabling mlockall is
incompatible with post-copy feature.

Note that during migration of vhost-user device, PMD threads hang for the
time of faulted pages download from source host. Transferring 1GB hugepage
Expand Down Expand Up @@ -553,78 +553,6 @@ shown with::

$ ovs-vsctl get Interface dpdkvhostclient0 statistics:ovs_tx_retries

vhost-user Dequeue Zero Copy (experimental)
-------------------------------------------

.. warning::

vhost-user Dequeue Zero Copy is deprecated in OVS and will be removed in
the next release.

Normally when dequeuing a packet from a vHost User device, a memcpy operation
must be used to copy that packet from guest address space to host address
space. This memcpy can be removed by enabling dequeue zero-copy like so::

$ ovs-vsctl add-port br0 dpdkvhostuserclient0 -- set Interface \
dpdkvhostuserclient0 type=dpdkvhostuserclient \
options:vhost-server-path=/tmp/dpdkvhostclient0 \
options:dq-zero-copy=true

With this feature enabled, a reference (pointer) to the packet is passed to
the host, instead of a copy of the packet. Removing this memcpy can give a
performance improvement for some use cases, for example switching large packets
between different VMs. However additional packet loss may be observed.

Note that the feature is disabled by default and must be explicitly enabled
by setting the ``dq-zero-copy`` option to ``true`` while specifying the
``vhost-server-path`` option as above. If you wish to split out the command
into multiple commands as below, ensure ``dq-zero-copy`` is set before
``vhost-server-path``::

$ ovs-vsctl set Interface dpdkvhostuserclient0 options:dq-zero-copy=true
$ ovs-vsctl set Interface dpdkvhostuserclient0 \
options:vhost-server-path=/tmp/dpdkvhostclient0

The feature is only available to ``dpdkvhostuserclient`` port types.

A limitation exists whereby if packets from a vHost port with
``dq-zero-copy=true`` are destined for a ``dpdk`` type port, the number of tx
descriptors (``n_txq_desc``) for that port must be reduced to a smaller number,
128 being the recommended value. This can be achieved by issuing the following
command::

$ ovs-vsctl set Interface dpdkport options:n_txq_desc=128

Note: The sum of the tx descriptors of all ``dpdk`` ports the VM will send to
should not exceed 128. For example, in case of a bond over two physical ports
in balance-tcp mode, one must divide 128 by the number of links in the bond.

Refer to :ref:`dpdk-queues-sizes` for more information.

The reason for this limitation is due to how the zero copy functionality is
implemented. The vHost device's 'tx used vring', a virtio structure used for
tracking used ie. sent descriptors, will only be updated when the NIC frees
the corresponding mbuf. If we don't free the mbufs frequently enough, that
vring will be starved and packets will no longer be processed. One way to
ensure we don't encounter this scenario, is to configure ``n_txq_desc`` to a
small enough number such that the 'mbuf free threshold' for the NIC will be hit
more often and thus free mbufs more frequently. The value of 128 is suggested,
but values of 64 and 256 have been tested and verified to work too, with
differing performance characteristics. A value of 512 can be used too, if the
virtio queue size in the guest is increased to 1024 (available to configure in
QEMU versions v2.10 and greater). This value can be set like so::

$ qemu-system-x86_64 ... -chardev socket,id=char1,path=<sockpath>,server
-netdev type=vhost-user,id=mynet1,chardev=char1,vhostforce
-device virtio-net-pci,mac=00:00:00:00:00:01,netdev=mynet1,
tx_queue_size=1024

Because of this limitation, this feature is considered 'experimental'.

.. note::

Post-copy Live Migration is not compatible with dequeue zero copy.

Further information can be found in the
`DPDK documentation
<https://doc.dpdk.org/guides-19.11/prog_guide/vhost_lib.html>`__
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Post-v2.14.0
- OVSDB:
* New unixctl command 'ovsdb-server/get-db-storage-status' to show the
status of the storage that's backing a database.
- DPDK:
* Removed support for vhost-user dequeue zero-copy.


v2.14.0 - 17 Aug 2020
Expand Down
25 changes: 0 additions & 25 deletions lib/netdev-dpdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2039,12 +2039,6 @@ netdev_dpdk_vhost_client_set_config(struct netdev *netdev,
if (!nullable_string_is_equal(path, dev->vhost_id)) {
free(dev->vhost_id);
dev->vhost_id = nullable_xstrdup(path);
/* check zero copy configuration */
if (smap_get_bool(args, "dq-zero-copy", false)) {
dev->vhost_driver_flags |= RTE_VHOST_USER_DEQUEUE_ZERO_COPY;
} else {
dev->vhost_driver_flags &= ~RTE_VHOST_USER_DEQUEUE_ZERO_COPY;
}
netdev_request_reconfigure(netdev);
}
}
Expand Down Expand Up @@ -5035,7 +5029,6 @@ netdev_dpdk_vhost_client_reconfigure(struct netdev *netdev)
int err;
uint64_t vhost_flags = 0;
uint64_t vhost_unsup_flags;
bool zc_enabled;

ovs_mutex_lock(&dev->mutex);

Expand All @@ -5061,19 +5054,6 @@ netdev_dpdk_vhost_client_reconfigure(struct netdev *netdev)
vhost_flags |= RTE_VHOST_USER_POSTCOPY_SUPPORT;
}

zc_enabled = dev->vhost_driver_flags
& RTE_VHOST_USER_DEQUEUE_ZERO_COPY;
/* Enable zero copy flag, if requested */
if (zc_enabled) {
vhost_flags |= RTE_VHOST_USER_DEQUEUE_ZERO_COPY;
/* DPDK vHost library doesn't allow zero-copy with linear buffers.
* Hence disable Linear buffer.
*/
vhost_flags &= ~RTE_VHOST_USER_LINEARBUF_SUPPORT;
VLOG_WARN("Zero copy enabled, disabling linear buffer"
" check for vHost port %s", dev->up.name);
}

/* Enable External Buffers if TCP Segmentation Offload is enabled. */
if (userspace_tso_enabled()) {
vhost_flags |= RTE_VHOST_USER_EXTBUF_SUPPORT;
Expand All @@ -5090,11 +5070,6 @@ netdev_dpdk_vhost_client_reconfigure(struct netdev *netdev)
VLOG_INFO("vHost User device '%s' created in 'client' mode, "
"using client socket '%s'",
dev->up.name, dev->vhost_id);
if (zc_enabled) {
VLOG_INFO("Zero copy enabled for vHost port %s", dev->up.name);
VLOG_WARN("Zero copy support is deprecated and will be "
"removed in the next OVS release.");
}
}

err = rte_vhost_driver_callback_register(dev->vhost_id,
Expand Down
11 changes: 0 additions & 11 deletions vswitchd/vswitch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3236,17 +3236,6 @@ ovs-vsctl add-port br0 p0 -- set Interface p0 type=patch options:peer=p1 \
</p>
</column>

<column name="options" key="dq-zero-copy"
type='{"type": "boolean"}'>
<p>
The value specifies whether or not to enable dequeue zero copy on
the given interface.
Must be set before vhost-server-path is specified.
Only supported by dpdkvhostuserclient interfaces.
The feature is considered experimental.
</p>
</column>

<column name="options" key="tx-retries-max"
type='{"type": "integer", "minInteger": 0, "maxInteger": 32}'>
<p>
Expand Down

0 comments on commit 86f624e

Please sign in to comment.