From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org, Thomas Huth <thuth@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Eric Blake <eblake@redhat.com>,
Laurent Vivier <lvivier@redhat.com>,
Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 5/8] multifd: Be flexible about packet size
Date: Thu, 21 Feb 2019 18:30:21 +0000 [thread overview]
Message-ID: <20190221183020.GO2605@work-vm> (raw)
In-Reply-To: <20190220115611.3192-6-quintela@redhat.com>
* Juan Quintela (quintela@redhat.com) wrote:
> This way we can change the packet size in the future and everything
> will work. We choose an arbitrary big number (100 times configured
> size) as a limit about how big we will reallocate.
>
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
> migration/ram.c | 24 ++++++++++++++++++------
> 1 file changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/migration/ram.c b/migration/ram.c
> index e22d02760b..75a8fc21f8 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -723,13 +723,13 @@ static void multifd_pages_clear(MultiFDPages_t *pages)
> static void multifd_send_fill_packet(MultiFDSendParams *p)
> {
> MultiFDPacket_t *packet = p->packet;
> - uint32_t page_count = MULTIFD_PACKET_SIZE / qemu_target_page_size();
> + 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_count);
> + packet->pages_alloc = cpu_to_be32(page_max);
> 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);
> @@ -746,7 +746,7 @@ static void multifd_send_fill_packet(MultiFDSendParams *p)
> static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
> {
> MultiFDPacket_t *packet = p->packet;
> - uint32_t page_count = MULTIFD_PACKET_SIZE / qemu_target_page_size();
> + uint32_t pages_max = MULTIFD_PACKET_SIZE / qemu_target_page_size();
> RAMBlock *block;
> int i;
>
> @@ -769,12 +769,24 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
> p->flags = be32_to_cpu(packet->flags);
>
> packet->pages_alloc = be32_to_cpu(packet->pages_alloc);
> - if (packet->pages_alloc > page_count) {
> + /*
> + * If we recevied a packet that is 100 times bigger than expected
> + * just stop migration. It is a magic number.
> + */
> + if (packet->pages_alloc > pages_max * 100) {
> error_setg(errp, "multifd: received packet "
> - "with size %d and expected maximum size %d",
> - packet->pages_alloc, page_count) ;
> + "with size %d and expected size %d",
> + packet->pages_alloc, pages_max) ;
Should that end with pages_max * 100 ?
> return -1;
> }
> + /*
> + * We received a packet that is bigger than expected but inside
> + * reasonable limits (see previous comment). Just reallocate.
> + */
> + if (packet->pages_alloc > p->pages->allocated) {
> + multifd_pages_clear(p->pages);
> + multifd_pages_init(packet->pages_alloc);
> + }
>
> p->pages->used = be32_to_cpu(packet->pages_used);
> if (p->pages->used > packet->pages_alloc) {
Other than that error message, I think it's OK, although the names get
very confusing (max, alloc, allocated)
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> --
> 2.20.1
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2019-02-21 18:31 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-20 11:56 [Qemu-devel] [PATCH v2 0/8] migration: Make multifd not experimental Juan Quintela
2019-02-20 11:56 ` [Qemu-devel] [PATCH v2 1/8] multifd: Only send pages when packet are not empty Juan Quintela
2019-02-21 17:43 ` Dr. David Alan Gilbert
2019-02-20 11:56 ` [Qemu-devel] [PATCH v2 2/8] multifd: Rename "size" member to pages_alloc Juan Quintela
2019-02-21 17:48 ` Dr. David Alan Gilbert
2019-02-20 11:56 ` [Qemu-devel] [PATCH v2 3/8] multifd: Create new next_packet_size field Juan Quintela
2019-02-21 18:45 ` Dr. David Alan Gilbert
2019-02-27 11:02 ` Juan Quintela
2019-02-20 11:56 ` [Qemu-devel] [PATCH v2 4/8] multifd: Drop x-multifd-page-count parameter Juan Quintela
2019-02-21 17:51 ` Dr. David Alan Gilbert
2019-02-20 11:56 ` [Qemu-devel] [PATCH v2 5/8] multifd: Be flexible about packet size Juan Quintela
2019-02-21 18:30 ` Dr. David Alan Gilbert [this message]
2019-02-27 11:06 ` Juan Quintela
2019-02-20 11:56 ` [Qemu-devel] [PATCH v2 6/8] multifd: Change default " Juan Quintela
2019-02-21 18:40 ` Dr. David Alan Gilbert
2019-02-20 11:56 ` [Qemu-devel] [PATCH v2 7/8] multifd: Drop x- Juan Quintela
2019-02-20 11:56 ` [Qemu-devel] [PATCH v2 8/8] tests: Add migration multifd test Juan Quintela
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190221183020.GO2605@work-vm \
--to=dgilbert@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).