* [PATCH v1] migration/multifd: always post the sync semaphores when sendesr exit
@ 2023-05-24 8:09 Wei Wang
0 siblings, 0 replies; only message in thread
From: Wei Wang @ 2023-05-24 8:09 UTC (permalink / raw)
To: quintela, peterx, qemu-devel; +Cc: Wei Wang
The sem_sync and channels_ready semaphores are used by the multifd
sender threads to synchronize with the migration thread. It is possible
that one of the sender threads exits due to an error (e.g. occured when
writing to the socket). The error thread sets multifd_send_state->exiting
to force other sender threads to exit. Those threads exit (due to the
setting of multifd_send_state->exiting) won't post the sem_sync and
channels_ready semaphores, as they didn't encounter any error (i.e. ret
will be 0 when exits). In this case, if the migration thread is waiting on
the sem_sync semaphores from all the sender threads, it will wait there
forever, which is not expected.
Change the sender threads to always post the sem_sync and channels_ready
semaphores when exit. This will unblock the migration thread in the
above case to exit. If the main thread isn't waiting on the semaphores
when the sender threads exits, posting on the semaphores will just be
like a noop.
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
---
migration/multifd.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/migration/multifd.c b/migration/multifd.c
index 0bf5958a9c..1ff461675e 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -757,10 +757,8 @@ out:
* Error happen, I will exit, but I can't just leave, tell
* who pay attention to me.
*/
- if (ret != 0) {
- qemu_sem_post(&p->sem_sync);
- qemu_sem_post(&multifd_send_state->channels_ready);
- }
+ qemu_sem_post(&p->sem_sync);
+ qemu_sem_post(&multifd_send_state->channels_ready);
qemu_mutex_lock(&p->mutex);
p->running = false;
--
2.27.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-05-24 8:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-24 8:09 [PATCH v1] migration/multifd: always post the sync semaphores when sendesr exit Wei Wang
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).