[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH for 8.0 v8 04/12] vhost: move iova_tree set to vhost_svq_star
From: |
Jason Wang |
Subject: |
Re: [PATCH for 8.0 v8 04/12] vhost: move iova_tree set to vhost_svq_start |
Date: |
Wed, 30 Nov 2022 14:41:31 +0800 |
On Thu, Nov 24, 2022 at 11:52 PM Eugenio Pérez <eperezma@redhat.com> wrote:
>
> Since we don't know if we will use SVQ at qemu initialization, let's
> allocate iova_tree only if needed. To do so, accept it at SVQ start, not
> at initialization.
>
> This will avoid to create it if the device does not support SVQ.
>
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Thanks
> ---
> hw/virtio/vhost-shadow-virtqueue.h | 5 ++---
> hw/virtio/vhost-shadow-virtqueue.c | 9 ++++-----
> hw/virtio/vhost-vdpa.c | 5 ++---
> 3 files changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/hw/virtio/vhost-shadow-virtqueue.h
> b/hw/virtio/vhost-shadow-virtqueue.h
> index d04c34a589..926a4897b1 100644
> --- a/hw/virtio/vhost-shadow-virtqueue.h
> +++ b/hw/virtio/vhost-shadow-virtqueue.h
> @@ -126,11 +126,10 @@ size_t vhost_svq_driver_area_size(const
> VhostShadowVirtqueue *svq);
> size_t vhost_svq_device_area_size(const VhostShadowVirtqueue *svq);
>
> void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev,
> - VirtQueue *vq);
> + VirtQueue *vq, VhostIOVATree *iova_tree);
> void vhost_svq_stop(VhostShadowVirtqueue *svq);
>
> -VhostShadowVirtqueue *vhost_svq_new(VhostIOVATree *iova_tree,
> - const VhostShadowVirtqueueOps *ops,
> +VhostShadowVirtqueue *vhost_svq_new(const VhostShadowVirtqueueOps *ops,
> void *ops_opaque);
>
> void vhost_svq_free(gpointer vq);
> diff --git a/hw/virtio/vhost-shadow-virtqueue.c
> b/hw/virtio/vhost-shadow-virtqueue.c
> index 3b05bab44d..4307296358 100644
> --- a/hw/virtio/vhost-shadow-virtqueue.c
> +++ b/hw/virtio/vhost-shadow-virtqueue.c
> @@ -642,9 +642,10 @@ void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue
> *svq, int svq_kick_fd)
> * @svq: Shadow Virtqueue
> * @vdev: VirtIO device
> * @vq: Virtqueue to shadow
> + * @iova_tree: Tree to perform descriptors translations
> */
> void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev,
> - VirtQueue *vq)
> + VirtQueue *vq, VhostIOVATree *iova_tree)
> {
> size_t desc_size, driver_size, device_size;
>
> @@ -655,6 +656,7 @@ void vhost_svq_start(VhostShadowVirtqueue *svq,
> VirtIODevice *vdev,
> svq->last_used_idx = 0;
> svq->vdev = vdev;
> svq->vq = vq;
> + svq->iova_tree = iova_tree;
>
> svq->vring.num = virtio_queue_get_num(vdev, virtio_get_queue_index(vq));
> driver_size = vhost_svq_driver_area_size(svq);
> @@ -712,18 +714,15 @@ void vhost_svq_stop(VhostShadowVirtqueue *svq)
> * Creates vhost shadow virtqueue, and instructs the vhost device to use the
> * shadow methods and file descriptors.
> *
> - * @iova_tree: Tree to perform descriptors translations
> * @ops: SVQ owner callbacks
> * @ops_opaque: ops opaque pointer
> */
> -VhostShadowVirtqueue *vhost_svq_new(VhostIOVATree *iova_tree,
> - const VhostShadowVirtqueueOps *ops,
> +VhostShadowVirtqueue *vhost_svq_new(const VhostShadowVirtqueueOps *ops,
> void *ops_opaque)
> {
> VhostShadowVirtqueue *svq = g_new0(VhostShadowVirtqueue, 1);
>
> event_notifier_init_fd(&svq->svq_kick, VHOST_FILE_UNBIND);
> - svq->iova_tree = iova_tree;
> svq->ops = ops;
> svq->ops_opaque = ops_opaque;
> return svq;
> diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> index 3df2775760..691bcc811a 100644
> --- a/hw/virtio/vhost-vdpa.c
> +++ b/hw/virtio/vhost-vdpa.c
> @@ -430,8 +430,7 @@ static int vhost_vdpa_init_svq(struct vhost_dev *hdev,
> struct vhost_vdpa *v,
> for (unsigned n = 0; n < hdev->nvqs; ++n) {
> VhostShadowVirtqueue *svq;
>
> - svq = vhost_svq_new(v->iova_tree, v->shadow_vq_ops,
> - v->shadow_vq_ops_opaque);
> + svq = vhost_svq_new(v->shadow_vq_ops, v->shadow_vq_ops_opaque);
> g_ptr_array_add(shadow_vqs, svq);
> }
>
> @@ -1063,7 +1062,7 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *dev)
> goto err;
> }
>
> - vhost_svq_start(svq, dev->vdev, vq);
> + vhost_svq_start(svq, dev->vdev, vq, v->iova_tree);
> ok = vhost_vdpa_svq_map_rings(dev, svq, &addr, &err);
> if (unlikely(!ok)) {
> goto err_map;
> --
> 2.31.1
>
- [PATCH for 8.0 v8 00/12] ASID support in vhost-vdpa net, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 01/12] vdpa: use v->shadow_vqs_enabled in vhost_vdpa_svqs_start & stop, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 02/12] vhost: set SVQ device call handler at SVQ start, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 03/12] vhost: allocate SVQ device file descriptors at device start, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 04/12] vhost: move iova_tree set to vhost_svq_start, Eugenio Pérez, 2022/11/24
- Re: [PATCH for 8.0 v8 04/12] vhost: move iova_tree set to vhost_svq_start,
Jason Wang <=
- [PATCH for 8.0 v8 05/12] vdpa: add vhost_vdpa_net_valid_svq_features, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 06/12] vdpa: extract vhost_vdpa_svq_allocate_iova_tree, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 08/12] vdpa: allocate SVQ array unconditionally, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 07/12] vdpa: move SVQ vring features check to net/, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 10/12] vdpa: store x-svq parameter in VhostVDPAState, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 09/12] vdpa: add asid parameter to vhost_vdpa_dma_map/unmap, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 11/12] vdpa: add shadow_data to vhost_vdpa, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 12/12] vdpa: always start CVQ in SVQ mode if possible, Eugenio Pérez, 2022/11/24