Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/44290/?format=api
http://patches.dpdk.org/api/patches/44290/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20180905042852.6212-2-tiwei.bie@intel.com/", "project": { "id": 1, "url": "http://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": "<20180905042852.6212-2-tiwei.bie@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20180905042852.6212-2-tiwei.bie@intel.com", "date": "2018-09-05T04:28:50", "name": "[1/3] net/virtio-user: fix deadlock in memory events callback", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "ca691fa9e8aa872ff214efbae190d2c1945952ba", "submitter": { "id": 617, "url": "http://patches.dpdk.org/api/people/617/?format=api", "name": "Tiwei Bie", "email": "tiwei.bie@intel.com" }, "delegate": { "id": 2642, "url": "http://patches.dpdk.org/api/users/2642/?format=api", "username": "mcoquelin", "first_name": "Maxime", "last_name": "Coquelin", "email": "maxime.coquelin@redhat.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20180905042852.6212-2-tiwei.bie@intel.com/mbox/", "series": [ { "id": 1180, "url": "http://patches.dpdk.org/api/series/1180/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1180", "date": "2018-09-05T04:28:49", "name": "Some fixes/improvements for virtio-user memory table", "version": 1, "mbox": "http://patches.dpdk.org/series/1180/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/44290/comments/", "check": "fail", "checks": "http://patches.dpdk.org/api/patches/44290/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 441E52C4F;\n\tWed, 5 Sep 2018 06:31:05 +0200 (CEST)", "from mga18.intel.com (mga18.intel.com [134.134.136.126])\n\tby dpdk.org (Postfix) with ESMTP id 3381C28FD;\n\tWed, 5 Sep 2018 06:31:02 +0200 (CEST)", "from fmsmga008.fm.intel.com ([10.253.24.58])\n\tby orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t04 Sep 2018 21:31:00 -0700", "from btwcube1.sh.intel.com ([10.67.104.194])\n\tby fmsmga008.fm.intel.com with ESMTP; 04 Sep 2018 21:29:47 -0700" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.53,332,1531810800\"; d=\"scan'208\";a=\"68456347\"", "From": "Tiwei Bie <tiwei.bie@intel.com>", "To": "maxime.coquelin@redhat.com,\n\tzhihong.wang@intel.com,\n\tdev@dpdk.org", "Cc": "seanbh@gmail.com,\n\tanatoly.burakov@intel.com,\n\tstable@dpdk.org", "Date": "Wed, 5 Sep 2018 12:28:50 +0800", "Message-Id": "<20180905042852.6212-2-tiwei.bie@intel.com>", "X-Mailer": "git-send-email 2.18.0", "In-Reply-To": "<20180905042852.6212-1-tiwei.bie@intel.com>", "References": "<20180905042852.6212-1-tiwei.bie@intel.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=utf-8", "Content-Transfer-Encoding": "8bit", "Subject": "[dpdk-dev] [PATCH 1/3] net/virtio-user: fix deadlock in memory\n\tevents callback", "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\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Deadlock can occur when allocating memory if a vhost-kernel\nbased virtio-user device is in use. To fix the deadlock,\nwe will take memory hotplug lock explicitly in virtio-user\nwhen necessary, and always call the _thread_unsafe memory\nfunctions.\n\nBugzilla ID: 81\nFixes: 12ecb2f63b12 (\"net/virtio-user: support memory hotplug\")\nCc: stable@dpdk.org\n\nReported-by: Seán Harte <seanbh@gmail.com>\nSigned-off-by: Tiwei Bie <tiwei.bie@intel.com>\n---\n drivers/net/virtio/virtio_user/vhost_kernel.c | 6 +++++-\n .../net/virtio/virtio_user/virtio_user_dev.c | 19 +++++++++++++++++++\n 2 files changed, 24 insertions(+), 1 deletion(-)", "diff": "diff --git a/drivers/net/virtio/virtio_user/vhost_kernel.c b/drivers/net/virtio/virtio_user/vhost_kernel.c\nindex b2444096c..897fee0af 100644\n--- a/drivers/net/virtio/virtio_user/vhost_kernel.c\n+++ b/drivers/net/virtio/virtio_user/vhost_kernel.c\n@@ -115,7 +115,11 @@ prepare_vhost_memory_kernel(void)\n \twa.region_nr = 0;\n \twa.vm = vm;\n \n-\tif (rte_memseg_contig_walk(add_memory_region, &wa) < 0) {\n+\t/*\n+\t * The memory lock has already been taken by memory subsystem\n+\t * or virtio_user_start_device().\n+\t */\n+\tif (rte_memseg_contig_walk_thread_unsafe(add_memory_region, &wa) < 0) {\n \t\tfree(vm);\n \t\treturn NULL;\n \t}\ndiff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c\nindex 7df600b02..869e96f87 100644\n--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c\n+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c\n@@ -13,6 +13,8 @@\n #include <sys/types.h>\n #include <sys/stat.h>\n \n+#include <rte_eal_memconfig.h>\n+\n #include \"vhost.h\"\n #include \"virtio_user_dev.h\"\n #include \"../virtio_ethdev.h\"\n@@ -109,9 +111,24 @@ is_vhost_user_by_type(const char *path)\n int\n virtio_user_start_device(struct virtio_user_dev *dev)\n {\n+\tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n \tuint64_t features;\n \tint ret;\n \n+\t/*\n+\t * XXX workaround!\n+\t *\n+\t * We need to make sure that the locks will be\n+\t * taken in the correct order to avoid deadlocks.\n+\t *\n+\t * Before releasing this lock, this thread should\n+\t * not trigger any memory hotplug events.\n+\t *\n+\t * This is a temporary workaround, and should be\n+\t * replaced when we get proper supports from the\n+\t * memory subsystem in the future.\n+\t */\n+\trte_rwlock_read_lock(&mcfg->memory_hotplug_lock);\n \tpthread_mutex_lock(&dev->mutex);\n \n \tif (is_vhost_user_by_type(dev->path) && dev->vhostfd < 0)\n@@ -152,10 +169,12 @@ virtio_user_start_device(struct virtio_user_dev *dev)\n \n \tdev->started = true;\n \tpthread_mutex_unlock(&dev->mutex);\n+\trte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);\n \n \treturn 0;\n error:\n \tpthread_mutex_unlock(&dev->mutex);\n+\trte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);\n \t/* TODO: free resource here or caller to check */\n \treturn -1;\n }\n", "prefixes": [ "1/3" ] }{ "id": 44290, "url": "