[v4,4/9] vhost: annotate virtqueue access lock

Message ID 20230119184620.3195267-5-david.marchand@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series vhost lock annotations |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

David Marchand Jan. 19, 2023, 6:46 p.m. UTC
  vhost_user_lock/unlock_all_queue_pairs must be waived since clang
annotations can't express taking a runtime number of locks.

vhost_queue_stats_update() requirement can be expressed with a required
tag.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
Changes since RFC v3:
- removed annotations needed for vhost async which went to the next
  patch,

---
 lib/vhost/vhost_user.c | 2 ++
 lib/vhost/virtio_net.c | 4 +---
 2 files changed, 3 insertions(+), 3 deletions(-)
  

Comments

Maxime Coquelin Jan. 31, 2023, 4:50 p.m. UTC | #1
On 1/19/23 19:46, David Marchand wrote:
> vhost_user_lock/unlock_all_queue_pairs must be waived since clang
> annotations can't express taking a runtime number of locks.
> 
> vhost_queue_stats_update() requirement can be expressed with a required
> tag.
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
> Changes since RFC v3:
> - removed annotations needed for vhost async which went to the next
>    patch,
> 
> ---
>   lib/vhost/vhost_user.c | 2 ++
>   lib/vhost/virtio_net.c | 4 +---
>   2 files changed, 3 insertions(+), 3 deletions(-)
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  

Patch

diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
index 3f6c5df900..c57f092975 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -2955,6 +2955,7 @@  vhost_user_check_and_alloc_queue_pair(struct virtio_net *dev,
 
 static void
 vhost_user_lock_all_queue_pairs(struct virtio_net *dev)
+	__rte_no_thread_safety_analysis
 {
 	unsigned int i = 0;
 	unsigned int vq_num = 0;
@@ -2972,6 +2973,7 @@  vhost_user_lock_all_queue_pairs(struct virtio_net *dev)
 
 static void
 vhost_user_unlock_all_queue_pairs(struct virtio_net *dev)
+	__rte_no_thread_safety_analysis
 {
 	unsigned int i = 0;
 	unsigned int vq_num = 0;
diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
index 2a75cda7b6..f05e379316 100644
--- a/lib/vhost/virtio_net.c
+++ b/lib/vhost/virtio_net.c
@@ -52,12 +52,10 @@  is_valid_virt_queue_idx(uint32_t idx, int is_tx, uint32_t nr_vring)
 	return (is_tx ^ (idx & 1)) == 0 && idx < nr_vring;
 }
 
-/*
- * This function must be called with virtqueue's access_lock taken.
- */
 static inline void
 vhost_queue_stats_update(struct virtio_net *dev, struct vhost_virtqueue *vq,
 		struct rte_mbuf **pkts, uint16_t count)
+	__rte_exclusive_locks_required(&vq->access_lock)
 {
 	struct virtqueue_stats *stats = &vq->stats;
 	int i;