get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/108931/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 108931,
    "url": "https://patches.dpdk.org/api/patches/108931/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20220328121758.26632-3-david.marchand@redhat.com/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20220328121758.26632-3-david.marchand@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20220328121758.26632-3-david.marchand@redhat.com",
    "date": "2022-03-28T12:17:55",
    "name": "[RFC,2/5] vhost: annotate virtqueue access lock",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "54e39b98c65c16747de63231c1fa6ac539e70d85",
    "submitter": {
        "id": 1173,
        "url": "https://patches.dpdk.org/api/people/1173/?format=api",
        "name": "David Marchand",
        "email": "david.marchand@redhat.com"
    },
    "delegate": {
        "id": 2642,
        "url": "https://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20220328121758.26632-3-david.marchand@redhat.com/mbox/",
    "series": [
        {
            "id": 22266,
            "url": "https://patches.dpdk.org/api/series/22266/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=22266",
            "date": "2022-03-28T12:17:53",
            "name": "vhost lock annotations",
            "version": 1,
            "mbox": "https://patches.dpdk.org/series/22266/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/108931/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/108931/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id B84E3A0501;\n\tMon, 28 Mar 2022 14:18:31 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id A9FEB42883;\n\tMon, 28 Mar 2022 14:18:31 +0200 (CEST)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by mails.dpdk.org (Postfix) with ESMTP id 077B74286B\n for <dev@dpdk.org>; Mon, 28 Mar 2022 14:18:30 +0200 (CEST)",
            "from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com\n [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n us-mta-482-oBT3UyUfOzWCHzzrD_evkA-1; Mon, 28 Mar 2022 08:18:27 -0400",
            "from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com\n [10.11.54.8])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E63DE85A5A8;\n Mon, 28 Mar 2022 12:18:26 +0000 (UTC)",
            "from dmarchan.remote.csb (unknown [10.40.195.27])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 17D00C15D57;\n Mon, 28 Mar 2022 12:18:25 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1648469910;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=Ao1AX8/uhDpNCScyjHYF3PjMGF/k/0J4FghpD1kXg2Q=;\n b=TzELGkI/Q7vH+sLuSnwhLjVcMarane5KOS4zoNuqKa+vDAyL18eISNhw+1jwXDcJJIzY28\n 3Gnz3FHrUxua/m2w43iU9D6BQx/fLKbXEnlGyJyYgiGAesksauqp59AicLA8qAZZyUEvhq\n xCR6+JaYWmt63UJPZEo5DpR6Do/vgz4=",
        "X-MC-Unique": "oBT3UyUfOzWCHzzrD_evkA-1",
        "From": "David Marchand <david.marchand@redhat.com>",
        "To": "dev@dpdk.org",
        "Cc": "maxime.coquelin@redhat.com,\n\tchenbo.xia@intel.com",
        "Subject": "[RFC PATCH 2/5] vhost: annotate virtqueue access lock",
        "Date": "Mon, 28 Mar 2022 14:17:55 +0200",
        "Message-Id": "<20220328121758.26632-3-david.marchand@redhat.com>",
        "In-Reply-To": "<20220328121758.26632-1-david.marchand@redhat.com>",
        "References": "<20220328121758.26632-1-david.marchand@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 2.85 on 10.11.54.8",
        "Authentication-Results": "relay.mimecast.com;\n auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "Introduce a wrapper around spinlocks and annotate the access_lock lock\nprotecting vq.\n\nOne small change is required in the code: vhost_poll_enqueue_completed\nwas getting a queue_id to get hold of the vq, while its callers already\nknew of the vq. vq is now directly passed.\n\nSigned-off-by: David Marchand <david.marchand@redhat.com>\n---\n lib/vhost/meson.build  |  3 ++\n lib/vhost/vhost.c      | 30 +++++++++---------\n lib/vhost/vhost.h      | 70 ++++++++++++++++++++++++++++++++++++++++--\n lib/vhost/vhost_user.c | 14 +++++----\n lib/vhost/virtio_net.c | 33 ++++++++++++--------\n 5 files changed, 115 insertions(+), 35 deletions(-)",
    "diff": "diff --git a/lib/vhost/meson.build b/lib/vhost/meson.build\nindex bc7272053b..6e0bf9e7e8 100644\n--- a/lib/vhost/meson.build\n+++ b/lib/vhost/meson.build\n@@ -17,6 +17,9 @@ elif (toolchain == 'icc' and cc.version().version_compare('>=16.0.0'))\n endif\n dpdk_conf.set('RTE_LIBRTE_VHOST_POSTCOPY', cc.has_header('linux/userfaultfd.h'))\n cflags += '-fno-strict-aliasing'\n+if cc.has_argument('-Wthread-safety')\n+    cflags += '-Wthread-safety'\n+endif\n sources = files(\n         'fd_man.c',\n         'iotlb.c',\ndiff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c\nindex 2f96a28dac..863cd9131e 100644\n--- a/lib/vhost/vhost.c\n+++ b/lib/vhost/vhost.c\n@@ -622,7 +622,7 @@ alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx)\n \n \t\tdev->virtqueue[i] = vq;\n \t\tinit_vring_queue(dev, i);\n-\t\trte_spinlock_init(&vq->access_lock);\n+\t\tvhost_spinlock_init(&vq->access_lock);\n \t\tvq->avail_wrap_counter = 1;\n \t\tvq->used_wrap_counter = 1;\n \t\tvq->signalled_used_valid = false;\n@@ -1291,14 +1291,14 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx)\n \tif (!vq)\n \t\treturn -1;\n \n-\trte_spinlock_lock(&vq->access_lock);\n+\tvhost_spinlock_lock(&vq->access_lock);\n \n \tif (vq_is_packed(dev))\n \t\tvhost_vring_call_packed(dev, vq);\n \telse\n \t\tvhost_vring_call_split(dev, vq);\n \n-\trte_spinlock_unlock(&vq->access_lock);\n+\tvhost_spinlock_unlock(&vq->access_lock);\n \n \treturn 0;\n }\n@@ -1321,7 +1321,7 @@ rte_vhost_avail_entries(int vid, uint16_t queue_id)\n \tif (!vq)\n \t\treturn 0;\n \n-\trte_spinlock_lock(&vq->access_lock);\n+\tvhost_spinlock_lock(&vq->access_lock);\n \n \tif (unlikely(!vq->enabled || vq->avail == NULL))\n \t\tgoto out;\n@@ -1329,7 +1329,7 @@ rte_vhost_avail_entries(int vid, uint16_t queue_id)\n \tret = *(volatile uint16_t *)&vq->avail->idx - vq->last_used_idx;\n \n out:\n-\trte_spinlock_unlock(&vq->access_lock);\n+\tvhost_spinlock_unlock(&vq->access_lock);\n \treturn ret;\n }\n \n@@ -1413,12 +1413,12 @@ rte_vhost_enable_guest_notification(int vid, uint16_t queue_id, int enable)\n \tif (!vq)\n \t\treturn -1;\n \n-\trte_spinlock_lock(&vq->access_lock);\n+\tvhost_spinlock_lock(&vq->access_lock);\n \n \tvq->notif_enable = enable;\n \tret = vhost_enable_guest_notification(dev, vq, enable);\n \n-\trte_spinlock_unlock(&vq->access_lock);\n+\tvhost_spinlock_unlock(&vq->access_lock);\n \n \treturn ret;\n }\n@@ -1475,7 +1475,7 @@ rte_vhost_rx_queue_count(int vid, uint16_t qid)\n \tif (vq == NULL)\n \t\treturn 0;\n \n-\trte_spinlock_lock(&vq->access_lock);\n+\tvhost_spinlock_lock(&vq->access_lock);\n \n \tif (unlikely(!vq->enabled || vq->avail == NULL))\n \t\tgoto out;\n@@ -1483,7 +1483,7 @@ rte_vhost_rx_queue_count(int vid, uint16_t qid)\n \tret = *((volatile uint16_t *)&vq->avail->idx) - vq->last_avail_idx;\n \n out:\n-\trte_spinlock_unlock(&vq->access_lock);\n+\tvhost_spinlock_unlock(&vq->access_lock);\n \treturn ret;\n }\n \n@@ -1708,9 +1708,9 @@ rte_vhost_async_channel_register(int vid, uint16_t queue_id)\n \tif (unlikely(vq == NULL || !dev->async_copy))\n \t\treturn -1;\n \n-\trte_spinlock_lock(&vq->access_lock);\n+\tvhost_spinlock_lock(&vq->access_lock);\n \tret = async_channel_register(vid, queue_id);\n-\trte_spinlock_unlock(&vq->access_lock);\n+\tvhost_spinlock_unlock(&vq->access_lock);\n \n \treturn ret;\n }\n@@ -1758,7 +1758,7 @@ rte_vhost_async_channel_unregister(int vid, uint16_t queue_id)\n \tif (!vq->async)\n \t\treturn ret;\n \n-\tif (!rte_spinlock_trylock(&vq->access_lock)) {\n+\tif (vhost_spinlock_trylock(&vq->access_lock) == 0) {\n \t\tVHOST_LOG_CONFIG(ERR, \"(%s) failed to unregister async channel, virtqueue busy.\\n\",\n \t\t\t\tdev->ifname);\n \t\treturn -1;\n@@ -1774,7 +1774,7 @@ rte_vhost_async_channel_unregister(int vid, uint16_t queue_id)\n \n \tvhost_free_async_mem(vq);\n out:\n-\trte_spinlock_unlock(&vq->access_lock);\n+\tvhost_spinlock_unlock(&vq->access_lock);\n \n \treturn ret;\n }\n@@ -1894,7 +1894,7 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id)\n \tif (!vq->async)\n \t\treturn ret;\n \n-\tif (!rte_spinlock_trylock(&vq->access_lock)) {\n+\tif (vhost_spinlock_trylock(&vq->access_lock) == 0) {\n \t\tVHOST_LOG_CONFIG(DEBUG,\n \t\t\t\"(%s) failed to check in-flight packets. virtqueue busy.\\n\",\n \t\t\tdev->ifname);\n@@ -1902,7 +1902,7 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id)\n \t}\n \n \tret = vq->async->pkts_inflight_n;\n-\trte_spinlock_unlock(&vq->access_lock);\n+\tvhost_spinlock_unlock(&vq->access_lock);\n \n \treturn ret;\n }\ndiff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h\nindex a9edc271aa..619f073fb2 100644\n--- a/lib/vhost/vhost.h\n+++ b/lib/vhost/vhost.h\n@@ -85,6 +85,71 @@\n \tfor (iter = val; iter < num; iter++)\n #endif\n \n+#ifndef __has_feature\n+#define __vhost_has_feature(x) 0\n+#else\n+#define __vhost_has_feature __has_feature\n+#endif\n+\n+#if __vhost_has_feature(c_thread_safety_attributes)\n+#define VHOST_NO_THREAD_SAFETY_ANALYSIS \\\n+\t__attribute__((no_thread_safety_analysis))\n+#define VHOST_LOCKABLE \\\n+\t__attribute__((lockable))\n+\n+#define VHOST_SPINLOCK_REQUIRES(...) \\\n+\t__attribute__((exclusive_locks_required(__VA_ARGS__)))\n+#define VHOST_SPINLOCK_ACQUIRES(...) \\\n+\t__attribute__((exclusive_lock_function(__VA_ARGS__)))\n+#define VHOST_SPINLOCK_TRYLOCK(ret, ...) \\\n+\t__attribute__((exclusive_trylock_function(ret, __VA_ARGS__)))\n+#define VHOST_SPINLOCK_RELEASES(...) \\\n+\t__attribute__((unlock_function(__VA_ARGS__)))\n+\n+#else\n+#define VHOST_NO_THREAD_SAFETY_ANALYSIS\n+#define VHOST_LOCKABLE\n+\n+#define VHOST_SPINLOCK_REQUIRES(...)\n+#define VHOST_SPINLOCK_ACQUIRES(...)\n+#define VHOST_SPINLOCK_TRYLOCK(...)\n+#define VHOST_SPINLOCK_RELEASES(...)\n+#endif\n+\n+typedef struct VHOST_LOCKABLE {\n+\trte_spinlock_t l;\n+} vhost_spinlock_t;\n+\n+static __rte_always_inline void\n+vhost_spinlock_init(vhost_spinlock_t *l)\n+{\n+\trte_spinlock_init(&l->l);\n+}\n+\n+static __rte_always_inline void\n+vhost_spinlock_lock(vhost_spinlock_t *l)\n+\tVHOST_SPINLOCK_ACQUIRES(l)\n+\tVHOST_NO_THREAD_SAFETY_ANALYSIS\n+{\n+\trte_spinlock_lock(&l->l);\n+}\n+\n+static __rte_always_inline int\n+vhost_spinlock_trylock(vhost_spinlock_t *l)\n+\tVHOST_SPINLOCK_TRYLOCK(1, l)\n+\tVHOST_NO_THREAD_SAFETY_ANALYSIS\n+{\n+\treturn rte_spinlock_trylock(&l->l);\n+}\n+\n+static __rte_always_inline void\n+vhost_spinlock_unlock(vhost_spinlock_t *l)\n+\tVHOST_SPINLOCK_RELEASES(l)\n+\tVHOST_NO_THREAD_SAFETY_ANALYSIS\n+{\n+\trte_spinlock_unlock(&l->l);\n+}\n+\n /**\n  * Structure contains buffer address, length and descriptor index\n  * from vring to do scatter RX.\n@@ -255,8 +320,7 @@ struct vhost_virtqueue {\n \tbool\t\t\taccess_ok;\n \tbool\t\t\tready;\n \n-\trte_spinlock_t\t\taccess_lock;\n-\n+\tvhost_spinlock_t\taccess_lock;\n \n \tunion {\n \t\tstruct vring_used_elem  *shadow_used_split;\n@@ -834,6 +898,7 @@ vhost_need_event(uint16_t event_idx, uint16_t new_idx, uint16_t old)\n \n static __rte_always_inline void\n vhost_vring_call_split(struct virtio_net *dev, struct vhost_virtqueue *vq)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \t/* Flush used->idx update before we read avail->flags. */\n \trte_atomic_thread_fence(__ATOMIC_SEQ_CST);\n@@ -872,6 +937,7 @@ vhost_vring_call_split(struct virtio_net *dev, struct vhost_virtqueue *vq)\n \n static __rte_always_inline void\n vhost_vring_call_packed(struct virtio_net *dev, struct vhost_virtqueue *vq)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tuint16_t old, new, off, off_wrap;\n \tbool signalled_used_valid, kick = false;\ndiff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c\nindex 1d390677fa..caf4cf14b5 100644\n--- a/lib/vhost/vhost_user.c\n+++ b/lib/vhost/vhost_user.c\n@@ -2571,9 +2571,9 @@ vhost_user_iotlb_msg(struct virtio_net **pdev,\n \t\t\t\t\tlen, imsg->perm);\n \n \t\t\tif (is_vring_iotlb(dev, vq, imsg)) {\n-\t\t\t\trte_spinlock_lock(&vq->access_lock);\n+\t\t\t\tvhost_spinlock_lock(&vq->access_lock);\n \t\t\t\t*pdev = dev = translate_ring_addresses(dev, i);\n-\t\t\t\trte_spinlock_unlock(&vq->access_lock);\n+\t\t\t\tvhost_spinlock_unlock(&vq->access_lock);\n \t\t\t}\n \t\t}\n \t\tbreak;\n@@ -2588,9 +2588,9 @@ vhost_user_iotlb_msg(struct virtio_net **pdev,\n \t\t\t\t\timsg->size);\n \n \t\t\tif (is_vring_iotlb(dev, vq, imsg)) {\n-\t\t\t\trte_spinlock_lock(&vq->access_lock);\n+\t\t\t\tvhost_spinlock_lock(&vq->access_lock);\n \t\t\t\tvring_invalidate(dev, vq);\n-\t\t\t\trte_spinlock_unlock(&vq->access_lock);\n+\t\t\t\tvhost_spinlock_unlock(&vq->access_lock);\n \t\t\t}\n \t\t}\n \t\tbreak;\n@@ -2909,6 +2909,7 @@ vhost_user_check_and_alloc_queue_pair(struct virtio_net *dev,\n \n static void\n vhost_user_lock_all_queue_pairs(struct virtio_net *dev)\n+\tVHOST_NO_THREAD_SAFETY_ANALYSIS\n {\n \tunsigned int i = 0;\n \tunsigned int vq_num = 0;\n@@ -2917,7 +2918,7 @@ vhost_user_lock_all_queue_pairs(struct virtio_net *dev)\n \t\tstruct vhost_virtqueue *vq = dev->virtqueue[i];\n \n \t\tif (vq) {\n-\t\t\trte_spinlock_lock(&vq->access_lock);\n+\t\t\tvhost_spinlock_lock(&vq->access_lock);\n \t\t\tvq_num++;\n \t\t}\n \t\ti++;\n@@ -2926,6 +2927,7 @@ vhost_user_lock_all_queue_pairs(struct virtio_net *dev)\n \n static void\n vhost_user_unlock_all_queue_pairs(struct virtio_net *dev)\n+\tVHOST_NO_THREAD_SAFETY_ANALYSIS\n {\n \tunsigned int i = 0;\n \tunsigned int vq_num = 0;\n@@ -2934,7 +2936,7 @@ vhost_user_unlock_all_queue_pairs(struct virtio_net *dev)\n \t\tstruct vhost_virtqueue *vq = dev->virtqueue[i];\n \n \t\tif (vq) {\n-\t\t\trte_spinlock_unlock(&vq->access_lock);\n+\t\t\tvhost_spinlock_unlock(&vq->access_lock);\n \t\t\tvq_num++;\n \t\t}\n \t\ti++;\ndiff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c\nindex 5f432b0d77..25bdb1479d 100644\n--- a/lib/vhost/virtio_net.c\n+++ b/lib/vhost/virtio_net.c\n@@ -1246,6 +1246,7 @@ vhost_enqueue_single_packed(struct virtio_net *dev,\n static __rte_noinline uint32_t\n virtio_dev_rx_split(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \tstruct rte_mbuf **pkts, uint32_t count)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tuint32_t pkt_idx = 0;\n \tuint16_t num_buffers;\n@@ -1441,6 +1442,7 @@ virtio_dev_rx_packed(struct virtio_net *dev,\n \t\t     struct vhost_virtqueue *__rte_restrict vq,\n \t\t     struct rte_mbuf **__rte_restrict pkts,\n \t\t     uint32_t count)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tuint32_t pkt_idx = 0;\n \n@@ -1488,7 +1490,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,\n \n \tvq = dev->virtqueue[queue_id];\n \n-\trte_spinlock_lock(&vq->access_lock);\n+\tvhost_spinlock_lock(&vq->access_lock);\n \n \tif (unlikely(!vq->enabled))\n \t\tgoto out_access_unlock;\n@@ -1514,7 +1516,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,\n \t\tvhost_user_iotlb_rd_unlock(vq);\n \n out_access_unlock:\n-\trte_spinlock_unlock(&vq->access_lock);\n+\tvhost_spinlock_unlock(&vq->access_lock);\n \n \treturn nb_tx;\n }\n@@ -1955,11 +1957,11 @@ write_back_completed_descs_packed(struct vhost_virtqueue *vq,\n }\n \n static __rte_always_inline uint16_t\n-vhost_poll_enqueue_completed(struct virtio_net *dev, uint16_t queue_id,\n+vhost_poll_enqueue_completed(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t\tstruct rte_mbuf **pkts, uint16_t count, int16_t dma_id,\n \t\tuint16_t vchan_id)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n-\tstruct vhost_virtqueue *vq = dev->virtqueue[queue_id];\n \tstruct vhost_async *async = vq->async;\n \tstruct async_inflight_info *pkts_info = async->pkts_info;\n \tuint16_t nr_cpl_pkts = 0;\n@@ -2050,7 +2052,7 @@ rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,\n \n \tvq = dev->virtqueue[queue_id];\n \n-\tif (!rte_spinlock_trylock(&vq->access_lock)) {\n+\tif (vhost_spinlock_trylock(&vq->access_lock) == 0) {\n \t\tVHOST_LOG_DATA(DEBUG, \"(%s) %s: virtqueue %u is busy.\\n\", dev->ifname, __func__,\n \t\t\t\tqueue_id);\n \t\treturn 0;\n@@ -2062,10 +2064,10 @@ rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,\n \t\tgoto out;\n \t}\n \n-\tn_pkts_cpl = vhost_poll_enqueue_completed(dev, queue_id, pkts, count, dma_id, vchan_id);\n+\tn_pkts_cpl = vhost_poll_enqueue_completed(dev, vq, pkts, count, dma_id, vchan_id);\n \n out:\n-\trte_spinlock_unlock(&vq->access_lock);\n+\tvhost_spinlock_unlock(&vq->access_lock);\n \n \treturn n_pkts_cpl;\n }\n@@ -2074,6 +2076,7 @@ uint16_t\n rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id,\n \t\tstruct rte_mbuf **pkts, uint16_t count, int16_t dma_id,\n \t\tuint16_t vchan_id)\n+\tVHOST_NO_THREAD_SAFETY_ANALYSIS\n {\n \tstruct virtio_net *dev = get_device(vid);\n \tstruct vhost_virtqueue *vq;\n@@ -2104,7 +2107,7 @@ rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id,\n \t\treturn 0;\n \t}\n \n-\tn_pkts_cpl = vhost_poll_enqueue_completed(dev, queue_id, pkts, count, dma_id, vchan_id);\n+\tn_pkts_cpl = vhost_poll_enqueue_completed(dev, vq, pkts, count, dma_id, vchan_id);\n \n \treturn n_pkts_cpl;\n }\n@@ -2132,7 +2135,7 @@ virtio_dev_rx_async_submit(struct virtio_net *dev, uint16_t queue_id,\n \n \tvq = dev->virtqueue[queue_id];\n \n-\trte_spinlock_lock(&vq->access_lock);\n+\tvhost_spinlock_lock(&vq->access_lock);\n \n \tif (unlikely(!vq->enabled || !vq->async))\n \t\tgoto out_access_unlock;\n@@ -2160,7 +2163,7 @@ virtio_dev_rx_async_submit(struct virtio_net *dev, uint16_t queue_id,\n \t\tvhost_user_iotlb_rd_unlock(vq);\n \n out_access_unlock:\n-\trte_spinlock_unlock(&vq->access_lock);\n+\tvhost_spinlock_unlock(&vq->access_lock);\n \n \treturn nb_tx;\n }\n@@ -2679,6 +2682,7 @@ static uint16_t\n virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \tstruct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count,\n \tbool legacy_ol_flags)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tuint16_t i;\n \tuint16_t free_entries;\n@@ -2774,6 +2778,7 @@ static uint16_t\n virtio_dev_tx_split_legacy(struct virtio_net *dev,\n \tstruct vhost_virtqueue *vq, struct rte_mempool *mbuf_pool,\n \tstruct rte_mbuf **pkts, uint16_t count)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \treturn virtio_dev_tx_split(dev, vq, mbuf_pool, pkts, count, true);\n }\n@@ -2783,6 +2788,7 @@ static uint16_t\n virtio_dev_tx_split_compliant(struct virtio_net *dev,\n \tstruct vhost_virtqueue *vq, struct rte_mempool *mbuf_pool,\n \tstruct rte_mbuf **pkts, uint16_t count)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \treturn virtio_dev_tx_split(dev, vq, mbuf_pool, pkts, count, false);\n }\n@@ -2982,6 +2988,7 @@ virtio_dev_tx_packed(struct virtio_net *dev,\n \t\t     struct rte_mbuf **__rte_restrict pkts,\n \t\t     uint32_t count,\n \t\t     bool legacy_ol_flags)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tuint32_t pkt_idx = 0;\n \n@@ -3025,6 +3032,7 @@ static uint16_t\n virtio_dev_tx_packed_legacy(struct virtio_net *dev,\n \tstruct vhost_virtqueue *__rte_restrict vq, struct rte_mempool *mbuf_pool,\n \tstruct rte_mbuf **__rte_restrict pkts, uint32_t count)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \treturn virtio_dev_tx_packed(dev, vq, mbuf_pool, pkts, count, true);\n }\n@@ -3034,6 +3042,7 @@ static uint16_t\n virtio_dev_tx_packed_compliant(struct virtio_net *dev,\n \tstruct vhost_virtqueue *__rte_restrict vq, struct rte_mempool *mbuf_pool,\n \tstruct rte_mbuf **__rte_restrict pkts, uint32_t count)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \treturn virtio_dev_tx_packed(dev, vq, mbuf_pool, pkts, count, false);\n }\n@@ -3065,7 +3074,7 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id,\n \n \tvq = dev->virtqueue[queue_id];\n \n-\tif (unlikely(rte_spinlock_trylock(&vq->access_lock) == 0))\n+\tif (unlikely(vhost_spinlock_trylock(&vq->access_lock) == 0))\n \t\treturn 0;\n \n \tif (unlikely(!vq->enabled)) {\n@@ -3134,7 +3143,7 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id,\n \t\tvhost_user_iotlb_rd_unlock(vq);\n \n out_access_unlock:\n-\trte_spinlock_unlock(&vq->access_lock);\n+\tvhost_spinlock_unlock(&vq->access_lock);\n \n \tif (unlikely(rarp_mbuf != NULL))\n \t\tcount += 1;\n",
    "prefixes": [
        "RFC",
        "2/5"
    ]
}