From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Cc: Amit Shah <amit.shah@redhat.com>, Alexander Graf <agraf@suse.de>
Subject: [Qemu-devel] [PULL 06/10] qemu-file: Add fast ftell code path
Date: Thu, 5 Feb 2015 17:24:23 +0100 [thread overview]
Message-ID: <1423153467-13804-7-git-send-email-quintela@redhat.com> (raw)
In-Reply-To: <1423153467-13804-1-git-send-email-quintela@redhat.com>
From: Alexander Graf <agraf@suse.de>
For ftell we flush the output buffer to ensure that we don't have anything
lingering in our internal buffers. This is a very safe thing to do.
However, with the dynamic size measurement that the dynamic vmstate
description will bring this would turn out quite slow.
Instead, we can fast path this specific measurement and just take the
internal buffers into account when telling the kernel our position.
I'm sure I overlooked some corner cases where this doesn't work, so
instead of tuning the safe, existing version, this patch adds a fast
variant of ftell that gets used by the dynamic vmstate description code
which isn't critical when it fails.
Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
include/migration/qemu-file.h | 1 +
migration/qemu-file.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h
index d843c00..a923cec 100644
--- a/include/migration/qemu-file.h
+++ b/include/migration/qemu-file.h
@@ -121,6 +121,7 @@ QEMUFile *qemu_bufopen(const char *mode, QEMUSizedBuffer *input);
int qemu_get_fd(QEMUFile *f);
int qemu_fclose(QEMUFile *f);
int64_t qemu_ftell(QEMUFile *f);
+int64_t qemu_ftell_fast(QEMUFile *f);
void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
void qemu_put_byte(QEMUFile *f, int v);
/*
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
index edc2830..e66e557 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -452,6 +452,22 @@ int qemu_get_byte(QEMUFile *f)
return result;
}
+int64_t qemu_ftell_fast(QEMUFile *f)
+{
+ int64_t ret = f->pos;
+ int i;
+
+ if (f->ops->writev_buffer) {
+ for (i = 0; i < f->iovcnt; i++) {
+ ret += f->iov[i].iov_len;
+ }
+ } else {
+ ret += f->buf_index;
+ }
+
+ return ret;
+}
+
int64_t qemu_ftell(QEMUFile *f)
{
qemu_fflush(f);
--
2.1.0
next prev parent reply other threads:[~2015-02-05 16:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-05 16:24 [Qemu-devel] [PULL 00/10] Migration queue Juan Quintela
2015-02-05 16:24 ` [Qemu-devel] [PULL 01/10] vmstate-static-checker: update whitelist Juan Quintela
2015-02-05 16:24 ` [Qemu-devel] [PULL 02/10] savevm: Convert fprintf to error_report Juan Quintela
2015-02-05 16:24 ` [Qemu-devel] [PULL 03/10] Migration: Add lots of trace events Juan Quintela
2015-02-05 16:24 ` [Qemu-devel] [PULL 04/10] Print errors in some of the early migration failure cases Juan Quintela
2015-02-05 16:24 ` [Qemu-devel] [PULL 05/10] QJSON: Add JSON writer Juan Quintela
2015-02-05 16:24 ` Juan Quintela [this message]
2015-02-05 16:24 ` [Qemu-devel] [PULL 07/10] migration: Append JSON description of migration stream Juan Quintela
2015-02-05 16:24 ` [Qemu-devel] [PULL 08/10] Add migration stream analyzation script Juan Quintela
2015-02-05 16:24 ` [Qemu-devel] [PULL 09/10] Tracify migration/rdma.c Juan Quintela
2015-02-05 16:24 ` [Qemu-devel] [PULL 10/10] fix mc146818rtc wrong subsection name to avoid vmstate_subsection_load() fail Juan Quintela
2015-02-06 10:38 ` [Qemu-devel] [PULL 00/10] Migration queue Peter Maydell
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=1423153467-13804-7-git-send-email-quintela@redhat.com \
--to=quintela@redhat.com \
--cc=agraf@suse.de \
--cc=amit.shah@redhat.com \
--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).