Skip to contentSkip to conversation

Multifd Cleanup

PATCH NAK Wei Yang 2 participants 15 messages May 28, 2019 – Jun 4, 2019

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

cover Multifd Cleanup

Just found several small places for unused variables.

Wei Yang (4):
migration: multifd_save_setup always return 0 migration/ram.c: use same type in MultiFDPages_t to define offsest migration/ram.c: MultiFDSendParams.sem_sync is not really used migration/ram.c: multifd_send_state->count is not really used

 migration/migration.c |  7 +------
 migration/ram.c       | 11 +----------
 2 files changed, 2 insertions(+), 16 deletions(-)
Signature · 1 line
2.19.1
author
#1 lore raw

PATCH 1/4 migration: multifd_save_setup always return 0

---
 migration/migration.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
migration/migration.c +1 -6
index d0a0f68f11..3aae4f2734 100644
@@ -3336,12 +3336,7 @@ void migrate_fd_connect(MigrationState *s, Error *error_in)
         return;
     }
 
-    if (multifd_save_setup() != 0) {
-        migrate_set_state(&s->state, MIGRATION_STATUS_SETUP,
-                          MIGRATION_STATUS_FAILED);
-        migrate_fd_cleanup(s);
-        return;
-    }
+    multifd_save_setup();
     qemu_thread_create(&s->thread, "live_migration", migration_thread, s,
                        QEMU_THREAD_JOINABLE);
     s->migration_thread_running = true;
Signature · 1 line
2.19.1
#2 lore raw

Re: [Qemu-devel] [PATCH 1/4] migration: multifd_save_setup always return 0

Quoted 13 lines · Wei Yang
---
 migration/migration.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
migration/migration.c +0 -0
index d0a0f68f11..3aae4f2734 100644
@@ -3336,12 +3336,7 @@ void migrate_fd_connect(MigrationState *s, Error *error_in)
         return;
     }
 

migration/migration.c void migrate_fd_connect(MigrationState *s, Error *error_in) · line 3342

Quoted 10 lines
migration/migration.c +1 -6
-    if (multifd_save_setup() != 0) {
-        migrate_set_state(&s->state, MIGRATION_STATUS_SETUP,
-                          MIGRATION_STATUS_FAILED);
-        migrate_fd_cleanup(s);
-        return;
-    }
+    multifd_save_setup();
     qemu_thread_create(&s->thread, "live_migration", migration_thread, s,
                        QEMU_THREAD_JOINABLE);
     s->migration_thread_running = true;

Nack.

On the compression patches that are on list, multifd_save_setup() returns -1 if there is a problem when we allocate a zbuff.

author
#3 lore raw

Re: [Qemu-devel] [PATCH 1/4] migration: multifd_save_setup always return 0

Quoted 27 lines · Juan Quintela
Quoted 13 lines · Wei Yang
---
 migration/migration.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
migration/migration.c +0 -0
index d0a0f68f11..3aae4f2734 100644
@@ -3336,12 +3336,7 @@ void migrate_fd_connect(MigrationState *s, Error *error_in)
         return;
     }
 

migration/migration.c void migrate_fd_connect(MigrationState *s, Error *error_in) · line 3342

Quoted 10 lines
migration/migration.c +1 -6
-    if (multifd_save_setup() != 0) {
-        migrate_set_state(&s->state, MIGRATION_STATUS_SETUP,
-                          MIGRATION_STATUS_FAILED);
-        migrate_fd_cleanup(s);
-        return;
-    }
+    multifd_save_setup();
     qemu_thread_create(&s->thread, "live_migration", migration_thread, s,
                        QEMU_THREAD_JOINABLE);
     s->migration_thread_running = true;

Nack.

Quoted 2 lines

On the compression patches that are on list, multifd_save_setup() returns -1 if there is a problem when we allocate a zbuff.

You mean there are some patches in mail list?

Signature · 2 lines
Wei Yang
Help you, Help me
#4 lore raw

Re: [Qemu-devel] [PATCH 1/4] migration: multifd_save_setup always return 0

Quoted 28 lines · Wei Yang
Quoted 27 lines · Juan Quintela
Quoted 13 lines · Wei Yang
---
 migration/migration.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
migration/migration.c +0 -0
index d0a0f68f11..3aae4f2734 100644
@@ -3336,12 +3336,7 @@ void migrate_fd_connect(MigrationState *s, Error *error_in)
         return;
     }
 

migration/migration.c void migrate_fd_connect(MigrationState *s, Error *error_in) · line 3342

Quoted 10 lines
migration/migration.c +1 -6
-    if (multifd_save_setup() != 0) {
-        migrate_set_state(&s->state, MIGRATION_STATUS_SETUP,
-                          MIGRATION_STATUS_FAILED);
-        migrate_fd_cleanup(s);
-        return;
-    }
+    multifd_save_setup();
     qemu_thread_create(&s->thread, "live_migration", migration_thread, s,
                        QEMU_THREAD_JOINABLE);
     s->migration_thread_running = true;

Nack.

Quoted 4 lines
Quoted 2 lines

On the compression patches that are on list, multifd_save_setup() returns -1 if there is a problem when we allocate a zbuff.

You mean there are some patches in mail list?

Yeap.

#5 lore raw

Re: [Qemu-devel] [PATCH 1/4] migration: multifd_save_setup always return 0

In reply to Wei Yang
Quoted 28 lines · Wei Yang
Quoted 27 lines · Juan Quintela
Quoted 13 lines · Wei Yang
---
 migration/migration.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
migration/migration.c +0 -0
index d0a0f68f11..3aae4f2734 100644
@@ -3336,12 +3336,7 @@ void migrate_fd_connect(MigrationState *s, Error *error_in)
         return;
     }
 

migration/migration.c void migrate_fd_connect(MigrationState *s, Error *error_in) · line 3342

Quoted 10 lines
migration/migration.c +1 -6
-    if (multifd_save_setup() != 0) {
-        migrate_set_state(&s->state, MIGRATION_STATUS_SETUP,
-                          MIGRATION_STATUS_FAILED);
-        migrate_fd_cleanup(s);
-        return;
-    }
+    multifd_save_setup();
     qemu_thread_create(&s->thread, "live_migration", migration_thread, s,
                        QEMU_THREAD_JOINABLE);
     s->migration_thread_running = true;

Nack.

Quoted 4 lines
Quoted 2 lines

On the compression patches that are on list, multifd_save_setup() returns -1 if there is a problem when we allocate a zbuff.

You mean there are some patches in mail list?

Yeap.

author
#6 lore raw

PATCH 2/4 migration/ram.c: use same type in MultiFDPages_t to define offsest

In reply to Wei Yang

MultiFDPacket_t.offset is allocated to store MultiFDPages_t.offset.

It would be better to use the same type.

---
 migration/ram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
migration/ram.c +1 -1
index 4c60869226..dcf4c54eb5 100644
@@ -607,7 +607,7 @@ typedef struct {
     uint64_t packet_num;
     uint64_t unused[4];    /* Reserved for future use */
     char ramblock[256];
-    uint64_t offset[];
+    ram_addr_t offset[];
 } __attribute__((packed)) MultiFDPacket_t;
 
 typedef struct {
Signature · 1 line
2.19.1
#7 lore raw

Re: [Qemu-devel] [PATCH 2/4] migration/ram.c: use same type in MultiFDPages_t to define offsest

Quoted 14 lines · Wei Yang

MultiFDPacket_t.offset is allocated to store MultiFDPages_t.offset.

It would be better to use the same type.

---
 migration/ram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
migration/ram.c +0 -0
index 4c60869226..dcf4c54eb5 100644

migration/ram.c typedef struct { · line 613

Quoted 8 lines
migration/ram.c +1 -1
@@ -607,7 +607,7 @@ typedef struct {
     uint64_t packet_num;
     uint64_t unused[4];    /* Reserved for future use */
     char ramblock[256];
-    uint64_t offset[];
+    ram_addr_t offset[];
 } __attribute__((packed)) MultiFDPacket_t;
 
 typedef struct {

This needs a comment, but it is on purpose. We want that the value on the wire to be the same for any architecture. (Migration stream is supposed to be architecture independent). ram_addr_t is architecture dependent.

Later, Juan.

author
#8 lore raw

Re: [Qemu-devel] [PATCH 2/4] migration/ram.c: use same type in MultiFDPages_t to define offsest

Quoted 22 lines · Juan Quintela
Quoted 21 lines · Wei Yang

MultiFDPacket_t.offset is allocated to store MultiFDPages_t.offset.

It would be better to use the same type.

---
 migration/ram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
migration/ram.c +1 -1
index 4c60869226..dcf4c54eb5 100644
@@ -607,7 +607,7 @@ typedef struct {
     uint64_t packet_num;
     uint64_t unused[4];    /* Reserved for future use */
     char ramblock[256];
-    uint64_t offset[];
+    ram_addr_t offset[];
 } __attribute__((packed)) MultiFDPacket_t;
 
Quoted 7 lines

migration/ram.c typedef struct { · line 613

Quoted 1 line
migration/ram.c +0 -0
 typedef struct {

This needs a comment, but it is on purpose. We want that the value on the wire to be the same for any architecture. (Migration stream is supposed to be architecture independent). ram_addr_t is architecture dependent.

Sounds reasonable.

Quoted 1 line

Later, Juan.

Signature · 2 lines
Wei Yang
Help you, Help me
author
#9 lore raw

PATCH 3/4 migration/ram.c: MultiFDSendParams.sem_sync is not really used

In reply to Wei Yang

Besides init and destroy, MultiFDSendParams.sem_sync is not really used.

---
 migration/ram.c | 4 ----
 1 file changed, 4 deletions(-)
migration/ram.c +0 -4
index dcf4c54eb5..5d31f7bd4c 100644
@@ -661,8 +661,6 @@ 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 {
@@ -1027,7 +1025,6 @@ void multifd_save_cleanup(void)
         p->c = NULL;
         qemu_mutex_destroy(&p->mutex);
         qemu_sem_destroy(&p->sem);
-        qemu_sem_destroy(&p->sem_sync);
         g_free(p->name);
         p->name = NULL;
         multifd_pages_clear(p->pages);
@@ -1201,7 +1198,6 @@ int multifd_save_setup(void)
 
         qemu_mutex_init(&p->mutex);
         qemu_sem_init(&p->sem, 0);
-        qemu_sem_init(&p->sem_sync, 0);
         p->quit = false;
         p->pending_job = 0;
         p->id = i;
Signature · 1 line
2.19.1
Reviewed-by on v1 3/4
#10 lore raw

Re: [Qemu-devel] [PATCH 3/4] migration/ram.c: MultiFDSendParams.sem_sync is not really used

Quoted 3 lines · Wei Yang

Besides init and destroy, MultiFDSendParams.sem_sync is not really used.

I mad SendParamas and RecvParams identical, but they are different. You are right.

author
#11 lore raw

Re: [Qemu-devel] [PATCH 3/4] migration/ram.c: MultiFDSendParams.sem_sync is not really used

Quoted 9 lines · Juan Quintela
Quoted 3 lines · Wei Yang

Besides init and destroy, MultiFDSendParams.sem_sync is not really used.

I mad SendParamas and RecvParams identical, but they are different. You are right.

Thanks.

BTW, I found some interesting thing about multifd_send_state->channels_ready. By checking the value of this semaphore, it grows far beyond what we really have.

For example, we have default 2 channels which means multifd_send_state->channels_ready's value is no more than 2. But the actual value could go to more than 30.

The behavior sounds not right.

Signature · 2 lines
Wei Yang
Help you, Help me
author
#12 lore raw

PATCH 4/4 migration/ram.c: multifd_send_state->count is not really used

In reply to Wei Yang
---
 migration/ram.c | 5 -----
 1 file changed, 5 deletions(-)
migration/ram.c +0 -5
index 5d31f7bd4c..c9a9f7489b 100644
@@ -892,8 +892,6 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
 
 struct {
     MultiFDSendParams *params;
-    /* number of created threads */
-    int count;
     /* array of pages to sent */
     MultiFDPages_t *pages;
     /* syncs main thread and channels */
@@ -1171,8 +1169,6 @@ static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque)
         p->running = true;
         qemu_thread_create(&p->thread, p->name, multifd_send_thread, p,
                            QEMU_THREAD_JOINABLE);
-
-        atomic_inc(&multifd_send_state->count);
     }
 }
 
@@ -1188,7 +1184,6 @@ int multifd_save_setup(void)
     thread_count = migrate_multifd_channels();
     multifd_send_state = g_malloc0(sizeof(*multifd_send_state));
     multifd_send_state->params = g_new0(MultiFDSendParams, thread_count);
-    atomic_set(&multifd_send_state->count, 0);
     multifd_send_state->pages = multifd_pages_init(page_count);
     qemu_sem_init(&multifd_send_state->sem_sync, 0);
     qemu_sem_init(&multifd_send_state->channels_ready, 0);
Signature · 1 line
2.19.1
Reviewed-by on v1 4/4
#13 lore raw

Re: [Qemu-devel] [PATCH 4/4] migration/ram.c: multifd_send_state->count is not really used

Quoted 1 line · Wei Yang

Once upon a time, we checked how many threads were created to recover for errors, but this was wrong because one of the "missing" threads could be one different from the last one.

Thanks, Juan.

author
#14 lore raw
In reply to Wei Yang

Hi, David

Do you prefer I resend 3/4 or it is ok for you to pick up here directly?

Quoted 14 lines · Wei Yang

Just found several small places for unused variables.

Wei Yang (4):
migration: multifd_save_setup always return 0 migration/ram.c: use same type in MultiFDPages_t to define offsest migration/ram.c: MultiFDSendParams.sem_sync is not really used migration/ram.c: multifd_send_state->count is not really used

migration/migration.c | 7 +------
migration/ram.c | 11 +----------

2 files changed, 2 insertions(+), 16 deletions(-)
Signature · 1 line
2.19.1
Signature · 2 lines
Wei Yang
Help you, Help me