migration/multifd: trivial cleanup for multifd
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
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
@@ -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
Re: [PATCH 1/4] migration/multifd: fix a typo in comment of multifd_recv_unfill_packet()
Quoted 10 lines · Wei Yang
Signed-off-by Wei Yang <[email protected]>--- migration/ram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)migration/ram.c +0
-0
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 ) {
PATCH 2/4 migration/multifd: use pages->allocated instead of the static max
In reply to Wei Yangmultifd_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
@@ -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
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 fillpages->allocatedinstead of static max value, especially we want to support flexible packet size.Signed-off-by Wei Yang <[email protected]>
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.
PATCH 3/4 migration/multifd: initialize packet->magic/version once at setup stage
In reply to Wei YangMultiFDPacket_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
@@ -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
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.
Signed-off-by Wei Yang <[email protected]>
It don't really matter, and is faster your way O:-)
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.
Signed-off-by Wei Yang <[email protected]>Reviewed-by Juan Quintela <[email protected]>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
PATCH 4/4 migration/multifd: pages->used would be cleared when attach to multifd_send_state
In reply to Wei YangWhen 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
@@ -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
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(), itspages->usedis cleared and then attached tomultifd_send_state.It is not necessary to do this twice.
Signed-off-by Wei Yang <[email protected]>
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: usepages->allocatedinstead of the static max migration/multifd: initialize packet->magic/version once at setup
stage
migration/multifd:pages->usedwould 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