qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: Peter Xu <peterx@redhat.com>,
	"Maciej S . Szmigiero" <mail@maciej.szmigiero.name>
Subject: Re: [PATCH v4 10/16] migration/multifd: Isolate ram pages packet data
Date: Mon, 26 Aug 2024 14:13:32 -0300	[thread overview]
Message-ID: <878qwjxl4z.fsf@suse.de> (raw)
In-Reply-To: <1c096ef1-5a61-44a2-a4ad-b3eb8e5e5b94@linaro.org>

Philippe Mathieu-Daudé <philmd@linaro.org> writes:

> On 23/8/24 19:39, Fabiano Rosas wrote:
>> While we cannot yet disentangle the multifd packet from page data, we
>> can make the code a bit cleaner by setting the page-related fields in
>> a separate function.
>> 
>> Signed-off-by: Fabiano Rosas <farosas@suse.de>
>> ---
>>   migration/multifd.c    | 99 +++++++++++++++++++++++++-----------------
>>   migration/trace-events |  5 ++-
>>   2 files changed, 63 insertions(+), 41 deletions(-)
>
>
>> -static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
>> +static int multifd_ram_unfill_packet(MultiFDRecvParams *p, Error **errp)
>>   {
>>       MultiFDPacket_t *packet = p->packet;
>>       uint32_t page_count = multifd_ram_page_count();
>>       uint32_t page_size = multifd_ram_page_size();
>>       int i;
>>   
>> -    packet->magic = be32_to_cpu(packet->magic);
>> -    if (packet->magic != MULTIFD_MAGIC) {
>> -        error_setg(errp, "multifd: received packet "
>> -                   "magic %x and expected magic %x",
>> -                   packet->magic, MULTIFD_MAGIC);
>> -        return -1;
>> -    }
>> -
>> -    packet->version = be32_to_cpu(packet->version);
>> -    if (packet->version != MULTIFD_VERSION) {
>> -        error_setg(errp, "multifd: received packet "
>> -                   "version %u and expected version %u",
>> -                   packet->version, MULTIFD_VERSION);
>> -        return -1;
>> -    }
>> -
>> -    p->flags = be32_to_cpu(packet->flags);
>> -
>>       packet->pages_alloc = be32_to_cpu(packet->pages_alloc);
>>       /*
>>        * If we received a packet that is 100 times bigger than expected
>> @@ -511,13 +507,6 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
>>           return -1;
>>       }
>>   
>> -    p->next_packet_size = be32_to_cpu(packet->next_packet_size);
>> -    p->packet_num = be64_to_cpu(packet->packet_num);
>> -    p->packets_recved++;
>> -
>> -    trace_multifd_recv(p->id, p->packet_num, p->normal_num, p->zero_num,
>> -                       p->flags, p->next_packet_size);
>> -
>>       if (p->normal_num == 0 && p->zero_num == 0) {
>>           return 0;
>>       }
>> @@ -559,6 +548,40 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
>>       return 0;
>>   }
>>   
>> +static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
>> +{
>> +    MultiFDPacket_t *packet = p->packet;
>> +    int ret = 0;
>> +
>> +    packet->magic = be32_to_cpu(packet->magic);
>> +    if (packet->magic != MULTIFD_MAGIC) {
>> +        error_setg(errp, "multifd: received packet "
>> +                   "magic %x and expected magic %x",
>> +                   packet->magic, MULTIFD_MAGIC);
>> +        return -1;
>> +    }
>> +
>> +    packet->version = be32_to_cpu(packet->version);
>> +    if (packet->version != MULTIFD_VERSION) {
>> +        error_setg(errp, "multifd: received packet "
>> +                   "version %u and expected version %u",
>> +                   packet->version, MULTIFD_VERSION);
>> +        return -1;
>> +    }
>> +
>> +    p->flags = be32_to_cpu(packet->flags);
>> +    p->next_packet_size = be32_to_cpu(packet->next_packet_size);
>> +    p->packet_num = be64_to_cpu(packet->packet_num);
>> +    p->packets_recved++;
>> +
>> +    ret = multifd_ram_unfill_packet(p, errp);
>
> Pre-existing but since you modify this code, maybe cleaner to
> "unfill" all packet fields, then check for sane magic/version
> and return error, to not let a packet half-swapped. Otherwise:

I don't even see the point of byte-swapping the packet
in-place. Probably better to have all the swaps into the variables in
the unfill function and leave the packet unchanged. I'll add another
patch to the series.

>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>
>> +
>> +    trace_multifd_recv_unfill(p->id, p->packet_num, p->flags,
>> +                              p->next_packet_size);
>> +
>> +    return ret;
>> +}


  reply	other threads:[~2024-08-26 17:14 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-23 17:38 [PATCH v4 00/16] migration/multifd: Remove multifd_send_state->pages Fabiano Rosas
2024-08-23 17:38 ` [PATCH v4 01/16] migration/multifd: Reduce access to p->pages Fabiano Rosas
2024-08-23 17:38 ` [PATCH v4 02/16] migration/multifd: Inline page_size and page_count Fabiano Rosas
2024-08-23 17:38 ` [PATCH v4 03/16] migration/multifd: Remove pages->allocated Fabiano Rosas
2024-08-23 17:38 ` [PATCH v4 04/16] migration/multifd: Pass in MultiFDPages_t to file_write_ramblock_iov Fabiano Rosas
2024-08-23 17:39 ` [PATCH v4 05/16] migration/multifd: Introduce MultiFDSendData Fabiano Rosas
2024-08-23 17:39 ` [PATCH v4 06/16] migration/multifd: Make MultiFDPages_t:offset a flexible array member Fabiano Rosas
2024-08-23 17:39 ` [PATCH v4 07/16] migration/multifd: Replace p->pages with an union pointer Fabiano Rosas
2024-08-23 17:39 ` [PATCH v4 08/16] migration/multifd: Move pages accounting into multifd_send_zero_page_detect() Fabiano Rosas
2024-08-23 17:39 ` [PATCH v4 09/16] migration/multifd: Remove total pages tracing Fabiano Rosas
2024-08-26 15:53   ` Peter Xu
2024-08-23 17:39 ` [PATCH v4 10/16] migration/multifd: Isolate ram pages packet data Fabiano Rosas
2024-08-26  6:23   ` Philippe Mathieu-Daudé
2024-08-26 17:13     ` Fabiano Rosas [this message]
2024-08-26 16:06   ` Peter Xu
2024-08-23 17:39 ` [PATCH v4 11/16] migration/multifd: Don't send ram data during SYNC Fabiano Rosas
2024-08-23 17:39 ` [PATCH v4 12/16] migration/multifd: Replace multifd_send_state->pages with client data Fabiano Rosas
2024-08-23 17:39 ` [PATCH v4 13/16] migration/multifd: Allow multifd sync without flush Fabiano Rosas
2024-08-23 17:39 ` [PATCH v4 14/16] migration/multifd: Standardize on multifd ops names Fabiano Rosas
2024-08-26 16:14   ` Peter Xu
2024-08-26 17:16     ` Fabiano Rosas
2024-08-23 17:39 ` [PATCH v4 15/16] migration/multifd: Register nocomp ops dynamically Fabiano Rosas
2024-08-26  6:32   ` Philippe Mathieu-Daudé
2024-08-26 11:18   ` Prasad Pandit
2024-08-26 16:15   ` Peter Xu
2024-08-23 17:39 ` [PATCH v4 16/16] migration/multifd: Move nocomp code into multifd-nocomp.c Fabiano Rosas
2024-08-26 16:16   ` Peter Xu

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=878qwjxl4z.fsf@suse.de \
    --to=farosas@suse.de \
    --cc=mail@maciej.szmigiero.name \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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).