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 <richardw.yang@linux.intel.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Message-Id: <20190604023540.26532-1-richardw.yang@linux.intel.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
Wei Yang 2019-06-04 10:35:40 +08:00 committed by Juan Quintela
parent 7c960d617a
commit 77568ea7f8
1 changed files with 4 additions and 4 deletions

View File

@ -1291,15 +1291,15 @@ static void multifd_recv_sync_main(void)
trace_multifd_recv_sync_main_wait(p->id); trace_multifd_recv_sync_main_wait(p->id);
qemu_sem_wait(&multifd_recv_state->sem_sync); 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); qemu_mutex_lock(&p->mutex);
if (multifd_recv_state->packet_num < p->packet_num) { if (multifd_recv_state->packet_num < p->packet_num) {
multifd_recv_state->packet_num = p->packet_num; multifd_recv_state->packet_num = p->packet_num;
} }
qemu_mutex_unlock(&p->mutex); 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); trace_multifd_recv_sync_main_signal(p->id);
qemu_sem_post(&p->sem_sync); qemu_sem_post(&p->sem_sync);
} }