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 5/5] migration/ram: Merge save_zero_page functions
Date: Tue, 15 Aug 2023 18:32:08 -0400 [thread overview]
Message-ID: <ZNv86AwQoEzJ5eY6@x1n> (raw)
In-Reply-To: <20230815143828.15436-6-farosas@suse.de>
On Tue, Aug 15, 2023 at 11:38:28AM -0300, Fabiano Rosas wrote:
> We don't need to do this in two pieces. One single function makes it
> easier to grasp, specially since it removes the indirection on the
> return value handling.
>
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> ---
> migration/ram.c | 41 +++++++++++------------------------------
> 1 file changed, 11 insertions(+), 30 deletions(-)
>
> diff --git a/migration/ram.c b/migration/ram.c
> index 8ec38f69e8..13935ead1c 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -1128,32 +1128,6 @@ void ram_release_page(const char *rbname, uint64_t offset)
> ram_discard_range(rbname, offset, TARGET_PAGE_SIZE);
> }
>
> -/**
> - * save_zero_page_to_file: send the zero page to the file
> - *
> - * Returns the size of data written to the file, 0 means the page is not
> - * a zero page
> - *
> - * @pss: current PSS channel
> - * @block: block that contains the page we want to send
> - * @offset: offset inside the block for the page
> - */
> -static int save_zero_page_to_file(PageSearchStatus *pss, RAMBlock *block,
> - ram_addr_t offset)
> -{
> - uint8_t *p = block->host + offset;
> - QEMUFile *file = pss->pss_channel;
> - int len = 0;
> -
> - if (buffer_is_zero(p, TARGET_PAGE_SIZE)) {
> - len += save_page_header(pss, file, block, offset | RAM_SAVE_FLAG_ZERO);
> - qemu_put_byte(file, 0);
> - len += 1;
> - ram_release_page(block->idstr, offset);
> - }
> - return len;
> -}
> -
> /**
> * save_zero_page: send the zero page to the stream
> *
> @@ -1167,12 +1141,19 @@ static int save_zero_page_to_file(PageSearchStatus *pss, RAMBlock *block,
> static int save_zero_page(RAMState *rs, PageSearchStatus *pss, RAMBlock *block,
> ram_addr_t offset)
> {
> - int len = save_zero_page_to_file(pss, block, offset);
> + uint8_t *p = block->host + offset;
> + QEMUFile *file = pss->pss_channel;
> + int len = 0;
>
> - if (!len) {
> - return -1;
> + if (!buffer_is_zero(p, TARGET_PAGE_SIZE)) {
> + return 0;
> }
>
> + len += save_page_header(pss, file, block, offset | RAM_SAVE_FLAG_ZERO);
> + qemu_put_byte(file, 0);
> + len += 1;
> + ram_release_page(block->idstr, offset);
> +
> stat64_add(&mig_stats.zero_pages, 1);
> ram_transferred_add(len);
>
> @@ -1186,7 +1167,7 @@ static int save_zero_page(RAMState *rs, PageSearchStatus *pss, RAMBlock *block,
> XBZRLE_cache_unlock();
> }
>
> - return 1;
> + return len;
I don't think it's correct.. We need to keep the retval definition (how
many pages were sent) rather than returning num of bytes, I think.
I'm curious how did this pass any form of test.. because I think we did
assert that:
/* Be strict to return code; it must be 1, or what else? */
if (migration_ops->ram_save_target_page(rs, pss) != 1) {
error_report_once("%s: ram_save_target_page failed", __func__);
ret = -1;
goto out;
}
Did I miss something?
--
Peter Xu
next prev parent reply other threads:[~2023-08-15 22:32 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
2023-08-15 14:38 ` [PATCH 5/5] migration/ram: Merge save_zero_page functions Fabiano Rosas
2023-08-15 22:32 ` Peter Xu [this message]
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=ZNv86AwQoEzJ5eY6@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).