vhost: basic in order support
authorJason Wang <jasowang@redhat.com>
Mon, 14 Jul 2025 08:47:54 +0000 (16:47 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 1 Aug 2025 13:11:09 +0000 (09:11 -0400)
commit67a873df0c410915275f735fedb401b9637d6faf
treef7fbd182434e10e7bfc20d7c06e4faa9cf4aed27
parentb4ba1207d45adaafa2982c035898b36af2d3e518
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 <jonah.palmer@oracle.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20250714084755.11921-3-jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Lei Yang <leiyang@redhat.com>
drivers/vhost/net.c
drivers/vhost/vhost.c
drivers/vhost/vhost.h