From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org, quintela@redhat.com, amit.shah@redhat.com
Cc: jdenemar@redhat.com, liang.z.li@intel.com,
zhang.zhanghailiang@huawei.com
Subject: [Qemu-devel] [PATCH v2 6/6] multithread decompression: Avoid one copy
Date: Wed, 16 Dec 2015 11:47:38 +0000 [thread overview]
Message-ID: <1450266458-3178-7-git-send-email-dgilbert@redhat.com> (raw)
In-Reply-To: <1450266458-3178-1-git-send-email-dgilbert@redhat.com>
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
qemu_get_buffer does a copy, we can avoid the memcpy, and
we can then remove the extra buffer.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Liang Li <liang.z.li@intel.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
---
migration/ram.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index 994552c..2da3b51 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -286,7 +286,6 @@ static bool quit_comp_thread;
static bool quit_decomp_thread;
static DecompressParam *decomp_param;
static QemuThread *decompress_threads;
-static uint8_t *compressed_data_buf;
static int do_compress_ram_page(CompressParam *param);
@@ -2207,7 +2206,6 @@ void migrate_decompress_threads_create(void)
thread_count = migrate_decompress_threads();
decompress_threads = g_new0(QemuThread, thread_count);
decomp_param = g_new0(DecompressParam, thread_count);
- compressed_data_buf = g_malloc0(compressBound(TARGET_PAGE_SIZE));
quit_decomp_thread = false;
for (i = 0; i < thread_count; i++) {
qemu_mutex_init(&decomp_param[i].mutex);
@@ -2238,13 +2236,11 @@ void migrate_decompress_threads_join(void)
}
g_free(decompress_threads);
g_free(decomp_param);
- g_free(compressed_data_buf);
decompress_threads = NULL;
decomp_param = NULL;
- compressed_data_buf = NULL;
}
-static void decompress_data_with_multi_threads(uint8_t *compbuf,
+static void decompress_data_with_multi_threads(QEMUFile *f,
void *host, int len)
{
int idx, thread_count;
@@ -2253,7 +2249,7 @@ static void decompress_data_with_multi_threads(uint8_t *compbuf,
while (true) {
for (idx = 0; idx < thread_count; idx++) {
if (!decomp_param[idx].start) {
- memcpy(decomp_param[idx].compbuf, compbuf, len);
+ qemu_get_buffer(f, decomp_param[idx].compbuf, len);
decomp_param[idx].des = host;
decomp_param[idx].len = len;
start_decompression(&decomp_param[idx]);
@@ -2498,8 +2494,7 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
ret = -EINVAL;
break;
}
- qemu_get_buffer(f, compressed_data_buf, len);
- decompress_data_with_multi_threads(compressed_data_buf, host, len);
+ decompress_data_with_multi_threads(f, host, len);
break;
case RAM_SAVE_FLAG_XBZRLE:
--
2.5.0
next prev parent reply other threads:[~2015-12-16 11:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-16 11:47 [Qemu-devel] [PATCH v2 0/6] Migration: Small fixes and improvements Dr. David Alan Gilbert (git)
2015-12-16 11:47 ` [Qemu-devel] [PATCH v2 1/6] migration: Export migrate_set_state() Dr. David Alan Gilbert (git)
2015-12-16 12:40 ` Juan Quintela
2015-12-16 11:47 ` [Qemu-devel] [PATCH v2 2/6] migration: Add state records for migration incoming Dr. David Alan Gilbert (git)
2015-12-16 11:47 ` [Qemu-devel] [PATCH v2 3/6] Postcopy: Send events/change state on incoming side Dr. David Alan Gilbert (git)
2015-12-16 11:47 ` [Qemu-devel] [PATCH v2 4/6] Migration: Emit event at start of pass Dr. David Alan Gilbert (git)
2015-12-16 12:41 ` Juan Quintela
2015-12-16 16:47 ` Eric Blake
2015-12-16 16:52 ` Dr. David Alan Gilbert
2016-01-13 10:27 ` Amit Shah
2015-12-16 11:47 ` [Qemu-devel] [PATCH v2 5/6] Use qemu_get_buffer_in_place for xbzrle data Dr. David Alan Gilbert (git)
2015-12-16 11:47 ` Dr. David Alan Gilbert (git) [this message]
2016-01-13 10:29 ` [Qemu-devel] [PATCH v2 0/6] Migration: Small fixes and improvements Amit Shah
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=1450266458-3178-7-git-send-email-dgilbert@redhat.com \
--to=dgilbert@redhat.com \
--cc=amit.shah@redhat.com \
--cc=jdenemar@redhat.com \
--cc=liang.z.li@intel.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=zhang.zhanghailiang@huawei.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).