vdpa: Send all CVQ state load commands in parallel
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v5 Latest7 patches 0 repliesNew
- v48 patches 12 repliesSuperseded
- v38 patches 21 repliesSuperseded
Changes in v5 from the cover letter
- inline the vhost_svq_available_slots in the caller suggested by Eugenio
- remove redundant assertion and code suggested by Eugenio
- fix conflicts with master branch
- add some comments and refactor a small part of code to improve
its readability
Patches in v5 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/7 | vdpa: Use iovec for vhost_vdpa_net_cvq_add()net/ | +22 | 0 replies | |
| 2/7 | vdpa: Avoid using vhost_vdpa_net_load_*() outside vhost_vdpa_net_load()net/ | +11 | 0 replies | |
| 3/7 | vdpa: Check device ack in vhost_vdpa_net_load_rx_mode()net/ | +31 | 0 replies | |
| 4/7 | vdpa: Move vhost_svq_poll() to the caller of vhost_vdpa_net_cvq_add()net/ | +43 | 0 replies | |
| 5/7 | vdpa: Introduce cursors to vhost_vdpa_net_loadx()net/ | +75 | 0 replies | |
| 6/7 | vhost: Expose vhost_svq_available_slots()hw/ hw/ | +2 | 0 replies | |
| 7/7 | vdpa: Send cvq state load commands in parallelnet/ | +102 | 0 replies |
Reviews trailers per patch
5 of 7 patches have a Reviewed-by or Acked-by.
| Patch | Eugenio Pérez |
|---|---|
| 1/7 | A-b |
| 2/7 | A-b |
| 3/7 | A-b |
| 4/7 | |
| 5/7 | |
| 6/7 | A-b |
| 7/7 | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v5 0/7] vdpa: Send all CVQ state load commands in parallel
This patchset allows QEMU to delay polling and checking the device used buffer until either the SVQ is full or control commands shadow buffers are full, instead of polling and checking immediately after sending each SVQ control command, so that QEMU can send all the SVQ control commands in parallel, which have better performance improvement.
I use vp_vdpa device to simulate vdpa device, and create 4094 VLANS in guest to build a test environment for sending multiple CVQ state load commands. This patch series can improve latency from 20848 us to 13543 us for about 4099 CVQ state load commands, about 1.78 us per command.
ChangeLog
=========
v5:
- inline the vhost_svq_available_slots in the caller suggested by Eugenio
- remove redundant assertion and code suggested by Eugenio
- fix conflicts with master branch
- add some comments and refactor a small part of code to improve
its readability
v4: https://lore.kernel.org/all/[email protected]/#t
- refactor subject line suggested by Eugenio in patch
"vhost: Add count argument to vhost_svq_poll()"
- split in to vdpa_in and model_in instead of reusing in
in vhost_vdpa_net_handle_ctrl_avail() suggested by Eugenio in patch "vdpa: Use iovec for vhost_vdpa_net_cvq_add()"
- pack CVQ command by iov_from_buf() instead of accessingout directly suggested by Eugenio in patch
"vdpa: Avoid using vhost_vdpa_net_load_*() outside vhost_vdpa_net_load()"
- always check the return value of vhost_vdpa_net_svq_poll()
suggested Eugenio in patch
"vdpa: Move vhost_svq_poll() to the caller of vhost_vdpa_net_cvq_add()"
- use struct iovec instead of void ** as cursor,
add vhost_vdpa_net_load_cursor_reset() helper function
to reset the cursors, refactor vhost_vdpa_net_load_cmd() to prepare buffers by iov_copy() instead of accessing in and out directly suggested by Eugenio in patch
"vdpa: Introduce cursors to vhost_vdpa_net_loadx()"
- refactor argument cmds_in_flight to len forvhost_vdpa_net_svq_full(), check the return value of vhost_vdpa_net_svq_poll() in vhost_vdpa_net_svq_flush(),
use iov_size(), vhost_vdpa_net_load_cursor_reset()
and iov_discard_front() to update the cursors instead of accessing it directly according to Eugenio in patch
"vdpa: Send cvq state load commands in parallel"
v3: https://lore.kernel.org/all/[email protected]/
- refactor vhost_svq_poll() to accept cmds_in_flight
suggested by Jason and Eugenio
- refactor vhost_vdpa_net_cvq_add() to make control commands buffers
is not tied to s->cvq_cmd_out_buffer and s->status, so we can reuse it suggested by Eugenio
- poll and check when SVQ is full or control commands shadow buffers is
full
v2: https://lore.kernel.org/all/[email protected]/
- recover accidentally deleted rows
- remove extra newline
- refactor need_poll_len to cmds_in_flight
- return -EINVAL when vhost_svq_poll() return 0 or check
on buffers written by device fails
- change the type of in_cursor, and refactor the
code for updating cursor
- return directly when vhost_vdpa_net_load_{mac,mq}()
returns a failure in vhost_vdpa_net_load()
v1: https://lore.kernel.org/all/[email protected]/
TestStep
========
1. regression testing using vp-vdpa device
- For L0 guest, boot QEMU with two virtio-net-pci net device withctrl_vq, ctrl_rx, ctrl_rx_extra features on, command line like:
-device virtio-net-pci,disable-legacy=on,disable-modern=off,
iommu_platform=on,mq=on,ctrl_vq=on,guest_uso4=off,guest_uso6=off, host_uso=off,guest_announce=off,indirect_desc=off,queue_reset=off, ctrl_rx=on,ctrl_rx_extra=on,...
- For L1 guest, apply the patch series and compile the source code,
start QEMU with two vdpa device with svq mode on, enable the ctrl_vq, ctrl_rx, ctrl_rx_extra features on, command line like:
-netdev type=vhost-vdpa,x-svq=true,...
-device virtio-net-pci,mq=on,guest_announce=off,ctrl_vq=on,ctrl_rx=on,ctrl_rx_extra=on...
- For L2 source guest, run the following bash command:
```bash
#!/bin/sh
for idx1 in {0..9}
do
for idx2 in {0..9}
do
for idx3 in {0..6}
do
ip link add macvlan$idx1$idx2$idx3 link eth0
address 4a:30:10:19:$idx1$idx2:1$idx3 type macvlan mode bridge
ip link set macvlan$idx1$idx2$idx3 up
done
done
done
```- Execute the live migration in L2 source monitor
- Result
* with this series, QEMU should not trigger any error or warning.
2. perf using vp-vdpa device
- For L0 guest, boot QEMU with two virtio-net-pci net device withctrl_vq, ctrl_vlan features on, command line like:
-device virtio-net-pci,disable-legacy=on,disable-modern=off,
iommu_platform=on,mq=on,ctrl_vq=on,guest_uso4=off,guest_uso6=off, host_uso=off,guest_announce=off,indirect_desc=off,queue_reset=off, ctrl_rx=on,ctrl_rx_extra=on,...
- For L1 guest, apply the patch series, then apply an addtional
patch to record the load time in microseconds as following:
```diff
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 6b958d6363..501b510fd2 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -295,7 +295,10 @@ static int vhost_net_start_one(struct vhost_net *net,
}
if (net->nc->info->load) {
+ int64_t start_us = g_get_monotonic_time();
r = net->nc->info->load(net->nc);
+ error_report("vhost_vdpa_net_load() = %ld us",
+ g_get_monotonic_time() - start_us);
if (r < 0) {
goto fail;
}
``` - For L1 guest, compile the code, and start QEMU with two vdpa device
with svq mode on, enable the ctrl_vq, ctrl_vlan features on, command line like:
-netdev type=vhost-vdpa,x-svq=true,...
-device virtio-net-pci,mq=on,guest_announce=off,ctrl_vq=on,ctrl_vlan=on...
- For L2 source guest, run the following bash command:
```bash
#!/bin/sh
for idx in {1..4094}
do
ip link add link eth0 name vlan$idx type vlan id $idx
done
```- execute the live migration in L2 source monitor
- Result
* with this series, QEMU should not trigger any warning
or error except something like "vhost_vdpa_net_load() = 13543 us"
* without this series, QEMU should not trigger any warning
or error except something like "vhost_vdpa_net_load() = 20848 us"
Hawkins Jiawei (7):
vdpa: Use iovec for vhost_vdpa_net_cvq_add()
vdpa: Avoid using vhost_vdpa_net_load_*() outside
vhost_vdpa_net_load()
vdpa: Check device ack in vhost_vdpa_net_load_rx_mode()
vdpa: Move vhost_svq_poll() to the caller of vhost_vdpa_net_cvq_add()
vdpa: Introduce cursors to vhost_vdpa_net_loadx()
vhost: Expose vhost_svq_available_slots()
vdpa: Send cvq state load commands in parallel
hw/virtio/vhost-shadow-virtqueue.c | 2 +- hw/virtio/vhost-shadow-virtqueue.h | 1 + net/vhost-vdpa.c | 374 +++++++++++++++++++---------- 3 files changed, 244 insertions(+), 133 deletions(-)
Signature · 1 line
2.25.1