From patchwork Thu Apr 20 09:48:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 13218253 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7D474C77B73 for ; Thu, 20 Apr 2023 09:50:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppQuD-00006B-1B; Thu, 20 Apr 2023 05:48:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppQuB-0008Kb-V4 for qemu-devel@nongnu.org; Thu, 20 Apr 2023 05:48:43 -0400 Received: from mout.web.de ([212.227.15.14]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppQu9-000880-56 for qemu-devel@nongnu.org; Thu, 20 Apr 2023 05:48:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1681984116; i=lukasstraub2@web.de; bh=9f3AZYiitU7Qh41SKHS0+4Flkwj5FIcZQc8op6FZ0Bo=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=MkUcgHjLUHIdxYqLLF1v2hHyXl4ikvGp5cPy+yUYvkFzUfE9BVVDfmLJjqP4IdCOW hQwrcJNAC9M/jxdivyz8YIzR2VmbBPnuJt3OZvEwZJlZMLv0BynyniitunapTSDE1w wTDOup1bL1wfi+He1P645smvnKfZRNwu8IqYAuFjqGGRq+Spzp6KxpkVXwnwNAWce1 GGajf/I656wyUIcOUpnt7DvxKlfeOPYyqtqbuanSCcEXO2d3KCp+6FnIdbifpyrg66 ELiAIGzgewF4HqTYff3duxiQGNX3oRMrRx78I2ZhtlwxeNoJQlHaIp3CJCp9QyEKyw uwWs2uBg/40hA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from gecko.fritz.box ([82.207.254.123]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1M2gkl-1pt0Cx19rT-004Dmk; Thu, 20 Apr 2023 11:48:36 +0200 Date: Thu, 20 Apr 2023 11:48:35 +0200 From: Lukas Straub To: qemu-devel Cc: Juan Quintela , Peter Xu , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v2 13/13] ram-compress.c: Make target independent Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:/gQU3KFnA6P2Llk+Y4Mea+re6rhK2VrtDaMbKS6AQU4mhieBcvy AUhokhnPHKL90mBBnn8FSkctajds4N4/pnF3g2KNfY2A/Re7BQ2/EWjmDzTcM9KDegG+tr0 B93saWI8rOKwjoUWB1LmNgxd53gnOKQXhw/OIYMP9uP5Ioo3AXufi0189WzRNxPDtqXbFuP 2U70QBN2wMCMOn1jqOBTQ== UI-OutboundReport: notjunk:1;M01:P0:UCcDTG+bZwA=;ndWUvhLrg8MJnzom/y4S5AWKgXM VqOJ7OLF6QskxF4XYHNS4wI5aGc3GzhstEkdqLvY6pNs59nVpNYK9SK00Eiu5godtBVzwpFpU rNVgXbuSw+vBKwpN1KtwCpCOm+SDjsxaWnpKRo8NE3frRES1tntUKPUZi3miHOBsh0mljIyKh HAho3d5oHk6fZgUdh/4yyVwC65HxbflnrqYcAOFsbH+3QXzigdn39gLCzmjPFynyGSjsFV62T gIXOyd+R11tusmwM7MJcuSAZQ+xTHTqAZBgMXiem+3tViaT4U2eH/Tis4XqjwmdTMhLBI6cX8 i5CQHUt17R2ZLAvRESCubM81EGKlTM+povIgyzYTB/YZV87CUYVvTXNKXe++v4aLDBxgqovZ3 D9zls6lStn7wbVnw235EMHws71BbH4JIyxerZqNg+cRpIDz+reF8X9J+HqYM7QXhm/94DRowM ZsEV7OAh37Zp5RF/ZHkjD7nmYFYlKMwY0fjAheZbXiVeMmJnCGYZPHakKackhrWlq/YjFOELK EDiYCiDNaCNEcPzuevgt775yMSF38GHkY2euZ+i9BGfI3YGv6PvwOv/opzwpRl17qRl18AtR/ v59BgYvHqejOGaCzlQ/e2OCtXm+SXuzaQXhmTVOM81vZkjSyuJlYqLfPz4WaGQVtyQwOVtwZT Ig4YCbPyG/OHUu09CnKBJdCzh35ooh7YJFD5AxWuVrENN4lDVyJ1bzDIoIVQxvnFj4ec9QQ5+ r7yScD09LkFqvT2RhsR44+1ahjJrE6fh8GYxb401zdt6f6i27qn2NsLatBDD1vAwmwsxk+h3c NfSMGE1hU7vSeS+54L1pMuLvEKs+QzAXB9fETa1RcQo0Jow+mSRsu1jG8vLzh01x0qi6K4Xtn 58mxvsaqLf9fDGoqy7lFSPlvgDin7tETH17Qn+uIihys3NWYS+64f9ag52lUwynmBzF9EkFf/ H/3E9f05CjCL8NFqetE0sNVboS0= Received-SPF: pass client-ip=212.227.15.14; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Make ram-compress.c target independent. Signed-off-by: Lukas Straub Reviewed-by: Juan Quintela --- migration/meson.build | 2 +- migration/ram-compress.c | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) -- 2.40.0 diff --git a/migration/meson.build b/migration/meson.build index 262e3c9754..16f642031c 100644 --- a/migration/meson.build +++ b/migration/meson.build @@ -22,6 +22,7 @@ softmmu_ss.add(files( 'migration.c', 'multifd.c', 'multifd-zlib.c', + 'ram-compress.c', 'postcopy-ram.c', 'savevm.c', 'socket.c', @@ -38,5 +39,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 b75a9d2b9a..9f03c3cc66 100644 --- a/migration/ram-compress.c +++ b/migration/ram-compress.c @@ -34,7 +34,8 @@ #include "qemu/error-report.h" #include "migration.h" #include "io/channel-null.h" -#include "exec/ram_addr.h" +#include "exec/target_page.h" +#include "exec/ramblock.h" CompressionStats compression_counters; @@ -155,7 +156,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; } @@ -191,11 +192,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; } @@ -204,8 +206,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!"); @@ -335,7 +337,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); @@ -438,7 +440,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;