[dpdk-stable] patch 'net/virtio-user: fix deadlock in memory events callback' has been queued to stable release 18.08.1
Kevin Traynor
ktraynor at redhat.com
Tue Nov 20 20:12:47 CET 2018
Hi,
FYI, your patch has been queued to stable release 18.08.1
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/23/18. So please
shout if anyone has objections.
Also note that after the patch there's a diff of the upstream commit vs the patch applied
to the branch. If the code is different (ie: not only metadata diffs), due for example to
a change in context or macro names, please double check it.
Thanks.
Kevin Traynor
---
>From 9a3059147371629a60cd19ce9cd78643616de9ae Mon Sep 17 00:00:00 2001
From: Tiwei Bie <tiwei.bie at intel.com>
Date: Wed, 5 Sep 2018 12:28:50 +0800
Subject: [PATCH] net/virtio-user: fix deadlock in memory events callback
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[ upstream commit 7ff269575bd144482d56a20fec61187f1af15dda ]
Deadlock can occur when allocating memory if a vhost-kernel
based virtio-user device is in use. To fix the deadlock,
we will take memory hotplug lock explicitly in virtio-user
when necessary, and always call the _thread_unsafe memory
functions.
Bugzilla ID: 81
Fixes: 12ecb2f63b12 ("net/virtio-user: support memory hotplug")
Reported-by: Seán Harte <seanbh at gmail.com>
Signed-off-by: Tiwei Bie <tiwei.bie at intel.com>
Tested-by: Seán Harte <seanbh at gmail.com>
Reviewed-by: Seán Harte <seanbh at gmail.com>
Reviewed-by: Anatoly Burakov <anatoly.burakov at intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
drivers/net/virtio/virtio_user/vhost_kernel.c | 6 +++++-
.../net/virtio/virtio_user/virtio_user_dev.c | 19 +++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/net/virtio/virtio_user/vhost_kernel.c b/drivers/net/virtio/virtio_user/vhost_kernel.c
index d1be82162..a93fe5b28 100644
--- a/drivers/net/virtio/virtio_user/vhost_kernel.c
+++ b/drivers/net/virtio/virtio_user/vhost_kernel.c
@@ -116,5 +116,9 @@ prepare_vhost_memory_kernel(void)
wa.vm = vm;
- if (rte_memseg_contig_walk(add_memory_region, &wa) < 0) {
+ /*
+ * The memory lock has already been taken by memory subsystem
+ * or virtio_user_start_device().
+ */
+ if (rte_memseg_contig_walk_thread_unsafe(add_memory_region, &wa) < 0) {
free(vm);
return NULL;
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 7df600b02..869e96f87 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -14,4 +14,6 @@
#include <sys/stat.h>
+#include <rte_eal_memconfig.h>
+
#include "vhost.h"
#include "virtio_user_dev.h"
@@ -110,7 +112,22 @@ int
virtio_user_start_device(struct virtio_user_dev *dev)
{
+ struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
uint64_t features;
int ret;
+ /*
+ * XXX workaround!
+ *
+ * We need to make sure that the locks will be
+ * taken in the correct order to avoid deadlocks.
+ *
+ * Before releasing this lock, this thread should
+ * not trigger any memory hotplug events.
+ *
+ * This is a temporary workaround, and should be
+ * replaced when we get proper supports from the
+ * memory subsystem in the future.
+ */
+ rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
pthread_mutex_lock(&dev->mutex);
@@ -153,8 +170,10 @@ virtio_user_start_device(struct virtio_user_dev *dev)
dev->started = true;
pthread_mutex_unlock(&dev->mutex);
+ rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
return 0;
error:
pthread_mutex_unlock(&dev->mutex);
+ rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
/* TODO: free resource here or caller to check */
return -1;
--
2.19.0
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2018-11-20 17:53:08.832978388 +0000
+++ 0057-net-virtio-user-fix-deadlock-in-memory-events-callba.patch 2018-11-20 17:53:07.000000000 +0000
@@ -1,4 +1,4 @@
-From 7ff269575bd144482d56a20fec61187f1af15dda Mon Sep 17 00:00:00 2001
+From 9a3059147371629a60cd19ce9cd78643616de9ae Mon Sep 17 00:00:00 2001
From: Tiwei Bie <tiwei.bie at intel.com>
Date: Wed, 5 Sep 2018 12:28:50 +0800
Subject: [PATCH] net/virtio-user: fix deadlock in memory events callback
@@ -6,6 +6,8 @@
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
+[ upstream commit 7ff269575bd144482d56a20fec61187f1af15dda ]
+
Deadlock can occur when allocating memory if a vhost-kernel
based virtio-user device is in use. To fix the deadlock,
we will take memory hotplug lock explicitly in virtio-user
@@ -14,7 +16,6 @@
Bugzilla ID: 81
Fixes: 12ecb2f63b12 ("net/virtio-user: support memory hotplug")
-Cc: stable at dpdk.org
Reported-by: Seán Harte <seanbh at gmail.com>
Signed-off-by: Tiwei Bie <tiwei.bie at intel.com>
More information about the stable
mailing list