Skip to contentSkip to conversation

migration/multifd: trivial cleanup for multifd

PATCH In review Wei Yang 4 participants 11 messages Oct 11, 2019

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

cover migration/multifd: trivial cleanup for multifd

Here are four trivial cleanups related to multifd.

Fix a typo, use a proper variable and setup never changed variables only once.

Wei Yang (4):
migration/multifd: fix a typo in comment of
multifd_recv_unfill_packet()
migration/multifd: use pages->allocated instead of the static max migration/multifd: initialize packet->magic/version once at setup
stage
migration/multifd: pages->used would be cleared when attach to
multifd_send_state

 migration/ram.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/4 migration/multifd: fix a typo in comment of multifd_recv_unfill_packet()

---
 migration/ram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
migration/ram.c +1 -1
index 22423f08cd..cf30171f44 100644
@@ -838,7 +838,7 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
 
     packet->pages_alloc = be32_to_cpu(packet->pages_alloc);
     /*
-     * If we recevied a packet that is 100 times bigger than expected
+     * If we received a packet that is 100 times bigger than expected
      * just stop migration.  It is a magic number.
      */
     if (packet->pages_alloc > pages_max * 100) {
Signature · 1 line
2.17.1
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] migration/multifd: fix a typo in comment of multifd_recv_unfill_packet()

Quoted 10 lines · Wei Yang
---
 migration/ram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
migration/ram.c +0 -0
index 22423f08cd..cf30171f44 100644

migration/ram.c static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp) · line 844

Quoted 8 lines
migration/ram.c +1 -1
@@ -838,7 +838,7 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
 
     packet->pages_alloc = be32_to_cpu(packet->pages_alloc);
     /*
-     * If we recevied a packet that is 100 times bigger than expected
+     * If we received a packet that is 100 times bigger than expected
      * just stop migration.  It is a magic number.
      */
     if (packet->pages_alloc > pages_max * 100) {
author
#3 lore raw

PATCH 2/4 migration/multifd: use pages->allocated instead of the static max

In reply to Wei Yang

multifd_send_fill_packet() prepares meta data for following pages to transfer. It would be more proper to fill pages->allocated instead of static max value, especially we want to support flexible packet size.

---
 migration/ram.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
migration/ram.c +1 -2
index cf30171f44..6a3bef0434 100644
@@ -791,13 +791,12 @@ static void multifd_pages_clear(MultiFDPages_t *pages)
 static void multifd_send_fill_packet(MultiFDSendParams *p)
 {
     MultiFDPacket_t *packet = p->packet;
-    uint32_t page_max = MULTIFD_PACKET_SIZE / qemu_target_page_size();
     int i;
 
     packet->magic = cpu_to_be32(MULTIFD_MAGIC);
     packet->version = cpu_to_be32(MULTIFD_VERSION);
     packet->flags = cpu_to_be32(p->flags);
-    packet->pages_alloc = cpu_to_be32(page_max);
+    packet->pages_alloc = cpu_to_be32(p->pages->allocated);
     packet->pages_used = cpu_to_be32(p->pages->used);
     packet->next_packet_size = cpu_to_be32(p->next_packet_size);
     packet->packet_num = cpu_to_be64(p->packet_num);
Signature · 1 line
2.17.1
Reviewed-by on v1 2/4
#4 lore raw

Re: [PATCH 2/4] migration/multifd: use pages->allocated instead of the static max

Quoted 5 lines · Wei Yang

multifd_send_fill_packet() prepares meta data for following pages to transfer. It would be more proper to fill pages->allocated instead of static max value, especially we want to support flexible packet size.

It don't really matters. We send full packets except the last one or somesuch extern reason. Only makes a difference if for that channel only is sent a partial packet.

author
#5 lore raw

PATCH 3/4 migration/multifd: initialize packet->magic/version once at setup stage

In reply to Wei Yang

MultiFDPacket_t's magic and version field never changes during migration, so move these two fields in setup stage.

---
 migration/ram.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
migration/ram.c +2 -2
index 6a3bef0434..71d845b851 100644
@@ -793,8 +793,6 @@ static void multifd_send_fill_packet(MultiFDSendParams *p)
     MultiFDPacket_t *packet = p->packet;
     int i;
 
-    packet->magic = cpu_to_be32(MULTIFD_MAGIC);
-    packet->version = cpu_to_be32(MULTIFD_VERSION);
     packet->flags = cpu_to_be32(p->flags);
     packet->pages_alloc = cpu_to_be32(p->pages->allocated);
     packet->pages_used = cpu_to_be32(p->pages->used);
@@ -1240,6 +1238,8 @@ int multifd_save_setup(void)
         p->packet_len = sizeof(MultiFDPacket_t)
                       + sizeof(ram_addr_t) * page_count;
         p->packet = g_malloc0(p->packet_len);
+        p->packet->magic = cpu_to_be32(MULTIFD_MAGIC);
+        p->packet->version = cpu_to_be32(MULTIFD_VERSION);
         p->name = g_strdup_printf("multifdsend_%d", i);
         socket_send_channel_create(multifd_new_send_channel_async, p);
     }
Signature · 1 line
2.17.1
Reviewed-by on v1 3/4
#6 lore raw

Re: [PATCH 3/4] migration/multifd: initialize packet->magic/version once at setup stage

Quoted 4 lines · Wei Yang

MultiFDPacket_t's magic and version field never changes during migration, so move these two fields in setup stage.

It don't really matter, and is faster your way O:-)

#7 lore raw

Re: [PATCH 3/4] migration/multifd: initialize packet->magic/version once at setup stage

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

MultiFDPacket_t's magic and version field never changes during migration, so move these two fields in setup stage.

It don't really matter, and is faster your way O:-)

You are right.

And I am wondering one more thing. Why we need to carry magic/version for each packet? Would it be better to just carry and check magic/version for the initial packet only?

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

PATCH 4/4 migration/multifd: pages->used would be cleared when attach to multifd_send_state

In reply to Wei Yang

When we found an available channel in multifd_send_pages(), its pages->used is cleared and then attached to multifd_send_state.

It is not necessary to do this twice.

---
 migration/ram.c | 1 -
 1 file changed, 1 deletion(-)
migration/ram.c +0 -1
index 71d845b851..051de77d5a 100644
@@ -1129,7 +1129,6 @@ static void *multifd_send_thread(void *opaque)
             p->flags = 0;
             p->num_packets++;
             p->num_pages += used;
-            p->pages->used = 0;
             qemu_mutex_unlock(&p->mutex);
 
             trace_multifd_send(p->id, packet_num, used, flags,
Signature · 1 line
2.17.1
Reviewed-by on v1 4/4
#9 lore raw

Re: [PATCH 4/4] migration/multifd: pages->used would be cleared when attach to multifd_send_state

Quoted 6 lines · Wei Yang

When we found an available channel in multifd_send_pages(), its pages->used is cleared and then attached to multifd_send_state.

It is not necessary to do this twice.

#10 lore raw
In reply to Wei Yang
Quoted 3 lines · * Wei Yang ([email protected]) wrote:

Here are four trivial cleanups related to multifd.

Fix a typo, use a proper variable and setup never changed variables only once.

Queued

Quoted 10 lines

Wei Yang (4):
migration/multifd: fix a typo in comment of
multifd_recv_unfill_packet()
migration/multifd: use pages->allocated instead of the static max migration/multifd: initialize packet->magic/version once at setup
stage
migration/multifd: pages->used would be cleared when attach to
multifd_send_state

Quoted 7 lines
 migration/ram.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
Signature · 1 line
2.17.1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK