From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
Stefan Hajnoczi <stefanha@redhat.com>,
Leonardo Bras <leobras@redhat.com>, Fam Zheng <fam@euphon.net>,
Peter Xu <peterx@redhat.com>
Subject: Re: [PATCH 9/9] qemu-file: Account for rate_limit usage on qemu_fflush()
Date: Thu, 4 May 2023 17:58:39 +0100 [thread overview]
Message-ID: <ZFPkP58QSrkm6riX@redhat.com> (raw)
In-Reply-To: <20230504113841.23130-10-quintela@redhat.com>
On Thu, May 04, 2023 at 01:38:41PM +0200, Juan Quintela wrote:
> That is the moment we know we have transferred something.
>
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
> migration/qemu-file.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/migration/qemu-file.c b/migration/qemu-file.c
> index ddebfac847..309b4c56f4 100644
> --- a/migration/qemu-file.c
> +++ b/migration/qemu-file.c
> @@ -300,7 +300,9 @@ void qemu_fflush(QEMUFile *f)
> &local_error) < 0) {
> qemu_file_set_error_obj(f, -EIO, local_error);
> } else {
> - f->total_transferred += iov_size(f->iov, f->iovcnt);
> + uint64_t size = iov_size(f->iov, f->iovcnt);
> + qemu_file_acct_rate_limit(f, size);
> + f->total_transferred += size;
> }
>
> qemu_iovec_release_ram(f);
> @@ -527,7 +529,6 @@ void qemu_put_buffer_async(QEMUFile *f, const uint8_t *buf, size_t size,
> return;
> }
>
> - f->rate_limit_used += size;
> add_to_iovec(f, buf, size, may_free);
> }
>
> @@ -545,7 +546,6 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size)
> l = size;
> }
> memcpy(f->buf + f->buf_index, buf, l);
> - f->rate_limit_used += l;
> add_buf_to_iovec(f, l);
> if (qemu_file_get_error(f)) {
> break;
> @@ -562,7 +562,6 @@ void qemu_put_byte(QEMUFile *f, int v)
> }
>
> f->buf[f->buf_index] = v;
> - f->rate_limit_used++;
> add_buf_to_iovec(f, 1);
> }
This has a slight semantic behavioural change.
By accounting for rate limit in the qemu_put functions, we ensure
that we stop growing the iovec when rate limiting activates.
If we only apply rate limit in the the flush function, that will
let the f->iov continue to accumulate buffers, while we have
rate limited the actual transfer. This makes me uneasy - it feels
like a bad idea to continue to accumulate buffers if we're not
ready to send them
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2023-05-04 17:44 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-04 11:38 [PATCH 0/9] QEMU file cleanups Juan Quintela
2023-05-04 11:38 ` [PATCH 1/9] migration: max_postcopy_bandwidth is a size parameter Juan Quintela
2023-05-04 16:48 ` Daniel P. Berrangé
2023-05-04 11:38 ` [PATCH 2/9] migration: qemu_file_total_transferred() function is monotonic Juan Quintela
2023-05-04 16:49 ` Daniel P. Berrangé
2023-05-04 11:38 ` [PATCH 3/9] qemu-file: make qemu_file_[sg]et_rate_limit() use an uint64_t Juan Quintela
2023-05-04 16:50 ` Daniel P. Berrangé
2023-05-04 23:59 ` Juan Quintela
2023-05-04 11:38 ` [PATCH 4/9] qemu-file: Make rate_limit_used " Juan Quintela
2023-05-04 16:51 ` Daniel P. Berrangé
2023-05-04 11:38 ` [PATCH 5/9] qemu-file: No need to check for shutdown in qemu_file_rate_limit Juan Quintela
2023-05-04 14:27 ` Peter Xu
2023-05-04 16:51 ` Daniel P. Berrangé
2023-05-04 11:38 ` [PATCH 6/9] qemu-file: remove shutdown member Juan Quintela
2023-05-04 14:27 ` Peter Xu
2023-05-04 16:52 ` Daniel P. Berrangé
2023-05-04 11:38 ` [PATCH 7/9] qemu-file: Make total_transferred an uint64_t Juan Quintela
2023-05-04 16:53 ` Daniel P. Berrangé
2023-05-04 11:38 ` [PATCH 8/9] qemu-file: Make ram_control_save_page() use accessors for rate_limit Juan Quintela
2023-05-04 14:28 ` Peter Xu
2023-05-04 16:53 ` Daniel P. Berrangé
2023-05-04 11:38 ` [PATCH 9/9] qemu-file: Account for rate_limit usage on qemu_fflush() Juan Quintela
2023-05-04 14:43 ` Peter Xu
2023-05-04 14:59 ` Juan Quintela
2023-05-04 16:58 ` Daniel P. Berrangé [this message]
2023-05-04 17:22 ` Juan Quintela
2023-05-05 7:19 ` Daniel P. Berrangé
2023-05-05 12:14 ` Juan Quintela
2023-05-04 14:45 ` [PATCH 0/9] QEMU file cleanups Peter Xu
2023-05-04 14:56 ` Juan Quintela
2023-05-04 15:24 ` Peter Xu
2023-05-04 15:29 ` 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=ZFPkP58QSrkm6riX@redhat.com \
--to=berrange@redhat.com \
--cc=fam@euphon.net \
--cc=leobras@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=stefanha@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).