[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 20/21] ram-compress.c: Make target independent
From: |
Juan Quintela |
Subject: |
[PULL 20/21] ram-compress.c: Make target independent |
Date: |
Fri, 28 Apr 2023 21:12:02 +0200 |
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
- [PULL 11/21] ram.c: Let the compress threads return a CompressResult enum, (continued)
- [PULL 11/21] ram.c: Let the compress threads return a CompressResult enum, Juan Quintela, 2023/04/28
- [PULL 14/21] ram.c: Do not call save_page_header() from compress threads, Juan Quintela, 2023/04/28
- [PULL 12/21] ram.c: Dont change param->block in the compress thread, Juan Quintela, 2023/04/28
- [PULL 13/21] ram.c: Reset result after sending queued data, Juan Quintela, 2023/04/28
- [PULL 16/21] ram.c: Remove last ram.c dependency from the core compress code, Juan Quintela, 2023/04/28
- [PULL 15/21] ram.c: Call update_compress_thread_counts from compress_send_queued_data, Juan Quintela, 2023/04/28
- [PULL 18/21] ram.c: Move core decompression code into its own file, Juan Quintela, 2023/04/28
- [PULL 19/21] ram compress: Assert that the file buffer matches the result, Juan Quintela, 2023/04/28
- [PULL 17/21] ram.c: Move core compression code into its own file, Juan Quintela, 2023/04/28
- [PULL 21/21] migration: Initialize and cleanup decompression in migration.c, Juan Quintela, 2023/04/28
- [PULL 20/21] ram-compress.c: Make target independent,
Juan Quintela <=
- Re: [PULL 00/21] Migration 20230428 patches, Richard Henderson, 2023/04/29