From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Thomas Huth" <thuth@redhat.com>, "Peter Xu" <peterx@redhat.com>,
"Leonardo Bras" <leobras@redhat.com>,
"Juan Quintela" <quintela@redhat.com>,
"Laurent Vivier" <lvivier@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Lukas Straub" <lukasstraub2@web.de>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PULL 12/13] ram-compress.c: Make target independent
Date: Mon, 8 May 2023 20:52:08 +0200 [thread overview]
Message-ID: <20230508185209.68604-13-quintela@redhat.com> (raw)
In-Reply-To: <20230508185209.68604-1-quintela@redhat.com>
From: Lukas Straub <lukasstraub2@web.de>
Make ram-compress.c target independent.
Signed-off-by: Lukas Straub <lukasstraub2@web.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
migration/meson.build | 3 ++-
migration/ram-compress.c | 17 ++++++++++-------
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/migration/meson.build b/migration/meson.build
index 2090af8e85..75de868bb7 100644
--- a/migration/meson.build
+++ b/migration/meson.build
@@ -23,6 +23,8 @@ softmmu_ss.add(files(
'migration.c',
'multifd.c',
'multifd-zlib.c',
+ 'multifd-zlib.c',
+ 'ram-compress.c',
'options.c',
'postcopy-ram.c',
'savevm.c',
@@ -40,5 +42,4 @@ softmmu_ss.add(when: zstd, if_true: files('multifd-zstd.c'))
specific_ss.add(when: 'CONFIG_SOFTMMU',
if_true: files('dirtyrate.c',
'ram.c',
- 'ram-compress.c',
'target.c'))
diff --git a/migration/ram-compress.c b/migration/ram-compress.c
index 3d2a4a6329..06254d8c69 100644
--- a/migration/ram-compress.c
+++ b/migration/ram-compress.c
@@ -35,7 +35,8 @@
#include "migration.h"
#include "options.h"
#include "io/channel-null.h"
-#include "exec/ram_addr.h"
+#include "exec/target_page.h"
+#include "exec/ramblock.h"
CompressionStats compression_counters;
@@ -156,7 +157,7 @@ int compress_threads_save_setup(void)
qemu_cond_init(&comp_done_cond);
qemu_mutex_init(&comp_done_lock);
for (i = 0; i < thread_count; i++) {
- comp_param[i].originbuf = g_try_malloc(TARGET_PAGE_SIZE);
+ comp_param[i].originbuf = g_try_malloc(qemu_target_page_size());
if (!comp_param[i].originbuf) {
goto exit;
}
@@ -192,11 +193,12 @@ static CompressResult do_compress_ram_page(QEMUFile *f, z_stream *stream,
uint8_t *source_buf)
{
uint8_t *p = block->host + offset;
+ size_t page_size = qemu_target_page_size();
int ret;
assert(qemu_file_buffer_empty(f));
- if (buffer_is_zero(p, TARGET_PAGE_SIZE)) {
+ if (buffer_is_zero(p, page_size)) {
return RES_ZEROPAGE;
}
@@ -205,8 +207,8 @@ static CompressResult do_compress_ram_page(QEMUFile *f, z_stream *stream,
* so that we can catch up the error during compression and
* decompression
*/
- memcpy(source_buf, p, TARGET_PAGE_SIZE);
- ret = qemu_put_compression_data(f, stream, source_buf, TARGET_PAGE_SIZE);
+ memcpy(source_buf, p, page_size);
+ ret = qemu_put_compression_data(f, stream, source_buf, page_size);
if (ret < 0) {
qemu_file_set_error(migrate_get_current()->to_dst_file, ret);
error_report("compressed data failed!");
@@ -336,7 +338,7 @@ static void *do_data_decompress(void *opaque)
param->des = 0;
qemu_mutex_unlock(¶m->mutex);
- pagesize = TARGET_PAGE_SIZE;
+ pagesize = qemu_target_page_size();
ret = qemu_uncompress_data(¶m->stream, des, pagesize,
param->compbuf, len);
@@ -439,7 +441,8 @@ int compress_threads_load_setup(QEMUFile *f)
goto exit;
}
- decomp_param[i].compbuf = g_malloc0(compressBound(TARGET_PAGE_SIZE));
+ size_t compbuf_size = compressBound(qemu_target_page_size());
+ decomp_param[i].compbuf = g_malloc0(compbuf_size);
qemu_mutex_init(&decomp_param[i].mutex);
qemu_cond_init(&decomp_param[i].cond);
decomp_param[i].done = true;
--
2.40.0
next prev parent reply other threads:[~2023-05-08 18:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-08 18:51 [PULL 00/13] Compression code patches Juan Quintela
2023-05-08 18:51 ` [PULL 01/13] qtest/migration-test.c: Add tests with compress enabled Juan Quintela
2023-05-08 18:51 ` [PULL 02/13] qtest/migration-test.c: Add postcopy " Juan Quintela
2023-05-08 18:51 ` [PULL 03/13] ram.c: Let the compress threads return a CompressResult enum Juan Quintela
2023-05-08 18:52 ` [PULL 04/13] ram.c: Dont change param->block in the compress thread Juan Quintela
2023-05-08 18:52 ` [PULL 05/13] ram.c: Reset result after sending queued data Juan Quintela
2023-05-08 18:52 ` [PULL 06/13] ram.c: Do not call save_page_header() from compress threads Juan Quintela
2023-05-08 18:52 ` [PULL 07/13] ram.c: Call update_compress_thread_counts from compress_send_queued_data Juan Quintela
2023-05-08 18:52 ` [PULL 08/13] ram.c: Remove last ram.c dependency from the core compress code Juan Quintela
2023-05-08 18:52 ` [PULL 09/13] ram.c: Move core compression code into its own file Juan Quintela
2023-05-08 18:52 ` [PULL 10/13] ram.c: Move core decompression " Juan Quintela
2023-05-08 18:52 ` [PULL 11/13] ram compress: Assert that the file buffer matches the result Juan Quintela
2023-05-08 18:52 ` Juan Quintela [this message]
2023-05-08 18:52 ` [PULL 13/13] migration: Initialize and cleanup decompression in migration.c Juan Quintela
2023-05-09 6:34 ` [PULL 00/13] Compression code patches Richard Henderson
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=20230508185209.68604-13-quintela@redhat.com \
--to=quintela@redhat.com \
--cc=leobras@redhat.com \
--cc=lukasstraub2@web.de \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@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).