qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] migration/multifd: trivial cleanup for multifd
@ 2019-10-11  8:50 Wei Yang
  2019-10-11  8:50 ` [PATCH 1/4] migration/multifd: fix a typo in comment of multifd_recv_unfill_packet() Wei Yang
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Wei Yang @ 2019-10-11  8:50 UTC (permalink / raw)
  To: quintela, dgilbert; +Cc: qemu-devel, Wei Yang

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(-)

-- 
2.17.1



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/4] migration/multifd: fix a typo in comment of multifd_recv_unfill_packet()
  2019-10-11  8:50 [PATCH 0/4] migration/multifd: trivial cleanup for multifd Wei Yang
@ 2019-10-11  8:50 ` Wei Yang
  2019-10-11  9:44   ` Juan Quintela
  2019-10-11  8:50 ` [PATCH 2/4] migration/multifd: use pages->allocated instead of the static max Wei Yang
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Wei Yang @ 2019-10-11  8:50 UTC (permalink / raw)
  To: quintela, dgilbert; +Cc: qemu-devel, Wei Yang

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 migration/ram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/migration/ram.c b/migration/ram.c
index 22423f08cd..cf30171f44 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -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) {
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/4] migration/multifd: use pages->allocated instead of the static max
  2019-10-11  8:50 [PATCH 0/4] migration/multifd: trivial cleanup for multifd Wei Yang
  2019-10-11  8:50 ` [PATCH 1/4] migration/multifd: fix a typo in comment of multifd_recv_unfill_packet() Wei Yang
@ 2019-10-11  8:50 ` Wei Yang
  2019-10-11 10:31   ` Juan Quintela
  2019-10-11  8:50 ` [PATCH 3/4] migration/multifd: initialize packet->magic/version once at setup stage Wei Yang
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Wei Yang @ 2019-10-11  8:50 UTC (permalink / raw)
  To: quintela, dgilbert; +Cc: qemu-devel, 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.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 migration/ram.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index cf30171f44..6a3bef0434 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -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);
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/4] migration/multifd: initialize packet->magic/version once at setup stage
  2019-10-11  8:50 [PATCH 0/4] migration/multifd: trivial cleanup for multifd Wei Yang
  2019-10-11  8:50 ` [PATCH 1/4] migration/multifd: fix a typo in comment of multifd_recv_unfill_packet() Wei Yang
  2019-10-11  8:50 ` [PATCH 2/4] migration/multifd: use pages->allocated instead of the static max Wei Yang
@ 2019-10-11  8:50 ` Wei Yang
  2019-10-11 10:20   ` Juan Quintela
  2019-10-11  8:50 ` [PATCH 4/4] migration/multifd: pages->used would be cleared when attach to multifd_send_state Wei Yang
  2019-10-11 14:02 ` [PATCH 0/4] migration/multifd: trivial cleanup for multifd Dr. David Alan Gilbert
  4 siblings, 1 reply; 11+ messages in thread
From: Wei Yang @ 2019-10-11  8:50 UTC (permalink / raw)
  To: quintela, dgilbert; +Cc: qemu-devel, 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 <richardw.yang@linux.intel.com>
---
 migration/ram.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index 6a3bef0434..71d845b851 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -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);
     }
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/4] migration/multifd: pages->used would be cleared when attach to multifd_send_state
  2019-10-11  8:50 [PATCH 0/4] migration/multifd: trivial cleanup for multifd Wei Yang
                   ` (2 preceding siblings ...)
  2019-10-11  8:50 ` [PATCH 3/4] migration/multifd: initialize packet->magic/version once at setup stage Wei Yang
@ 2019-10-11  8:50 ` Wei Yang
  2019-10-11 10:24   ` Juan Quintela
  2019-10-11 14:02 ` [PATCH 0/4] migration/multifd: trivial cleanup for multifd Dr. David Alan Gilbert
  4 siblings, 1 reply; 11+ messages in thread
From: Wei Yang @ 2019-10-11  8:50 UTC (permalink / raw)
  To: quintela, dgilbert; +Cc: qemu-devel, 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.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 migration/ram.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/migration/ram.c b/migration/ram.c
index 71d845b851..051de77d5a 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -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,
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/4] migration/multifd: fix a typo in comment of multifd_recv_unfill_packet()
  2019-10-11  8:50 ` [PATCH 1/4] migration/multifd: fix a typo in comment of multifd_recv_unfill_packet() Wei Yang
@ 2019-10-11  9:44   ` Juan Quintela
  0 siblings, 0 replies; 11+ messages in thread
From: Juan Quintela @ 2019-10-11  9:44 UTC (permalink / raw)
  To: Wei Yang; +Cc: dgilbert, qemu-devel

Wei Yang <richardw.yang@linux.intel.com> wrote:
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> ---
>  migration/ram.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/migration/ram.c b/migration/ram.c
> index 22423f08cd..cf30171f44 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -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) {

Reviewed-by: Juan Quintela <quintela@redhat.com>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] migration/multifd: initialize packet->magic/version once at setup stage
  2019-10-11  8:50 ` [PATCH 3/4] migration/multifd: initialize packet->magic/version once at setup stage Wei Yang
@ 2019-10-11 10:20   ` Juan Quintela
  2019-10-11 12:17     ` Wei Yang
  0 siblings, 1 reply; 11+ messages in thread
From: Juan Quintela @ 2019-10-11 10:20 UTC (permalink / raw)
  To: Wei Yang; +Cc: dgilbert, qemu-devel

Wei Yang <richardw.yang@linux.intel.com> wrote:
> MultiFDPacket_t's magic and version field never changes during
> migration, so move these two fields in setup stage.
>
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/4] migration/multifd: pages->used would be cleared when attach to multifd_send_state
  2019-10-11  8:50 ` [PATCH 4/4] migration/multifd: pages->used would be cleared when attach to multifd_send_state Wei Yang
@ 2019-10-11 10:24   ` Juan Quintela
  0 siblings, 0 replies; 11+ messages in thread
From: Juan Quintela @ 2019-10-11 10:24 UTC (permalink / raw)
  To: Wei Yang; +Cc: dgilbert, qemu-devel

Wei Yang <richardw.yang@linux.intel.com> wrote:
> 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.
>
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] migration/multifd: use pages->allocated instead of the static max
  2019-10-11  8:50 ` [PATCH 2/4] migration/multifd: use pages->allocated instead of the static max Wei Yang
@ 2019-10-11 10:31   ` Juan Quintela
  0 siblings, 0 replies; 11+ messages in thread
From: Juan Quintela @ 2019-10-11 10:31 UTC (permalink / raw)
  To: Wei Yang; +Cc: dgilbert, qemu-devel

Wei Yang <richardw.yang@linux.intel.com> wrote:
> 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.
>
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>

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.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] migration/multifd: initialize packet->magic/version once at setup stage
  2019-10-11 10:20   ` Juan Quintela
@ 2019-10-11 12:17     ` Wei Yang
  0 siblings, 0 replies; 11+ messages in thread
From: Wei Yang @ 2019-10-11 12:17 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel, Wei Yang, dgilbert

On Fri, Oct 11, 2019 at 12:20:48PM +0200, Juan Quintela wrote:
>Wei Yang <richardw.yang@linux.intel.com> wrote:
>> MultiFDPacket_t's magic and version field never changes during
>> migration, so move these two fields in setup stage.
>>
>> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>
>Reviewed-by: Juan Quintela <quintela@redhat.com>
>
>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?

-- 
Wei Yang
Help you, Help me


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/4] migration/multifd: trivial cleanup for multifd
  2019-10-11  8:50 [PATCH 0/4] migration/multifd: trivial cleanup for multifd Wei Yang
                   ` (3 preceding siblings ...)
  2019-10-11  8:50 ` [PATCH 4/4] migration/multifd: pages->used would be cleared when attach to multifd_send_state Wei Yang
@ 2019-10-11 14:02 ` Dr. David Alan Gilbert
  4 siblings, 0 replies; 11+ messages in thread
From: Dr. David Alan Gilbert @ 2019-10-11 14:02 UTC (permalink / raw)
  To: Wei Yang; +Cc: qemu-devel, quintela

* Wei Yang (richardw.yang@linux.intel.com) wrote:
> Here are four trivial cleanups related to multifd.
> 
> Fix a typo, use a proper variable and setup never changed variables only once.

Queued

> 
> 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(-)
> 
> -- 
> 2.17.1
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-10-11 14:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-11  8:50 [PATCH 0/4] migration/multifd: trivial cleanup for multifd Wei Yang
2019-10-11  8:50 ` [PATCH 1/4] migration/multifd: fix a typo in comment of multifd_recv_unfill_packet() Wei Yang
2019-10-11  9:44   ` Juan Quintela
2019-10-11  8:50 ` [PATCH 2/4] migration/multifd: use pages->allocated instead of the static max Wei Yang
2019-10-11 10:31   ` Juan Quintela
2019-10-11  8:50 ` [PATCH 3/4] migration/multifd: initialize packet->magic/version once at setup stage Wei Yang
2019-10-11 10:20   ` Juan Quintela
2019-10-11 12:17     ` Wei Yang
2019-10-11  8:50 ` [PATCH 4/4] migration/multifd: pages->used would be cleared when attach to multifd_send_state Wei Yang
2019-10-11 10:24   ` Juan Quintela
2019-10-11 14:02 ` [PATCH 0/4] migration/multifd: trivial cleanup for multifd Dr. David Alan Gilbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).