qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: Fabiano Rosas <farosas@suse.de>
Cc: qemu-devel@nongnu.org, Juan Quintela <quintela@redhat.com>,
	Leonardo Bras <leobras@redhat.com>
Subject: Re: [PATCH 4/5] migration/ram: Return early from save_zero_page
Date: Tue, 15 Aug 2023 18:26:58 -0400	[thread overview]
Message-ID: <ZNv7spVAEFHpdebZ@x1n> (raw)
In-Reply-To: <20230815143828.15436-5-farosas@suse.de>

On Tue, Aug 15, 2023 at 11:38:27AM -0300, Fabiano Rosas wrote:
> Invert the first conditional so we return early when len == 0. This is
> merely to make the next patch easier to read.
> 
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> ---
>  migration/ram.c | 29 +++++++++++++++--------------
>  1 file changed, 15 insertions(+), 14 deletions(-)
> 
> diff --git a/migration/ram.c b/migration/ram.c
> index a10410a1a5..8ec38f69e8 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -1169,23 +1169,24 @@ static int save_zero_page(RAMState *rs, PageSearchStatus *pss, RAMBlock *block,
>  {
>      int len = save_zero_page_to_file(pss, block, offset);
>  
> -    if (len) {
> -        stat64_add(&mig_stats.zero_pages, 1);
> -        ram_transferred_add(len);
> +    if (!len) {
> +        return -1;
> +    }
>  
> -        /*
> -         * Must let xbzrle know, otherwise a previous (now 0'd) cached
> -         * page would be stale.
> -         */
> -        if (rs->xbzrle_started) {
> -            XBZRLE_cache_lock();
> -            xbzrle_cache_zero_page(block->offset + offset);
> -            XBZRLE_cache_unlock();
> -        }
> +    stat64_add(&mig_stats.zero_pages, 1);
> +    ram_transferred_add(len);
>  
> -        return 1;
> +    /*
> +     * Must let xbzrle know, otherwise a previous (now 0'd) cached
> +     * page would be stale.
> +     */
> +    if (rs->xbzrle_started) {
> +        XBZRLE_cache_lock();
> +        xbzrle_cache_zero_page(block->offset + offset);
> +        XBZRLE_cache_unlock();
>      }
> -    return -1;
> +
> +    return 1;
>  }

Can we squash this into previous patch?

-- 
Peter Xu



  reply	other threads:[~2023-08-15 22:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-15 14:38 [PATCH 0/5] migration/ram: Merge zero page handling Fabiano Rosas
2023-08-15 14:38 ` [PATCH 1/5] migration/ram: Remove RAMState from xbzrle_cache_zero_page Fabiano Rosas
2023-08-15 22:20   ` Peter Xu
2023-08-15 14:38 ` [PATCH 2/5] migration/ram: Stop passing QEMUFile around in save_zero_page Fabiano Rosas
2023-08-15 22:22   ` Peter Xu
2023-08-15 14:38 ` [PATCH 3/5] migration/ram: Move xbzrle zero page handling into save_zero_page Fabiano Rosas
2023-08-15 22:25   ` Peter Xu
2023-08-15 23:30   ` Fabiano Rosas
2023-08-15 14:38 ` [PATCH 4/5] migration/ram: Return early from save_zero_page Fabiano Rosas
2023-08-15 22:26   ` Peter Xu [this message]
2023-08-15 14:38 ` [PATCH 5/5] migration/ram: Merge save_zero_page functions Fabiano Rosas
2023-08-15 22:32   ` Peter Xu
2023-08-15 23:28     ` Fabiano Rosas

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=ZNv7spVAEFHpdebZ@x1n \
    --to=peterx@redhat.com \
    --cc=farosas@suse.de \
    --cc=leobras@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@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).