diff options
| author | Jason Wang <[email protected]> | 2025-07-14 08:47:54 +0000 |
|---|---|---|
| committer | Michael S. Tsirkin <[email protected]> | 2025-08-01 13:11:09 +0000 |
| commit | 67a873df0c410915275f735fedb401b9637d6faf (patch) | |
| tree | f7fbd182434e10e7bfc20d7c06e4faa9cf4aed27 /drivers/vhost/net.c | |
| parent | vhost: fail early when __vhost_add_used() fails (diff) | |
| download | kernel-67a873df0c410915275f735fedb401b9637d6faf.tar.gz kernel-67a873df0c410915275f735fedb401b9637d6faf.zip | |
vhost: basic in order support
This patch adds basic in order support for vhost. Two optimizations
are implemented in this patch:
1) Since driver uses descriptor in order, vhost can deduce the next
avail ring head by counting the number of descriptors that has been
used in next_avail_head. This eliminate the need to access the
available ring in vhost.
2) vhost_add_used_and_singal_n() is extended to accept the number of
batched buffers per used elem. While this increases the times of
userspace memory access but it helps to reduce the chance of
used ring access of both the driver and vhost.
Vhost-net will be the first user for this.
Acked-by: Jonah Palmer <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Tested-by: Lei Yang <[email protected]>
Diffstat (limited to 'drivers/vhost/net.c')
| -rw-r--r-- | drivers/vhost/net.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 7cbfc7d718b3..4f9c67f17b49 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -374,7 +374,8 @@ static void vhost_zerocopy_signal_used(struct vhost_net *net, while (j) { add = min(UIO_MAXIOV - nvq->done_idx, j); vhost_add_used_and_signal_n(vq->dev, vq, - &vq->heads[nvq->done_idx], add); + &vq->heads[nvq->done_idx], + NULL, add); nvq->done_idx = (nvq->done_idx + add) % UIO_MAXIOV; j -= add; } @@ -457,7 +458,8 @@ static void vhost_net_signal_used(struct vhost_net_virtqueue *nvq) if (!nvq->done_idx) return; - vhost_add_used_and_signal_n(dev, vq, vq->heads, nvq->done_idx); + vhost_add_used_and_signal_n(dev, vq, vq->heads, NULL, + nvq->done_idx); nvq->done_idx = 0; } |
