Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/66574/?format=api
https://patches.dpdk.org/api/patches/66574/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1584007039-12437-1-git-send-email-wangzhike@jd.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": "<1584007039-12437-1-git-send-email-wangzhike@jd.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1584007039-12437-1-git-send-email-wangzhike@jd.com", "date": "2020-03-12T09:57:19", "name": "vhost: return -EAGAIN during unregistering vhost if it is busy.", "commit_ref": null, "pull_url": null, "state": "rejected", "archived": true, "hash": "af7506ef4ad25edb74c7a0308b4fe7239b4195c3", "submitter": { "id": 873, "url": "https://patches.dpdk.org/api/people/873/?format=api", "name": "王志克", "email": "wangzhike@jd.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/1584007039-12437-1-git-send-email-wangzhike@jd.com/mbox/", "series": [ { "id": 8893, "url": "https://patches.dpdk.org/api/series/8893/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=8893", "date": "2020-03-12T09:57:19", "name": "vhost: return -EAGAIN during unregistering vhost if it is busy.", "version": 1, "mbox": "https://patches.dpdk.org/series/8893/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/66574/comments/", "check": "warning", "checks": "https://patches.dpdk.org/api/patches/66574/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 dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 1240DA0569;\n\tThu, 12 Mar 2020 10:57:53 +0100 (CET)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id D9CE31C010;\n\tThu, 12 Mar 2020 10:57:52 +0100 (CET)", "from m12-18.163.com (m12-18.163.com [220.181.12.18])\n by dpdk.org (Postfix) with ESMTP id 705412BAA;\n Thu, 12 Mar 2020 10:57:47 +0100 (CET)", "from localhost.localdomain (unknown [106.38.115.15])\n by smtp14 (Coremail) with SMTP id EsCowAAnndmOB2peVunzBA--.43447S2;\n Thu, 12 Mar 2020 17:57:46 +0800 (CST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com;\n s=s110527; h=From:Subject:Date:Message-Id; bh=7LZhwOo9SeoWLJAyaF\n NOBMegWmfjJLAjzzsCnHaW3oQ=; b=FkU2t+uKdIh98XDMu+VLVJwpzlnmGv0JLZ\n v+M8+kijrsbc8a+i5zFVoc5hoigTjSlFjjRf/VsydeUT6Mef0FMMPhV+DusG6qvX\n wZC+ObZtGMROnd74siXTZx9TtLwS6zBuUFjouB4fSwXLIDXOh5PZW9AY4uYzBjkD\n B9NpWYSxM=", "From": "Zhike Wang <wangzhike@jd.com>", "To": "dev@dpdk.org", "Cc": "maxime.coquelin@redhat.com, xiaolong.ye@intel.com, zhihong.wang@intel.com,\n stable@dpdk.org, Zhike Wang <wangzhike@jd.com>", "Date": "Thu, 12 Mar 2020 17:57:19 +0800", "Message-Id": "<1584007039-12437-1-git-send-email-wangzhike@jd.com>", "X-Mailer": "git-send-email 1.8.3.1", "X-CM-TRANSID": "EsCowAAnndmOB2peVunzBA--.43447S2", "X-Coremail-Antispam": "1Uf129KBjvJXoWxAry7Xw4UWF45Xw18Zw45GFg_yoW5XFWfpa\n 45WFy3JrZ7Gr10vrsrA3WrG34rKF1rAF47u3s7K3WUZrWUCw4Yqa92ka4jgw13JFy8ZF4U\n AF4Iga9Y9r18Cw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2\n 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jVmhrUUUUU=", "X-Originating-IP": "[106.38.115.15]", "X-CM-SenderInfo": "pzdqw6bntsiqqrwthudrp/1tbiVhrkulqzkD-S4AAAsm", "Subject": "[dpdk-dev] [PATCH] vhost: return -EAGAIN during unregistering vhost\n\tif it is busy.", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "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": "The vhost_user_read_cb() and rte_vhost_driver_unregister()\ncan be called at the same time by 2 threads, and may lead to deadlock.\nEg thread1 calls vhost_user_read_cb()->vhost_user_get_vring_base()->destroy_device(),\nthen thread2 calls rte_vhost_driver_unregister(), and will retry the fdset_try_del() in loop.\n\nSome application implements destroy_device() as a blocking function, eg\nOVS calls ovsrcu_synchronize() insides destroy_device(). As a result,\nthread1(eg vhost_events) is blocked to wait quiesce of thread2(eg ovs-vswitchd),\nand thread2 is in a loop to wait thread1 to give up the use of the vhost fd,\nthen leads to deadlock.\n\nIt is better to return -EAGAIN to application, who will decide how to handle\n(eg OVS can call ovsrcu_quiesce() and then retry).\n\nSigned-off-by: Zhike Wang <wangzhike@jd.com>\n---\n lib/librte_vhost/rte_vhost.h | 4 +++-\n lib/librte_vhost/socket.c | 8 ++++----\n 2 files changed, 7 insertions(+), 5 deletions(-)", "diff": "diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h\nindex c7b619a..276db11 100644\n--- a/lib/librte_vhost/rte_vhost.h\n+++ b/lib/librte_vhost/rte_vhost.h\n@@ -389,7 +389,9 @@ void rte_vhost_log_used_vring(int vid, uint16_t vring_idx,\n */\n int rte_vhost_driver_register(const char *path, uint64_t flags);\n \n-/* Unregister vhost driver. This is only meaningful to vhost user. */\n+/* Unregister vhost driver. This is only meaningful to vhost user.\n+ * Return -EAGAIN if device is busy, and leave it to be handled by application.\n+ */\n int rte_vhost_driver_unregister(const char *path);\n \n /**\ndiff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c\nindex 7c80121..a75a3f6 100644\n--- a/lib/librte_vhost/socket.c\n+++ b/lib/librte_vhost/socket.c\n@@ -1027,7 +1027,8 @@ struct vhost_user_reconnect_list {\n }\n \n /**\n- * Unregister the specified vhost socket\n+ * Unregister the specified vhost socket.\n+ * Return -EAGAIN if device is busy, and leave it to be handled by application.\n */\n int\n rte_vhost_driver_unregister(const char *path)\n@@ -1039,7 +1040,6 @@ struct vhost_user_reconnect_list {\n \tif (path == NULL)\n \t\treturn -1;\n \n-again:\n \tpthread_mutex_lock(&vhost_user.mutex);\n \n \tfor (i = 0; i < vhost_user.vsocket_cnt; i++) {\n@@ -1063,7 +1063,7 @@ struct vhost_user_reconnect_list {\n \t\t\t\t\tpthread_mutex_unlock(\n \t\t\t\t\t\t\t&vsocket->conn_mutex);\n \t\t\t\t\tpthread_mutex_unlock(&vhost_user.mutex);\n-\t\t\t\t\tgoto again;\n+\t\t\t\t\treturn -EAGAIN;\n \t\t\t\t}\n \n \t\t\t\tVHOST_LOG_CONFIG(INFO,\n@@ -1085,7 +1085,7 @@ struct vhost_user_reconnect_list {\n \t\t\t\tif (fdset_try_del(&vhost_user.fdset,\n \t\t\t\t\t\tvsocket->socket_fd) == -1) {\n \t\t\t\t\tpthread_mutex_unlock(&vhost_user.mutex);\n-\t\t\t\t\tgoto again;\n+\t\t\t\t\treturn -EAGAIN;\n \t\t\t\t}\n \n \t\t\t\tclose(vsocket->socket_fd);\n", "prefixes": [] }{ "id": 66574, "url": "