get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 108933,
    "url": "https://patches.dpdk.org/api/patches/108933/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20220328121758.26632-5-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-5-david.marchand@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20220328121758.26632-5-david.marchand@redhat.com",
    "date": "2022-03-28T12:17:57",
    "name": "[RFC,4/5] vhost: annotate async locking requirement",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "35c05d4c1f8aaef4b56f6034c76f2220352ed9a9",
    "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-5-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/108933/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/108933/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 9054FA0501;\n\tMon, 28 Mar 2022 14:18:56 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id C0A6642889;\n\tMon, 28 Mar 2022 14:18:54 +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 62E894288D\n for <dev@dpdk.org>; Mon, 28 Mar 2022 14:18:53 +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-12-_ZS0dJeTOyCxZaPJWbOosA-1; Mon, 28 Mar 2022 08:18:50 -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 8B32D802819;\n Mon, 28 Mar 2022 12:18:50 +0000 (UTC)",
            "from dmarchan.remote.csb (unknown [10.40.195.27])\n by smtp.corp.redhat.com (Postfix) with ESMTP id AF632C15D40;\n Mon, 28 Mar 2022 12:18:49 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1648469932;\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=/GJD5m8DFNuCwYxoSMk0aT0MiueqxaNs3vkc7BbLlh4=;\n b=Rq8kJtnBFQ4Lrao7h5ZHbbwLs6a41UvPBcgGm8GHCo8HL43hjtJKHfTBayGKkky0rklihG\n vSttMwo7uj+FN2Ex/2N6copdHyRoYadt0uuFACTTCxJTOi5EGjo857TTox7pvwN0qF2huM\n hj5uAm/hT6zP814HZbbWES0ReIpYhBI=",
        "X-MC-Unique": "_ZS0dJeTOyCxZaPJWbOosA-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 4/5] vhost: annotate async locking requirement",
        "Date": "Mon, 28 Mar 2022 14:17:57 +0200",
        "Message-Id": "<20220328121758.26632-5-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": "Instrument that the async field of a virtqueue must be protected by a\nlock.\n\nSigned-off-by: David Marchand <david.marchand@redhat.com>\n---\n lib/vhost/vhost.c      | 14 +++++++++-----\n lib/vhost/vhost.h      |  5 ++++-\n lib/vhost/vhost_user.c |  2 ++\n lib/vhost/virtio_net.c | 14 ++++++++++++++\n 4 files changed, 29 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c\nindex 9e6ca506ff..ea28323367 100644\n--- a/lib/vhost/vhost.c\n+++ b/lib/vhost/vhost.c\n@@ -334,6 +334,7 @@ cleanup_device(struct virtio_net *dev, int destroy)\n \n static void\n vhost_free_async_mem(struct vhost_virtqueue *vq)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tif (!vq->async)\n \t\treturn;\n@@ -352,6 +353,7 @@ vhost_free_async_mem(struct vhost_virtqueue *vq)\n \n void\n free_vq(struct virtio_net *dev, struct vhost_virtqueue *vq)\n+\tVHOST_NO_THREAD_SAFETY_ANALYSIS\n {\n \tif (vq_is_packed(dev))\n \t\trte_free(vq->shadow_used_packed);\n@@ -1622,10 +1624,10 @@ rte_vhost_extern_callback_register(int vid,\n }\n \n static __rte_always_inline int\n-async_channel_register(int vid, uint16_t queue_id)\n+async_channel_register(struct virtio_net *dev, struct vhost_virtqueue *vq,\n+\tuint16_t queue_id)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n-\tstruct virtio_net *dev = get_device(vid);\n-\tstruct vhost_virtqueue *vq = dev->virtqueue[queue_id];\n \tstruct vhost_async *async;\n \tint node = vq->numa_node;\n \n@@ -1709,7 +1711,7 @@ rte_vhost_async_channel_register(int vid, uint16_t queue_id)\n \t\treturn -1;\n \n \tvhost_spinlock_lock(&vq->access_lock);\n-\tret = async_channel_register(vid, queue_id);\n+\tret = async_channel_register(dev, vq, queue_id);\n \tvhost_spinlock_unlock(&vq->access_lock);\n \n \treturn ret;\n@@ -1717,6 +1719,7 @@ rte_vhost_async_channel_register(int vid, uint16_t queue_id)\n \n int\n rte_vhost_async_channel_register_thread_unsafe(int vid, uint16_t queue_id)\n+\tVHOST_NO_THREAD_SAFETY_ANALYSIS\n {\n \tstruct vhost_virtqueue *vq;\n \tstruct virtio_net *dev = get_device(vid);\n@@ -1732,7 +1735,7 @@ rte_vhost_async_channel_register_thread_unsafe(int vid, uint16_t queue_id)\n \tif (unlikely(vq == NULL || !dev->async_copy))\n \t\treturn -1;\n \n-\treturn async_channel_register(vid, queue_id);\n+\treturn async_channel_register(dev, vq, queue_id);\n }\n \n int\n@@ -1777,6 +1780,7 @@ rte_vhost_async_channel_unregister(int vid, uint16_t queue_id)\n \n int\n rte_vhost_async_channel_unregister_thread_unsafe(int vid, uint16_t queue_id)\n+\tVHOST_NO_THREAD_SAFETY_ANALYSIS\n {\n \tstruct vhost_virtqueue *vq;\n \tstruct virtio_net *dev = get_device(vid);\ndiff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h\nindex 619f073fb2..4b301ec152 100644\n--- a/lib/vhost/vhost.h\n+++ b/lib/vhost/vhost.h\n@@ -96,6 +96,8 @@\n \t__attribute__((no_thread_safety_analysis))\n #define VHOST_LOCKABLE \\\n \t__attribute__((lockable))\n+#define VHOST_GUARDED \\\n+\t__attribute__((guarded_var))\n \n #define VHOST_SPINLOCK_REQUIRES(...) \\\n \t__attribute__((exclusive_locks_required(__VA_ARGS__)))\n@@ -109,6 +111,7 @@\n #else\n #define VHOST_NO_THREAD_SAFETY_ANALYSIS\n #define VHOST_LOCKABLE\n+#define VHOST_GUARDED\n \n #define VHOST_SPINLOCK_REQUIRES(...)\n #define VHOST_SPINLOCK_ACQUIRES(...)\n@@ -363,7 +366,7 @@ struct vhost_virtqueue {\n \tstruct rte_vhost_resubmit_info *resubmit_inflight;\n \tuint64_t\t\tglobal_counter;\n \n-\tstruct vhost_async\t*async;\n+\tstruct vhost_async\t*async VHOST_GUARDED;\n \n \tint\t\t\tnotif_enable;\n #define VIRTIO_UNINITIALIZED_NOTIF\t(-1)\ndiff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c\nindex caf4cf14b5..35f1e23995 100644\n--- a/lib/vhost/vhost_user.c\n+++ b/lib/vhost/vhost_user.c\n@@ -2199,6 +2199,8 @@ static int\n vhost_user_set_vring_enable(struct virtio_net **pdev,\n \t\t\tstruct vhu_msg_context *ctx,\n \t\t\tint main_fd __rte_unused)\n+\t/* vq->access_lock is taken in vhost_user_lock_all_queue_pairs() */\n+\tVHOST_NO_THREAD_SAFETY_ANALYSIS\n {\n \tstruct virtio_net *dev = *pdev;\n \tbool enable = !!ctx->msg.payload.state.num;\ndiff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c\nindex 25bdb1479d..9bdba992dd 100644\n--- a/lib/vhost/virtio_net.c\n+++ b/lib/vhost/virtio_net.c\n@@ -51,6 +51,7 @@ static __rte_always_inline int64_t\n vhost_async_dma_transfer_one(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t\tint16_t dma_id, uint16_t vchan_id, uint16_t flag_idx,\n \t\tstruct vhost_iov_iter *pkt)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tstruct async_dma_vchan_info *dma_info = &dma_copy_track[dma_id].vchans[vchan_id];\n \tuint16_t ring_mask = dma_info->ring_mask;\n@@ -99,6 +100,7 @@ static __rte_always_inline uint16_t\n vhost_async_dma_transfer(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t\tint16_t dma_id, uint16_t vchan_id, uint16_t head_idx,\n \t\tstruct vhost_iov_iter *pkts, uint16_t nr_pkts)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tstruct async_dma_vchan_info *dma_info = &dma_copy_track[dma_id].vchans[vchan_id];\n \tint64_t ret, nr_copies = 0;\n@@ -1000,6 +1002,7 @@ static __rte_always_inline int\n async_mbuf_to_desc_seg(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t\tstruct rte_mbuf *m, uint32_t mbuf_offset,\n \t\tuint64_t buf_iova, uint32_t cpy_len)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tstruct vhost_async *async = vq->async;\n \tuint64_t mapped_len;\n@@ -1057,6 +1060,7 @@ static __rte_always_inline int\n mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t\tstruct rte_mbuf *m, struct buf_vector *buf_vec,\n \t\tuint16_t nr_vec, uint16_t num_buffers, bool is_async)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tuint32_t vec_idx = 0;\n \tuint32_t mbuf_offset, mbuf_avail;\n@@ -1186,6 +1190,7 @@ vhost_enqueue_single_packed(struct virtio_net *dev,\n \t\t\t    struct rte_mbuf *pkt,\n \t\t\t    struct buf_vector *buf_vec,\n \t\t\t    uint16_t *nr_descs)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tuint16_t nr_vec = 0;\n \tuint16_t avail_idx = vq->last_avail_idx;\n@@ -1417,6 +1422,7 @@ static __rte_always_inline int16_t\n virtio_dev_rx_single_packed(struct virtio_net *dev,\n \t\t\t    struct vhost_virtqueue *vq,\n \t\t\t    struct rte_mbuf *pkt)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tstruct buf_vector buf_vec[BUF_VECTOR_MAX];\n \tuint16_t nr_descs = 0;\n@@ -1541,6 +1547,7 @@ rte_vhost_enqueue_burst(int vid, uint16_t queue_id,\n \n static __rte_always_inline uint16_t\n async_get_first_inflight_pkt_idx(struct vhost_virtqueue *vq)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tstruct vhost_async *async = vq->async;\n \n@@ -1587,6 +1594,7 @@ static __rte_noinline uint32_t\n virtio_dev_rx_async_submit_split(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t\tuint16_t queue_id, struct rte_mbuf **pkts, uint32_t count,\n \t\tint16_t dma_id, uint16_t vchan_id)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tstruct buf_vector buf_vec[BUF_VECTOR_MAX];\n \tuint32_t pkt_idx = 0;\n@@ -1691,6 +1699,7 @@ vhost_enqueue_async_packed(struct virtio_net *dev,\n \t\t\t    struct buf_vector *buf_vec,\n \t\t\t    uint16_t *nr_descs,\n \t\t\t    uint16_t *nr_buffers)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tuint16_t nr_vec = 0;\n \tuint16_t avail_idx = vq->last_avail_idx;\n@@ -1748,6 +1757,7 @@ vhost_enqueue_async_packed(struct virtio_net *dev,\n static __rte_always_inline int16_t\n virtio_dev_rx_async_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t\t\t    struct rte_mbuf *pkt, uint16_t *nr_descs, uint16_t *nr_buffers)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tstruct buf_vector buf_vec[BUF_VECTOR_MAX];\n \n@@ -1766,6 +1776,7 @@ virtio_dev_rx_async_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,\n static __rte_always_inline void\n dma_error_handler_packed(struct vhost_virtqueue *vq, uint16_t slot_idx,\n \t\t\tuint32_t nr_err, uint32_t *pkt_idx)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tuint16_t descs_err = 0;\n \tuint16_t buffers_err = 0;\n@@ -1793,6 +1804,7 @@ static __rte_noinline uint32_t\n virtio_dev_rx_async_submit_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t\tuint16_t queue_id, struct rte_mbuf **pkts, uint32_t count,\n \t\tint16_t dma_id, uint16_t vchan_id)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tuint32_t pkt_idx = 0;\n \tuint32_t remained = count;\n@@ -1863,6 +1875,7 @@ virtio_dev_rx_async_submit_packed(struct virtio_net *dev, struct vhost_virtqueue\n \n static __rte_always_inline void\n write_back_completed_descs_split(struct vhost_virtqueue *vq, uint16_t n_descs)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tstruct vhost_async *async = vq->async;\n \tuint16_t nr_left = n_descs;\n@@ -1895,6 +1908,7 @@ write_back_completed_descs_split(struct vhost_virtqueue *vq, uint16_t n_descs)\n static __rte_always_inline void\n write_back_completed_descs_packed(struct vhost_virtqueue *vq,\n \t\t\t\tuint16_t n_buffers)\n+\tVHOST_SPINLOCK_REQUIRES(vq->access_lock)\n {\n \tstruct vhost_async *async = vq->async;\n \tuint16_t from = async->last_buffer_idx_packed;\n",
    "prefixes": [
        "RFC",
        "4/5"
    ]
}