> -----Original Message----- > From: David Marchand <david.march...@redhat.com> > Sent: Tuesday, February 7, 2023 6:45 PM > To: dev@dpdk.org > Cc: maxime.coque...@redhat.com; step...@networkplumber.org; Xia, Chenbo > <chenbo....@intel.com>; Hu, Jiayu <jiayu...@intel.com>; Wang, YuanX > <yuanx.w...@intel.com>; Ding, Xuan <xuan.d...@intel.com>; > m...@smartsharesystems.com > Subject: [PATCH v6 6/9] vhost: always take IOTLB lock > > clang does not support conditionally held locks when statically analysing > taken locks with thread safety checks. > Always take iotlb locks regardless of VIRTIO_F_IOMMU_PLATFORM feature. > > Signed-off-by: David Marchand <david.march...@redhat.com> > Acked-by: Morten Brørup <m...@smartsharesystems.com> > Reviewed-by: Maxime Coquelin <maxime.coque...@redhat.com> > --- > lib/vhost/vhost.c | 8 +++----- > lib/vhost/virtio_net.c | 24 ++++++++---------------- > 2 files changed, 11 insertions(+), 21 deletions(-) > > diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c > index 8bccdd8584..1e0c30791e 100644 > --- a/lib/vhost/vhost.c > +++ b/lib/vhost/vhost.c > @@ -563,10 +563,9 @@ vring_translate(struct virtio_net *dev, struct > vhost_virtqueue *vq) > } > > void > -vring_invalidate(struct virtio_net *dev, struct vhost_virtqueue *vq) > +vring_invalidate(struct virtio_net *dev __rte_unused, struct > vhost_virtqueue *vq) > { > - if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) > - vhost_user_iotlb_wr_lock(vq); > + vhost_user_iotlb_wr_lock(vq); > > vq->access_ok = false; > vq->desc = NULL; > @@ -574,8 +573,7 @@ vring_invalidate(struct virtio_net *dev, struct > vhost_virtqueue *vq) > vq->used = NULL; > vq->log_guest_addr = 0; > > - if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) > - vhost_user_iotlb_wr_unlock(vq); > + vhost_user_iotlb_wr_unlock(vq); > } > > static void > diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c > index 6672caac49..49fc46e127 100644 > --- a/lib/vhost/virtio_net.c > +++ b/lib/vhost/virtio_net.c > @@ -1688,8 +1688,7 @@ virtio_dev_rx(struct virtio_net *dev, struct > vhost_virtqueue *vq, > if (unlikely(!vq->enabled)) > goto out_access_unlock; > > - if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) > - vhost_user_iotlb_rd_lock(vq); > + vhost_user_iotlb_rd_lock(vq); > > if (unlikely(!vq->access_ok)) > if (unlikely(vring_translate(dev, vq) < 0)) > @@ -1707,8 +1706,7 @@ virtio_dev_rx(struct virtio_net *dev, struct > vhost_virtqueue *vq, > vhost_queue_stats_update(dev, vq, pkts, nb_tx); > > out: > - if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) > - vhost_user_iotlb_rd_unlock(vq); > + vhost_user_iotlb_rd_unlock(vq); > > out_access_unlock: > rte_spinlock_unlock(&vq->access_lock); > @@ -2499,8 +2497,7 @@ virtio_dev_rx_async_submit(struct virtio_net *dev, > struct vhost_virtqueue *vq, > if (unlikely(!vq->enabled || !vq->async)) > goto out_access_unlock; > > - if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) > - vhost_user_iotlb_rd_lock(vq); > + vhost_user_iotlb_rd_lock(vq); > > if (unlikely(!vq->access_ok)) > if (unlikely(vring_translate(dev, vq) < 0)) > @@ -2520,8 +2517,7 @@ virtio_dev_rx_async_submit(struct virtio_net *dev, > struct vhost_virtqueue *vq, > vq->stats.inflight_submitted += nb_tx; > > out: > - if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) > - vhost_user_iotlb_rd_unlock(vq); > + vhost_user_iotlb_rd_unlock(vq); > > out_access_unlock: > rte_spinlock_unlock(&vq->access_lock); > @@ -3543,8 +3539,7 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id, > goto out_access_unlock; > } > > - if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) > - vhost_user_iotlb_rd_lock(vq); > + vhost_user_iotlb_rd_lock(vq); > > if (unlikely(!vq->access_ok)) > if (unlikely(vring_translate(dev, vq) < 0)) { > @@ -3603,8 +3598,7 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id, > vhost_queue_stats_update(dev, vq, pkts, count); > > out: > - if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) > - vhost_user_iotlb_rd_unlock(vq); > + vhost_user_iotlb_rd_unlock(vq); > > out_access_unlock: > rte_spinlock_unlock(&vq->access_lock); > @@ -4150,8 +4144,7 @@ rte_vhost_async_try_dequeue_burst(int vid, uint16_t > queue_id, > goto out_access_unlock; > } > > - if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) > - vhost_user_iotlb_rd_lock(vq); > + vhost_user_iotlb_rd_lock(vq); > > if (unlikely(vq->access_ok == 0)) > if (unlikely(vring_translate(dev, vq) < 0)) { > @@ -4215,8 +4208,7 @@ rte_vhost_async_try_dequeue_burst(int vid, uint16_t > queue_id, > vhost_queue_stats_update(dev, vq, pkts, count); > > out: > - if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) > - vhost_user_iotlb_rd_unlock(vq); > + vhost_user_iotlb_rd_unlock(vq); > > out_access_unlock: > rte_spinlock_unlock(&vq->access_lock); > -- > 2.39.1
Reviewed-by: Chenbo Xia <chenbo....@intel.com>