* Juan Quintela (quint...@redhat.com) wrote:
> This makes easy to debug things because when you want for all threads
> to arrive at that semaphore, you know which one your are waiting for.
>
> Signed-off-by: Juan Quintela
Reviewed-by: Dr. David Alan Gilbert
and queued.
> ---
> migration/ram.c | 14 +++---
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/migration/ram.c b/migration/ram.c
> index ca11d43e30..4bdd201a4e 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -661,6 +661,8 @@ typedef struct {
> uint64_t num_packets;
> /* pages sent through this channel */
> uint64_t num_pages;
> +/* syncs main thread and channels */
> +QemuSemaphore sem_sync;
> } MultiFDSendParams;
>
> typedef struct {
> @@ -896,8 +898,6 @@ struct {
> MultiFDSendParams *params;
> /* array of pages to sent */
> MultiFDPages_t *pages;
> -/* syncs main thread and channels */
> -QemuSemaphore sem_sync;
> /* global number of generated multifd packets */
> uint64_t packet_num;
> /* send channels ready */
> @@ -1038,6 +1038,7 @@ void multifd_save_cleanup(void)
> p->c = NULL;
> qemu_mutex_destroy(>mutex);
> qemu_sem_destroy(>sem);
> +qemu_sem_destroy(>sem_sync);
> g_free(p->name);
> p->name = NULL;
> multifd_pages_clear(p->pages);
> @@ -1047,7 +1048,6 @@ void multifd_save_cleanup(void)
> p->packet = NULL;
> }
> qemu_sem_destroy(_send_state->channels_ready);
> -qemu_sem_destroy(_send_state->sem_sync);
> g_free(multifd_send_state->params);
> multifd_send_state->params = NULL;
> multifd_pages_clear(multifd_send_state->pages);
> @@ -1092,7 +1092,7 @@ static void multifd_send_sync_main(void)
> MultiFDSendParams *p = _send_state->params[i];
>
> trace_multifd_send_sync_main_wait(p->id);
> -qemu_sem_wait(_send_state->sem_sync);
> +qemu_sem_wait(>sem_sync);
> }
> trace_multifd_send_sync_main(multifd_send_state->packet_num);
> }
> @@ -1152,7 +1152,7 @@ static void *multifd_send_thread(void *opaque)
> qemu_mutex_unlock(>mutex);
>
> if (flags & MULTIFD_FLAG_SYNC) {
> -qemu_sem_post(_send_state->sem_sync);
> +qemu_sem_post(>sem_sync);
> }
> qemu_sem_post(_send_state->channels_ready);
> } else if (p->quit) {
> @@ -1175,7 +1175,7 @@ out:
> */
> if (ret != 0) {
> if (flags & MULTIFD_FLAG_SYNC) {
> -qemu_sem_post(_send_state->sem_sync);
> +qemu_sem_post(>sem_sync);
> }
> qemu_sem_post(_send_state->channels_ready);
> }
> @@ -1221,7 +1221,6 @@ int multifd_save_setup(void)
> multifd_send_state = g_malloc0(sizeof(*multifd_send_state));
> multifd_send_state->params = g_new0(MultiFDSendParams, thread_count);
> multifd_send_state->pages = multifd_pages_init(page_count);
> -qemu_sem_init(_send_state->sem_sync, 0);
> qemu_sem_init(_send_state->channels_ready, 0);
>
> for (i = 0; i < thread_count; i++) {
> @@ -1229,6 +1228,7 @@ int multifd_save_setup(void)
>
> qemu_mutex_init(>mutex);
> qemu_sem_init(>sem, 0);
> +qemu_sem_init(>sem_sync, 0);
> p->quit = false;
> p->pending_job = 0;
> p->id = i;
> --
> 2.21.0
>
--
Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK