Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/93525/?format=api
https://patches.dpdk.org/api/patches/93525/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1622189463-392610-3-git-send-email-jiayu.hu@intel.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": "<1622189463-392610-3-git-send-email-jiayu.hu@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1622189463-392610-3-git-send-email-jiayu.hu@intel.com", "date": "2021-05-28T08:11:03", "name": "[2/2] vhost: add thread unsafe async registration functions", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "41d744da9ac200d05e42886128e44e58613e010f", "submitter": { "id": 539, "url": "https://patches.dpdk.org/api/people/539/?format=api", "name": "Hu, Jiayu", "email": "jiayu.hu@intel.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/1622189463-392610-3-git-send-email-jiayu.hu@intel.com/mbox/", "series": [ { "id": 17148, "url": "https://patches.dpdk.org/api/series/17148/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=17148", "date": "2021-05-28T08:11:01", "name": "provide thread unsafe async registration functions", "version": 1, "mbox": "https://patches.dpdk.org/series/17148/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/93525/comments/", "check": "fail", "checks": "https://patches.dpdk.org/api/patches/93525/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 1B3A5A0547;\n\tFri, 28 May 2021 03:42:56 +0200 (CEST)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 08C2841108;\n\tFri, 28 May 2021 03:42:48 +0200 (CEST)", "from mga07.intel.com (mga07.intel.com [134.134.136.100])\n by mails.dpdk.org (Postfix) with ESMTP id EADAA410E9\n for <dev@dpdk.org>; Fri, 28 May 2021 03:42:44 +0200 (CEST)", "from orsmga001.jf.intel.com ([10.7.209.18])\n by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 27 May 2021 18:42:44 -0700", "from npg_dpdk_virtio_jiayuhu_07.sh.intel.com ([10.67.118.193])\n by orsmga001.jf.intel.com with ESMTP; 27 May 2021 18:42:42 -0700" ], "IronPort-SDR": [ "\n 5WJ58m0+bD7V7rpSXwTsqZlElV01l/a/QwowwD+68ZuiArJ33hlUIB4X2Qqviv7XuuoDxhdwkU\n QZxChE/nXwsw==", "\n ZLwmEhx+Lfn5t+EV+u+T00fdAVbu8WA6L2FbK8TSS3NP26MPOw1RISKVhxUvVjR2Tu7mi7GgkB\n fElTRCo7Fx+Q==" ], "X-IronPort-AV": [ "E=McAfee;i=\"6200,9189,9997\"; a=\"266760005\"", "E=Sophos;i=\"5.83,228,1616482800\"; d=\"scan'208\";a=\"266760005\"", "E=Sophos;i=\"5.83,228,1616482800\"; d=\"scan'208\";a=\"477732994\"" ], "X-ExtLoop1": "1", "From": "Jiayu Hu <jiayu.hu@intel.com>", "To": "dev@dpdk.org", "Cc": "maxime.coquelin@redhat.com, chenbo.xia@intel.com, yinan.wang@intel.com,\n Jiayu Hu <jiayu.hu@intel.com>", "Date": "Fri, 28 May 2021 04:11:03 -0400", "Message-Id": "<1622189463-392610-3-git-send-email-jiayu.hu@intel.com>", "X-Mailer": "git-send-email 2.7.4", "In-Reply-To": "<1622189463-392610-1-git-send-email-jiayu.hu@intel.com>", "References": "<1622189463-392610-1-git-send-email-jiayu.hu@intel.com>", "Subject": "[dpdk-dev] [PATCH 2/2] vhost: add thread unsafe async registration\n functions", "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", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "This patch is to add thread unsafe version for async register and\nunregister functions.\n\nSigned-off-by: Jiayu Hu <jiayu.hu@intel.com>\n---\n doc/guides/prog_guide/vhost_lib.rst | 12 +++\n lib/vhost/rte_vhost_async.h | 42 ++++++++++\n lib/vhost/version.map | 4 +\n lib/vhost/vhost.c | 161 +++++++++++++++++++++++++++---------\n 4 files changed, 178 insertions(+), 41 deletions(-)", "diff": "diff --git a/doc/guides/prog_guide/vhost_lib.rst b/doc/guides/prog_guide/vhost_lib.rst\nindex d18fb98..6b2745f 100644\n--- a/doc/guides/prog_guide/vhost_lib.rst\n+++ b/doc/guides/prog_guide/vhost_lib.rst\n@@ -253,6 +253,12 @@ The following is an overview of some key Vhost API functions:\n vhost invokes this function to get the copy data completed by async\n devices.\n \n+* ``rte_vhost_async_channel_register_thread_unsafe(vid, queue_id, features, ops)``\n+ Register a vhost queue with async copy device channel without\n+ performing any locking.\n+\n+ This function is only safe to call from within vhost callback functions.\n+\n * ``rte_vhost_async_channel_unregister(vid, queue_id)``\n \n Unregister the async copy device channel from a vhost queue.\n@@ -265,6 +271,12 @@ The following is an overview of some key Vhost API functions:\n devices for all vhost queues in destroy_device(), when a\n virtio device is paused or shut down.\n \n+* ``rte_vhost_async_channel_unregister_thread_unsafe(vid, queue_id)``\n+ Unregister the async copy device channel from a vhost queue without\n+ performing any locking.\n+\n+ This function is only safe to call from within vhost callback functions.\n+\n * ``rte_vhost_submit_enqueue_burst(vid, queue_id, pkts, count, comp_pkts, comp_count)``\n \n Submit an enqueue request to transmit ``count`` packets from host to guest\ndiff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h\nindex 6faa31f..d054b5f 100644\n--- a/lib/vhost/rte_vhost_async.h\n+++ b/lib/vhost/rte_vhost_async.h\n@@ -143,6 +143,48 @@ __rte_experimental\n int rte_vhost_async_channel_unregister(int vid, uint16_t queue_id);\n \n /**\n+ * register an async channel for vhost without performing any locking\n+ *\n+ * @note This function does not perform any locking, and is only safe to call\n+ * from within vhost callback functions.\n+ *\n+ * @param vid\n+ * vhost device id async channel to be attached to\n+ * @param queue_id\n+ * vhost queue id async channel to be attached to\n+ * @param features\n+ * DMA channel feature bit\n+ * b0 : DMA supports inorder data transfer\n+ * b1 - b15: reserved\n+ * b16 - b27: Packet length threshold for DMA transfer\n+ * b28 - b31: reserved\n+ * @param ops\n+ * DMA operation callbacks\n+ * @return\n+ * 0 on success, -1 on failures\n+ */\n+__rte_experimental\n+int rte_vhost_async_channel_register_thread_unsafe(int vid, uint16_t queue_id,\n+\tuint32_t features, struct rte_vhost_async_channel_ops *ops);\n+\n+/**\n+ * unregister a dma channel for vhost without performing any lock\n+ *\n+ * @note This function does not perform any locking, and is only safe to call\n+ * from within vhost callback functions.\n+ *\n+ * @param vid\n+ * vhost device id DMA channel to be detached\n+ * @param queue_id\n+ * vhost queue id DMA channel to be detached\n+ * @return\n+ * 0 on success, -1 on failures\n+ */\n+__rte_experimental\n+int rte_vhost_async_channel_unregister_thread_unsafe(int vid,\n+\t\tuint16_t queue_id);\n+\n+/**\n * This function submits enqueue data to async engine. Successfully\n * enqueued packets can be transfer completed or being occupied by DMA\n * engines, when this API returns. Transfer completed packets are returned\ndiff --git a/lib/vhost/version.map b/lib/vhost/version.map\nindex 9103a23..2363db8 100644\n--- a/lib/vhost/version.map\n+++ b/lib/vhost/version.map\n@@ -79,4 +79,8 @@ EXPERIMENTAL {\n \n \t# added in 21.05\n \trte_vhost_get_negotiated_protocol_features;\n+\n+\t# added in 21.08\n+\trte_vhost_async_channel_register_thread_unsafe;\n+\trte_vhost_async_channel_unregister_thread_unsafe;\n };\ndiff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c\nindex c96f633..025e150 100644\n--- a/lib/vhost/vhost.c\n+++ b/lib/vhost/vhost.c\n@@ -1609,46 +1609,20 @@ int rte_vhost_extern_callback_register(int vid,\n \treturn 0;\n }\n \n-int rte_vhost_async_channel_register(int vid, uint16_t queue_id,\n-\t\t\t\t\tuint32_t features,\n-\t\t\t\t\tstruct rte_vhost_async_channel_ops *ops)\n+static __rte_always_inline int\n+async_channel_register(int vid, uint16_t queue_id,\n+\t\tstruct rte_vhost_async_features f,\n+\t\tstruct rte_vhost_async_channel_ops *ops)\n {\n-\tstruct vhost_virtqueue *vq;\n \tstruct virtio_net *dev = get_device(vid);\n-\tstruct rte_vhost_async_features f;\n+\tstruct vhost_virtqueue *vq = dev->virtqueue[queue_id];\n \tint node;\n \n-\tif (dev == NULL || ops == NULL)\n-\t\treturn -1;\n-\n-\tf.intval = features;\n-\n-\tif (queue_id >= VHOST_MAX_VRING)\n-\t\treturn -1;\n-\n-\tvq = dev->virtqueue[queue_id];\n-\n-\tif (unlikely(vq == NULL || !dev->async_copy))\n-\t\treturn -1;\n-\n-\tif (unlikely(!f.async_inorder)) {\n-\t\tVHOST_LOG_CONFIG(ERR,\n-\t\t\t\"async copy is not supported on non-inorder mode \"\n-\t\t\t\"(vid %d, qid: %d)\\n\", vid, queue_id);\n-\t\treturn -1;\n-\t}\n-\n-\tif (unlikely(ops->check_completed_copies == NULL ||\n-\t\tops->transfer_data == NULL))\n-\t\treturn -1;\n-\n-\trte_spinlock_lock(&vq->access_lock);\n-\n \tif (unlikely(vq->async_registered)) {\n \t\tVHOST_LOG_CONFIG(ERR,\n \t\t\t\"async register failed: channel already registered \"\n \t\t\t\"(vid %d, qid: %d)\\n\", vid, queue_id);\n-\t\tgoto reg_out;\n+\t\treturn -1;\n \t}\n \n #ifdef RTE_LIBRTE_VHOST_NUMA\n@@ -1670,7 +1644,7 @@ int rte_vhost_async_channel_register(int vid, uint16_t queue_id,\n \t\tVHOST_LOG_CONFIG(ERR,\n \t\t\t\"async register failed: cannot allocate memory for async_pkts_info \"\n \t\t\t\"(vid %d, qid: %d)\\n\", vid, queue_id);\n-\t\tgoto reg_out;\n+\t\treturn -1;\n \t}\n \n \tvq->it_pool = rte_malloc_socket(NULL,\n@@ -1681,7 +1655,7 @@ int rte_vhost_async_channel_register(int vid, uint16_t queue_id,\n \t\tVHOST_LOG_CONFIG(ERR,\n \t\t\t\"async register failed: cannot allocate memory for it_pool \"\n \t\t\t\"(vid %d, qid: %d)\\n\", vid, queue_id);\n-\t\tgoto reg_out;\n+\t\treturn -1;\n \t}\n \n \tvq->vec_pool = rte_malloc_socket(NULL,\n@@ -1692,7 +1666,7 @@ int rte_vhost_async_channel_register(int vid, uint16_t queue_id,\n \t\tVHOST_LOG_CONFIG(ERR,\n \t\t\t\"async register failed: cannot allocate memory for vec_pool \"\n \t\t\t\"(vid %d, qid: %d)\\n\", vid, queue_id);\n-\t\tgoto reg_out;\n+\t\treturn -1;\n \t}\n \n \tif (vq_is_packed(dev)) {\n@@ -1704,7 +1678,7 @@ int rte_vhost_async_channel_register(int vid, uint16_t queue_id,\n \t\t\tVHOST_LOG_CONFIG(ERR,\n \t\t\t\t\"async register failed: cannot allocate memory for async buffers \"\n \t\t\t\t\"(vid %d, qid: %d)\\n\", vid, queue_id);\n-\t\t\tgoto reg_out;\n+\t\t\treturn -1;\n \t\t}\n \t} else {\n \t\tvq->async_descs_split = rte_malloc_socket(NULL,\n@@ -1715,22 +1689,92 @@ int rte_vhost_async_channel_register(int vid, uint16_t queue_id,\n \t\t\tVHOST_LOG_CONFIG(ERR,\n \t\t\t\t\"async register failed: cannot allocate memory for async descs \"\n \t\t\t\t\"(vid %d, qid: %d)\\n\", vid, queue_id);\n-\t\t\tgoto reg_out;\n+\t\t\treturn -1;\n \t\t}\n \t}\n \n \tvq->async_ops.check_completed_copies = ops->check_completed_copies;\n \tvq->async_ops.transfer_data = ops->transfer_data;\n-\n \tvq->async_inorder = f.async_inorder;\n \tvq->async_threshold = f.async_threshold;\n-\n \tvq->async_registered = true;\n \n-reg_out:\n+\treturn 0;\n+}\n+\n+int rte_vhost_async_channel_register(int vid, uint16_t queue_id,\n+\t\t\t\t\tuint32_t features,\n+\t\t\t\t\tstruct rte_vhost_async_channel_ops *ops)\n+{\n+\tstruct vhost_virtqueue *vq;\n+\tstruct virtio_net *dev = get_device(vid);\n+\tstruct rte_vhost_async_features f;\n+\tint ret;\n+\n+\tif (dev == NULL || ops == NULL)\n+\t\treturn -1;\n+\n+\tf.intval = features;\n+\n+\tif (queue_id >= VHOST_MAX_VRING)\n+\t\treturn -1;\n+\n+\tvq = dev->virtqueue[queue_id];\n+\n+\tif (unlikely(vq == NULL || !dev->async_copy))\n+\t\treturn -1;\n+\n+\tif (unlikely(!f.async_inorder)) {\n+\t\tVHOST_LOG_CONFIG(ERR,\n+\t\t\t\"async copy is not supported on non-inorder mode \"\n+\t\t\t\"(vid %d, qid: %d)\\n\", vid, queue_id);\n+\t\treturn -1;\n+\t}\n+\n+\tif (unlikely(ops->check_completed_copies == NULL ||\n+\t\tops->transfer_data == NULL))\n+\t\treturn -1;\n+\n+\trte_spinlock_lock(&vq->access_lock);\n+\tret = async_channel_register(vid, queue_id, f, ops);\n \trte_spinlock_unlock(&vq->access_lock);\n \n-\treturn 0;\n+\treturn ret;\n+}\n+\n+int rte_vhost_async_channel_register_thread_unsafe(int vid, uint16_t queue_id,\n+\t\t\t\t\tuint32_t features,\n+\t\t\t\t\tstruct rte_vhost_async_channel_ops *ops)\n+{\n+\tstruct vhost_virtqueue *vq;\n+\tstruct virtio_net *dev = get_device(vid);\n+\tstruct rte_vhost_async_features f;\n+\n+\tif (dev == NULL || ops == NULL)\n+\t\treturn -1;\n+\n+\tf.intval = features;\n+\n+\tif (queue_id >= VHOST_MAX_VRING)\n+\t\treturn -1;\n+\n+\tvq = dev->virtqueue[queue_id];\n+\n+\tif (unlikely(vq == NULL || !dev->async_copy))\n+\t\treturn -1;\n+\n+\tif (unlikely(!f.async_inorder)) {\n+\t\tVHOST_LOG_CONFIG(ERR,\n+\t\t\t\"async copy is not supported on non-inorder mode \"\n+\t\t\t\"(vid %d, qid: %d)\\n\", vid, queue_id);\n+\t\treturn -1;\n+\t}\n+\n+\tif (unlikely(ops->check_completed_copies == NULL ||\n+\t\tops->transfer_data == NULL))\n+\t\treturn -1;\n+\n+\treturn async_channel_register(vid, queue_id, f, ops);\n }\n \n int rte_vhost_async_channel_unregister(int vid, uint16_t queue_id)\n@@ -1780,5 +1824,40 @@ int rte_vhost_async_channel_unregister(int vid, uint16_t queue_id)\n \treturn ret;\n }\n \n+int rte_vhost_async_channel_unregister_thread_unsafe(int vid,\n+\t\tuint16_t queue_id)\n+{\n+\tstruct vhost_virtqueue *vq;\n+\tstruct virtio_net *dev = get_device(vid);\n+\n+\tif (dev == NULL)\n+\t\treturn -1;\n+\n+\tif (queue_id >= VHOST_MAX_VRING)\n+\t\treturn -1;\n+\n+\tvq = dev->virtqueue[queue_id];\n+\n+\tif (vq == NULL)\n+\t\treturn -1;\n+\n+\tif (!vq->async_registered)\n+\t\treturn 0;\n+\n+\tif (vq->async_pkts_inflight_n) {\n+\t\tVHOST_LOG_CONFIG(ERR, \"Failed to unregister async channel. \"\n+\t\t\t\"async inflight packets must be completed before unregistration.\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tvhost_free_async_mem(vq);\n+\n+\tvq->async_ops.transfer_data = NULL;\n+\tvq->async_ops.check_completed_copies = NULL;\n+\tvq->async_registered = false;\n+\n+\treturn 0;\n+}\n+\n RTE_LOG_REGISTER_SUFFIX(vhost_config_log_level, config, INFO);\n RTE_LOG_REGISTER_SUFFIX(vhost_data_log_level, data, WARNING);\n", "prefixes": [ "2/2" ] }{ "id": 93525, "url": "