From 77568ea7f845cefc5623f7d7fb75137b5e30b956 Mon Sep 17 00:00:00 2001 From: Wei Yang Date: Tue, 4 Jun 2019 10:35:40 +0800 Subject: migration/multifd: sync packet_num after all thread are done Notification from recv thread is not ordered, which means we may be notified by one MultiFDRecvParams but adjust packet_num for another. Move the adjustment after we are sure each recv thread are sync-ed. Signed-off-by: Wei Yang Reviewed-by: Juan Quintela Reviewed-by: Peter Xu Message-Id: <20190604023540.26532-1-richardw.yang@linux.intel.com> Signed-off-by: Juan Quintela --- migration/ram.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index d3d72b6f4f..96c84f770a 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1291,15 +1291,15 @@ static void multifd_recv_sync_main(void) trace_multifd_recv_sync_main_wait(p->id); qemu_sem_wait(&multifd_recv_state->sem_sync); + } + for (i = 0; i < migrate_multifd_channels(); i++) { + MultiFDRecvParams *p = &multifd_recv_state->params[i]; + qemu_mutex_lock(&p->mutex); if (multifd_recv_state->packet_num < p->packet_num) { multifd_recv_state->packet_num = p->packet_num; } qemu_mutex_unlock(&p->mutex); - } - for (i = 0; i < migrate_multifd_channels(); i++) { - MultiFDRecvParams *p = &multifd_recv_state->params[i]; - trace_multifd_recv_sync_main_signal(p->id); qemu_sem_post(&p->sem_sync); } -- cgit v1.2.3