get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 125528,
    "url": "https://patches.dpdk.org/api/patches/125528/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/167992139724.45323.17979512439014217881.stgit@ebuild.local/",
    "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": "<167992139724.45323.17979512439014217881.stgit@ebuild.local>",
    "list_archive_url": "https://inbox.dpdk.org/dev/167992139724.45323.17979512439014217881.stgit@ebuild.local",
    "date": "2023-03-27T12:51:17",
    "name": "vhost: add device op to offload the interrupt kick",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "b80e0113e392af0bf21ba9a42a15ccb8d5670696",
    "submitter": {
        "id": 672,
        "url": "https://patches.dpdk.org/api/people/672/?format=api",
        "name": "Eelco Chaudron",
        "email": "echaudro@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/167992139724.45323.17979512439014217881.stgit@ebuild.local/mbox/",
    "series": [
        {
            "id": 27551,
            "url": "https://patches.dpdk.org/api/series/27551/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=27551",
            "date": "2023-03-27T12:51:17",
            "name": "vhost: add device op to offload the interrupt kick",
            "version": 1,
            "mbox": "https://patches.dpdk.org/series/27551/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/125528/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/125528/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 0AB3B42808;\n\tMon, 27 Mar 2023 14:51:33 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 9687840EE1;\n\tMon, 27 Mar 2023 14:51:32 +0200 (CEST)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by mails.dpdk.org (Postfix) with ESMTP id 4E7B740ED8\n for <dev@dpdk.org>; Mon, 27 Mar 2023 14:51:31 +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-513-ZK_n3LEDMniXeuxd46NMiw-1; Mon, 27 Mar 2023 08:51:29 -0400",
            "from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com\n [10.11.54.10])\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 D1454858F0E;\n Mon, 27 Mar 2023 12:51:28 +0000 (UTC)",
            "from localhost.localdomain (unknown [10.39.193.129])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 32D2A492C3E;\n Mon, 27 Mar 2023 12:51:28 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1679921490;\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 bh=9IXJ5BZtaHXm+OW5xtmEcDnfG+AF8cA18y+/Rhwm0/k=;\n b=Rlf62dDgNtuvamkxYaIJsiPFRbXRxqKwNBSlxfDU3ZBzZGt3EfTFITDmvtFc6vOB4n25oB\n GCQr+4/XTNbmqOF2V1/NsSa2O8X38FomoBzObiKKf1U2TeosZrFbH6CEgFxba1CFK2SUOv\n 9uKqOtKj3N8RcieCavPGNMdmn3Y7sek=",
        "X-MC-Unique": "ZK_n3LEDMniXeuxd46NMiw-1",
        "From": "Eelco Chaudron <echaudro@redhat.com>",
        "To": "maxime.coquelin@redhat.com,\n\tchenbo.xia@intel.com",
        "Cc": "dev@dpdk.org",
        "Subject": "[PATCH] vhost: add device op to offload the interrupt kick",
        "Date": "Mon, 27 Mar 2023 14:51:17 +0200",
        "Message-Id": "<167992139724.45323.17979512439014217881.stgit@ebuild.local>",
        "User-Agent": "StGit/1.5",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.1 on 10.11.54.10",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "8bit",
        "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": "This patch adds an operation callback which gets called every time the\nlibrary wants to call eventfd_write(). This eventfd_write() call could\nresult in a system call, which could potentially block the PMD thread.\n\nThe callback function can decide whether it's ok to handle the\neventfd_write() now or have the newly introduced function,\nrte_vhost_notify_guest(), called at a later time.\n\nThis can be used by 3rd party applications, like OVS, to avoid system\ncalls being called as part of the PMD threads.\n\nSigned-off-by: Eelco Chaudron <echaudro@redhat.com>\n---\n lib/vhost/rte_vhost.h |   10 +++++++++-\n lib/vhost/vhost.c     |   21 +++++++++++++++++++++\n lib/vhost/vhost.h     |   43 ++++++++++++++++++++++++++++---------------\n 3 files changed, 58 insertions(+), 16 deletions(-)",
    "diff": "diff --git a/lib/vhost/rte_vhost.h b/lib/vhost/rte_vhost.h\nindex 58a5d4be92..af7a394d0f 100644\n--- a/lib/vhost/rte_vhost.h\n+++ b/lib/vhost/rte_vhost.h\n@@ -298,7 +298,13 @@ struct rte_vhost_device_ops {\n \t */\n \tvoid (*guest_notified)(int vid);\n \n-\tvoid *reserved[1]; /**< Reserved for future extension */\n+\t/**\n+\t * If this callback is registered, notification to the guest can\n+\t * be handled by the front-end calling rte_vhost_notify_guest().\n+\t * If it's not handled, 'false' should be returned. This can be used\n+\t * to remove the \"slow\" eventfd_write() syscall from the datapath.\n+\t */\n+\tbool (*guest_notify)(int vid, uint16_t queue_id);\n };\n \n /**\n@@ -433,6 +439,8 @@ void rte_vhost_log_used_vring(int vid, uint16_t vring_idx,\n \n int rte_vhost_enable_guest_notification(int vid, uint16_t queue_id, int enable);\n \n+void rte_vhost_notify_guest(int vid, uint16_t queue_id);\n+\n /**\n  * Register vhost driver. path could be different for multiple\n  * instance support.\ndiff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c\nindex ef37943817..ee090d78ef 100644\n--- a/lib/vhost/vhost.c\n+++ b/lib/vhost/vhost.c\n@@ -1467,6 +1467,27 @@ rte_vhost_enable_guest_notification(int vid, uint16_t queue_id, int enable)\n \treturn ret;\n }\n \n+void\n+rte_vhost_notify_guest(int vid, uint16_t queue_id)\n+{\n+\tstruct virtio_net *dev = get_device(vid);\n+\tstruct vhost_virtqueue *vq;\n+\n+\tif (!dev ||  queue_id >= VHOST_MAX_VRING)\n+\t\treturn;\n+\n+\tvq = dev->virtqueue[queue_id];\n+\tif (!vq)\n+\t\treturn;\n+\n+\trte_spinlock_lock(&vq->access_lock);\n+\n+\tif (vq->callfd >= 0)\n+\t\teventfd_write(vq->callfd, (eventfd_t)1);\n+\n+\trte_spinlock_unlock(&vq->access_lock);\n+}\n+\n void\n rte_vhost_log_write(int vid, uint64_t addr, uint64_t len)\n {\ndiff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h\nindex 8fdab13c70..39ad8260a1 100644\n--- a/lib/vhost/vhost.h\n+++ b/lib/vhost/vhost.h\n@@ -883,6 +883,30 @@ vhost_need_event(uint16_t event_idx, uint16_t new_idx, uint16_t old)\n \treturn (uint16_t)(new_idx - event_idx - 1) < (uint16_t)(new_idx - old);\n }\n \n+static __rte_always_inline void\n+vhost_vring_kick_guest(struct virtio_net *dev, struct vhost_virtqueue *vq)\n+{\n+\tif (dev->notify_ops->guest_notify) {\n+\t\tuint16_t qid;\n+\t\tfor (qid = 0;  qid < dev->nr_vring; qid++) {\n+\t\t\tif (dev->virtqueue[qid] == vq) {\n+\t\t\t\tif (dev->notify_ops->guest_notify(dev->vid,\n+\t\t\t\t\t\t\t\t  qid))\n+\t\t\t\t\tgoto done;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\t}\n+\teventfd_write(vq->callfd, (eventfd_t) 1);\n+\n+done:\n+\tif (dev->flags & VIRTIO_DEV_STATS_ENABLED)\n+\t\tvq->stats.guest_notifications++;\n+\tif (dev->notify_ops->guest_notified)\n+\t\tdev->notify_ops->guest_notified(dev->vid);\n+}\n+\n+\n static __rte_always_inline void\n vhost_vring_call_split(struct virtio_net *dev, struct vhost_virtqueue *vq)\n {\n@@ -905,21 +929,13 @@ vhost_vring_call_split(struct virtio_net *dev, struct vhost_virtqueue *vq)\n \t\tif ((vhost_need_event(vhost_used_event(vq), new, old) &&\n \t\t\t\t\t(vq->callfd >= 0)) ||\n \t\t\t\tunlikely(!signalled_used_valid)) {\n-\t\t\teventfd_write(vq->callfd, (eventfd_t) 1);\n-\t\t\tif (dev->flags & VIRTIO_DEV_STATS_ENABLED)\n-\t\t\t\tvq->stats.guest_notifications++;\n-\t\t\tif (dev->notify_ops->guest_notified)\n-\t\t\t\tdev->notify_ops->guest_notified(dev->vid);\n+\t\t\tvhost_vring_kick_guest(dev, vq);\n \t\t}\n \t} else {\n \t\t/* Kick the guest if necessary. */\n \t\tif (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)\n \t\t\t\t&& (vq->callfd >= 0)) {\n-\t\t\teventfd_write(vq->callfd, (eventfd_t)1);\n-\t\t\tif (dev->flags & VIRTIO_DEV_STATS_ENABLED)\n-\t\t\t\tvq->stats.guest_notifications++;\n-\t\t\tif (dev->notify_ops->guest_notified)\n-\t\t\t\tdev->notify_ops->guest_notified(dev->vid);\n+\t\t\tvhost_vring_kick_guest(dev, vq);\n \t\t}\n \t}\n }\n@@ -971,11 +987,8 @@ vhost_vring_call_packed(struct virtio_net *dev, struct vhost_virtqueue *vq)\n \tif (vhost_need_event(off, new, old))\n \t\tkick = true;\n kick:\n-\tif (kick) {\n-\t\teventfd_write(vq->callfd, (eventfd_t)1);\n-\t\tif (dev->notify_ops->guest_notified)\n-\t\t\tdev->notify_ops->guest_notified(dev->vid);\n-\t}\n+\tif (kick)\n+\t\tvhost_vring_kick_guest(dev, vq);\n }\n \n static __rte_always_inline void\n",
    "prefixes": []
}