Message ID | 20230524080906.531440-1-wei.w.wang@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v1] migration/multifd: always post the sync semaphores when sendesr exit | expand |
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;
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(-)