* [Qemu-devel] [PATCH 0/2] migration/rdma disconnect fixes
@ 2019-09-13 16:35 Dr. David Alan Gilbert (git)
2019-09-13 16:35 ` [Qemu-devel] [PATCH 1/2] migration/rdma: Don't moan about disconnects at the end Dr. David Alan Gilbert (git)
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2019-09-13 16:35 UTC (permalink / raw)
To: qemu-devel, quintela, peterx
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Hi,
This fixes a deadlock that can occur on the source after
a failed RDMA migration and cleans up some warning messages
that can appear during normal completion.
https://bugzilla.redhat.com/show_bug.cgi?id=1746787
Dr. David Alan Gilbert (2):
migration/rdma: Don't moan about disconnects at the end
migration/rdma.c: Swap synchronize_rcu for call_rcu
migration/rdma.c | 51 +++++++++++++++++++++++++++++++++---------------
1 file changed, 35 insertions(+), 16 deletions(-)
--
2.21.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 1/2] migration/rdma: Don't moan about disconnects at the end
2019-09-13 16:35 [Qemu-devel] [PATCH 0/2] migration/rdma disconnect fixes Dr. David Alan Gilbert (git)
@ 2019-09-13 16:35 ` Dr. David Alan Gilbert (git)
2019-09-13 16:35 ` [Qemu-devel] [PATCH 2/2] migration/rdma.c: Swap synchronize_rcu for call_rcu Dr. David Alan Gilbert (git)
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2019-09-13 16:35 UTC (permalink / raw)
To: qemu-devel, quintela, peterx
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
If we've already finished the migration or something has
already gone wrong, don't moan about the migration stream disconnecting.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
migration/rdma.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/migration/rdma.c b/migration/rdma.c
index 78e6b72bac..0fcf02f48e 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -3253,10 +3253,14 @@ static void rdma_cm_poll_handler(void *opaque)
if (cm_event->event == RDMA_CM_EVENT_DISCONNECTED ||
cm_event->event == RDMA_CM_EVENT_DEVICE_REMOVAL) {
- error_report("receive cm event, cm event is %d", cm_event->event);
- rdma->error_state = -EPIPE;
- if (rdma->return_path) {
- rdma->return_path->error_state = -EPIPE;
+ if (!rdma->error_state &&
+ migration_incoming_get_current()->state !=
+ MIGRATION_STATUS_COMPLETED) {
+ error_report("receive cm event, cm event is %d", cm_event->event);
+ rdma->error_state = -EPIPE;
+ if (rdma->return_path) {
+ rdma->return_path->error_state = -EPIPE;
+ }
}
if (mis->migration_incoming_co) {
--
2.21.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 2/2] migration/rdma.c: Swap synchronize_rcu for call_rcu
2019-09-13 16:35 [Qemu-devel] [PATCH 0/2] migration/rdma disconnect fixes Dr. David Alan Gilbert (git)
2019-09-13 16:35 ` [Qemu-devel] [PATCH 1/2] migration/rdma: Don't moan about disconnects at the end Dr. David Alan Gilbert (git)
@ 2019-09-13 16:35 ` Dr. David Alan Gilbert (git)
2019-09-16 2:59 ` [Qemu-devel] [PATCH 0/2] migration/rdma disconnect fixes Peter Xu
2019-09-25 10:11 ` Dr. David Alan Gilbert
3 siblings, 0 replies; 5+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2019-09-13 16:35 UTC (permalink / raw)
To: qemu-devel, quintela, peterx
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
This fixes a deadlock that can occur on the migration source after
a failed RDMA migration; as the source tries to cleanup it
clears a pair of pointers and uses synchronize_rcu to wait; this
is happening on the main thread. With the CPUs running
a CPU thread can be an rcu reader and attempt to grab the main lock
(kvm_handle_io->address_space_write->flatview_write->flatview_write_continue->
prepare_mmio_access->qemu_mutex_lock_iothread_impl)
Replace the synchronize_rcu with a call_rcu to postpone the freeing.
Fixes: 74637e6f08fceda98806 ("migration: implement bi-directional RDMA QIOChannel")
( https://bugzilla.redhat.com/show_bug.cgi?id=1746787 )
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
migration/rdma.c | 39 +++++++++++++++++++++++++++------------
1 file changed, 27 insertions(+), 12 deletions(-)
diff --git a/migration/rdma.c b/migration/rdma.c
index 0fcf02f48e..4c74e88a37 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -3017,11 +3017,35 @@ static void qio_channel_rdma_set_aio_fd_handler(QIOChannel *ioc,
}
}
+struct rdma_close_rcu {
+ struct rcu_head rcu;
+ RDMAContext *rdmain;
+ RDMAContext *rdmaout;
+};
+
+/* callback from qio_channel_rdma_close via call_rcu */
+static void qio_channel_rdma_close_rcu(struct rdma_close_rcu *rcu)
+{
+ if (rcu->rdmain) {
+ qemu_rdma_cleanup(rcu->rdmain);
+ }
+
+ if (rcu->rdmaout) {
+ qemu_rdma_cleanup(rcu->rdmaout);
+ }
+
+ g_free(rcu->rdmain);
+ g_free(rcu->rdmaout);
+ g_free(rcu);
+}
+
static int qio_channel_rdma_close(QIOChannel *ioc,
Error **errp)
{
QIOChannelRDMA *rioc = QIO_CHANNEL_RDMA(ioc);
RDMAContext *rdmain, *rdmaout;
+ struct rdma_close_rcu *rcu = g_new(struct rdma_close_rcu, 1);
+
trace_qemu_rdma_close();
rdmain = rioc->rdmain;
@@ -3034,18 +3058,9 @@ static int qio_channel_rdma_close(QIOChannel *ioc,
atomic_rcu_set(&rioc->rdmaout, NULL);
}
- synchronize_rcu();
-
- if (rdmain) {
- qemu_rdma_cleanup(rdmain);
- }
-
- if (rdmaout) {
- qemu_rdma_cleanup(rdmaout);
- }
-
- g_free(rdmain);
- g_free(rdmaout);
+ rcu->rdmain = rdmain;
+ rcu->rdmaout = rdmaout;
+ call_rcu(rcu, qio_channel_rdma_close_rcu, rcu);
return 0;
}
--
2.21.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] migration/rdma disconnect fixes
2019-09-13 16:35 [Qemu-devel] [PATCH 0/2] migration/rdma disconnect fixes Dr. David Alan Gilbert (git)
2019-09-13 16:35 ` [Qemu-devel] [PATCH 1/2] migration/rdma: Don't moan about disconnects at the end Dr. David Alan Gilbert (git)
2019-09-13 16:35 ` [Qemu-devel] [PATCH 2/2] migration/rdma.c: Swap synchronize_rcu for call_rcu Dr. David Alan Gilbert (git)
@ 2019-09-16 2:59 ` Peter Xu
2019-09-25 10:11 ` Dr. David Alan Gilbert
3 siblings, 0 replies; 5+ messages in thread
From: Peter Xu @ 2019-09-16 2:59 UTC (permalink / raw)
To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, quintela
On Fri, Sep 13, 2019 at 05:35:05PM +0100, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> Hi,
> This fixes a deadlock that can occur on the source after
> a failed RDMA migration and cleans up some warning messages
> that can appear during normal completion.
>
> https://bugzilla.redhat.com/show_bug.cgi?id=1746787
Reviewed-by: Peter Xu <peterx@redhat.com>
--
Peter Xu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] migration/rdma disconnect fixes
2019-09-13 16:35 [Qemu-devel] [PATCH 0/2] migration/rdma disconnect fixes Dr. David Alan Gilbert (git)
` (2 preceding siblings ...)
2019-09-16 2:59 ` [Qemu-devel] [PATCH 0/2] migration/rdma disconnect fixes Peter Xu
@ 2019-09-25 10:11 ` Dr. David Alan Gilbert
3 siblings, 0 replies; 5+ messages in thread
From: Dr. David Alan Gilbert @ 2019-09-25 10:11 UTC (permalink / raw)
To: qemu-devel, quintela, peterx
* Dr. David Alan Gilbert (git) (dgilbert@redhat.com) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> Hi,
> This fixes a deadlock that can occur on the source after
> a failed RDMA migration and cleans up some warning messages
> that can appear during normal completion.
>
> https://bugzilla.redhat.com/show_bug.cgi?id=1746787
Queued
> Dr. David Alan Gilbert (2):
> migration/rdma: Don't moan about disconnects at the end
> migration/rdma.c: Swap synchronize_rcu for call_rcu
>
> migration/rdma.c | 51 +++++++++++++++++++++++++++++++++---------------
> 1 file changed, 35 insertions(+), 16 deletions(-)
>
> --
> 2.21.0
>
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-09-25 10:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-13 16:35 [Qemu-devel] [PATCH 0/2] migration/rdma disconnect fixes Dr. David Alan Gilbert (git)
2019-09-13 16:35 ` [Qemu-devel] [PATCH 1/2] migration/rdma: Don't moan about disconnects at the end Dr. David Alan Gilbert (git)
2019-09-13 16:35 ` [Qemu-devel] [PATCH 2/2] migration/rdma.c: Swap synchronize_rcu for call_rcu Dr. David Alan Gilbert (git)
2019-09-16 2:59 ` [Qemu-devel] [PATCH 0/2] migration/rdma disconnect fixes Peter Xu
2019-09-25 10:11 ` Dr. David Alan Gilbert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).