From nobody Fri May 3 04:40:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164190580725563.55445122826734; Tue, 11 Jan 2022 04:56:47 -0800 (PST) Received: from localhost ([::1]:37418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n7Ghi-0005Wm-6S for importer@patchew.org; Tue, 11 Jan 2022 07:56:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7GYR-00061C-PW for qemu-devel@nongnu.org; Tue, 11 Jan 2022 07:47:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:46400) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7GYL-0003C6-HY for qemu-devel@nongnu.org; Tue, 11 Jan 2022 07:47:11 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-135-IJjAPcpIOcmGbHPXIfHnBA-1; Tue, 11 Jan 2022 07:47:01 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B7C8A81CCCA for ; Tue, 11 Jan 2022 12:47:00 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD4BD2B45E; Tue, 11 Jan 2022 12:46:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641905225; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dSJDJ/uTmwSJ4RdPNgFLHa0xMl2gTxmT2BAl0JEJoTU=; b=jJnwE+DrWuSL2LEqmywN3uE2PF0DGKfdirvYaLsljEflioiJU46F2UvMKQUS2SNiP4psL1 PIBtxJn1/1VysAkk/BiK6zOUMujtTDSM6wlgjLV02zoPR3oZzbGdN1ew/9fjQk7Lc1q0+d FOp4WP5eAP4uaIzgK9SROFbRVvTAfvk= X-MC-Unique: IJjAPcpIOcmGbHPXIfHnBA-1 From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v3 1/6] migration: All this fields are unsigned Date: Tue, 11 Jan 2022 13:45:51 +0100 Message-Id: <20220111124556.4892-2-quintela@redhat.com> In-Reply-To: <20220111124556.4892-1-quintela@redhat.com> References: <20220111124556.4892-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=quintela@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Cc: Leonardo Bras , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Dr. David Alan Gilbert" , Peter Xu , Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641905808459100001 So printing it as %d is wrong. Notice that for the channel id, that is an uint8_t, but I changed it anyways for consistency. Signed-off-by: Juan Quintela Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Xu --- migration/multifd-zlib.c | 20 ++++++++++---------- migration/multifd-zstd.c | 24 ++++++++++++------------ migration/multifd.c | 16 ++++++++-------- migration/trace-events | 26 +++++++++++++------------- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/migration/multifd-zlib.c b/migration/multifd-zlib.c index da6201704c..9f6ebf1076 100644 --- a/migration/multifd-zlib.c +++ b/migration/multifd-zlib.c @@ -51,7 +51,7 @@ static int zlib_send_setup(MultiFDSendParams *p, Error **= errp) zs->opaque =3D Z_NULL; if (deflateInit(zs, migrate_multifd_zlib_level()) !=3D Z_OK) { g_free(z); - error_setg(errp, "multifd %d: deflate init failed", p->id); + error_setg(errp, "multifd %u: deflate init failed", p->id); return -1; } /* To be safe, we reserve twice the size of the packet */ @@ -60,7 +60,7 @@ static int zlib_send_setup(MultiFDSendParams *p, Error **= errp) if (!z->zbuff) { deflateEnd(&z->zs); g_free(z); - error_setg(errp, "multifd %d: out of memory for zbuff", p->id); + error_setg(errp, "multifd %u: out of memory for zbuff", p->id); return -1; } p->data =3D z; @@ -132,12 +132,12 @@ static int zlib_send_prepare(MultiFDSendParams *p, Er= ror **errp) ret =3D deflate(zs, flush); } while (ret =3D=3D Z_OK && zs->avail_in && zs->avail_out); if (ret =3D=3D Z_OK && zs->avail_in) { - error_setg(errp, "multifd %d: deflate failed to compress all i= nput", + error_setg(errp, "multifd %u: deflate failed to compress all i= nput", p->id); return -1; } if (ret !=3D Z_OK) { - error_setg(errp, "multifd %d: deflate returned %d instead of Z= _OK", + error_setg(errp, "multifd %u: deflate returned %d instead of Z= _OK", p->id, ret); return -1; } @@ -190,7 +190,7 @@ static int zlib_recv_setup(MultiFDRecvParams *p, Error = **errp) zs->avail_in =3D 0; zs->next_in =3D Z_NULL; if (inflateInit(zs) !=3D Z_OK) { - error_setg(errp, "multifd %d: inflate init failed", p->id); + error_setg(errp, "multifd %u: inflate init failed", p->id); return -1; } /* To be safe, we reserve twice the size of the packet */ @@ -198,7 +198,7 @@ static int zlib_recv_setup(MultiFDRecvParams *p, Error = **errp) z->zbuff =3D g_try_malloc(z->zbuff_len); if (!z->zbuff) { inflateEnd(zs); - error_setg(errp, "multifd %d: out of memory for zbuff", p->id); + error_setg(errp, "multifd %u: out of memory for zbuff", p->id); return -1; } return 0; @@ -247,7 +247,7 @@ static int zlib_recv_pages(MultiFDRecvParams *p, Error = **errp) int i; =20 if (flags !=3D MULTIFD_FLAG_ZLIB) { - error_setg(errp, "multifd %d: flags received %x flags expected %x", + error_setg(errp, "multifd %u: flags received %x flags expected %x", p->id, flags, MULTIFD_FLAG_ZLIB); return -1; } @@ -284,19 +284,19 @@ static int zlib_recv_pages(MultiFDRecvParams *p, Erro= r **errp) } while (ret =3D=3D Z_OK && zs->avail_in && (zs->total_out - start) < page_size); if (ret =3D=3D Z_OK && (zs->total_out - start) < page_size) { - error_setg(errp, "multifd %d: inflate generated too few output= ", + error_setg(errp, "multifd %u: inflate generated too few output= ", p->id); return -1; } if (ret !=3D Z_OK) { - error_setg(errp, "multifd %d: inflate returned %d instead of Z= _OK", + error_setg(errp, "multifd %u: inflate returned %d instead of Z= _OK", p->id, ret); return -1; } } out_size =3D zs->total_out - out_size; if (out_size !=3D expected_size) { - error_setg(errp, "multifd %d: packet size received %d size expecte= d %d", + error_setg(errp, "multifd %u: packet size received %u size expecte= d %u", p->id, out_size, expected_size); return -1; } diff --git a/migration/multifd-zstd.c b/migration/multifd-zstd.c index 2d5b61106c..cc4e991724 100644 --- a/migration/multifd-zstd.c +++ b/migration/multifd-zstd.c @@ -55,7 +55,7 @@ static int zstd_send_setup(MultiFDSendParams *p, Error **= errp) z->zcs =3D ZSTD_createCStream(); if (!z->zcs) { g_free(z); - error_setg(errp, "multifd %d: zstd createCStream failed", p->id); + error_setg(errp, "multifd %u: zstd createCStream failed", p->id); return -1; } =20 @@ -63,7 +63,7 @@ static int zstd_send_setup(MultiFDSendParams *p, Error **= errp) if (ZSTD_isError(res)) { ZSTD_freeCStream(z->zcs); g_free(z); - error_setg(errp, "multifd %d: initCStream failed with error %s", + error_setg(errp, "multifd %u: initCStream failed with error %s", p->id, ZSTD_getErrorName(res)); return -1; } @@ -73,7 +73,7 @@ static int zstd_send_setup(MultiFDSendParams *p, Error **= errp) if (!z->zbuff) { ZSTD_freeCStream(z->zcs); g_free(z); - error_setg(errp, "multifd %d: out of memory for zbuff", p->id); + error_setg(errp, "multifd %u: out of memory for zbuff", p->id); return -1; } return 0; @@ -144,12 +144,12 @@ static int zstd_send_prepare(MultiFDSendParams *p, Er= ror **errp) } while (ret > 0 && (z->in.size - z->in.pos > 0) && (z->out.size - z->out.pos > 0)); if (ret > 0 && (z->in.size - z->in.pos > 0)) { - error_setg(errp, "multifd %d: compressStream buffer too small", + error_setg(errp, "multifd %u: compressStream buffer too small", p->id); return -1; } if (ZSTD_isError(ret)) { - error_setg(errp, "multifd %d: compressStream error %s", + error_setg(errp, "multifd %u: compressStream error %s", p->id, ZSTD_getErrorName(ret)); return -1; } @@ -198,7 +198,7 @@ static int zstd_recv_setup(MultiFDRecvParams *p, Error = **errp) z->zds =3D ZSTD_createDStream(); if (!z->zds) { g_free(z); - error_setg(errp, "multifd %d: zstd createDStream failed", p->id); + error_setg(errp, "multifd %u: zstd createDStream failed", p->id); return -1; } =20 @@ -206,7 +206,7 @@ static int zstd_recv_setup(MultiFDRecvParams *p, Error = **errp) if (ZSTD_isError(ret)) { ZSTD_freeDStream(z->zds); g_free(z); - error_setg(errp, "multifd %d: initDStream failed with error %s", + error_setg(errp, "multifd %u: initDStream failed with error %s", p->id, ZSTD_getErrorName(ret)); return -1; } @@ -217,7 +217,7 @@ static int zstd_recv_setup(MultiFDRecvParams *p, Error = **errp) if (!z->zbuff) { ZSTD_freeDStream(z->zds); g_free(z); - error_setg(errp, "multifd %d: out of memory for zbuff", p->id); + error_setg(errp, "multifd %u: out of memory for zbuff", p->id); return -1; } return 0; @@ -265,7 +265,7 @@ static int zstd_recv_pages(MultiFDRecvParams *p, Error = **errp) int i; =20 if (flags !=3D MULTIFD_FLAG_ZSTD) { - error_setg(errp, "multifd %d: flags received %x flags expected %x", + error_setg(errp, "multifd %u: flags received %x flags expected %x", p->id, flags, MULTIFD_FLAG_ZSTD); return -1; } @@ -297,19 +297,19 @@ static int zstd_recv_pages(MultiFDRecvParams *p, Erro= r **errp) } while (ret > 0 && (z->in.size - z->in.pos > 0) && (z->out.pos < page_size)); if (ret > 0 && (z->out.pos < page_size)) { - error_setg(errp, "multifd %d: decompressStream buffer too smal= l", + error_setg(errp, "multifd %u: decompressStream buffer too smal= l", p->id); return -1; } if (ZSTD_isError(ret)) { - error_setg(errp, "multifd %d: decompressStream returned %s", + error_setg(errp, "multifd %u: decompressStream returned %s", p->id, ZSTD_getErrorName(ret)); return ret; } out_size +=3D z->out.pos; } if (out_size !=3D expected_size) { - error_setg(errp, "multifd %d: packet size received %d size expecte= d %d", + error_setg(errp, "multifd %u: packet size received %u size expecte= d %u", p->id, out_size, expected_size); return -1; } diff --git a/migration/multifd.c b/migration/multifd.c index 3242f688e5..4d62850258 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -148,7 +148,7 @@ static int nocomp_recv_pages(MultiFDRecvParams *p, Erro= r **errp) uint32_t flags =3D p->flags & MULTIFD_FLAG_COMPRESSION_MASK; =20 if (flags !=3D MULTIFD_FLAG_NOCOMP) { - error_setg(errp, "multifd %d: flags received %x flags expected %x", + error_setg(errp, "multifd %u: flags received %x flags expected %x", p->id, flags, MULTIFD_FLAG_NOCOMP); return -1; } @@ -212,8 +212,8 @@ static int multifd_recv_initial_packet(QIOChannel *c, E= rror **errp) } =20 if (msg.version !=3D MULTIFD_VERSION) { - error_setg(errp, "multifd: received packet version %d " - "expected %d", msg.version, MULTIFD_VERSION); + error_setg(errp, "multifd: received packet version %u " + "expected %u", msg.version, MULTIFD_VERSION); return -1; } =20 @@ -229,8 +229,8 @@ static int multifd_recv_initial_packet(QIOChannel *c, E= rror **errp) } =20 if (msg.id > migrate_multifd_channels()) { - error_setg(errp, "multifd: received channel version %d " - "expected %d", msg.version, MULTIFD_VERSION); + error_setg(errp, "multifd: received channel version %u " + "expected %u", msg.version, MULTIFD_VERSION); return -1; } =20 @@ -303,7 +303,7 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams= *p, Error **errp) packet->version =3D be32_to_cpu(packet->version); if (packet->version !=3D MULTIFD_VERSION) { error_setg(errp, "multifd: received packet " - "version %d and expected version %d", + "version %u and expected version %u", packet->version, MULTIFD_VERSION); return -1; } @@ -317,7 +317,7 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams= *p, Error **errp) */ if (packet->pages_alloc > pages_max * 100) { error_setg(errp, "multifd: received packet " - "with size %d and expected a maximum size of %d", + "with size %u and expected a maximum size of %u", packet->pages_alloc, pages_max * 100) ; return -1; } @@ -333,7 +333,7 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams= *p, Error **errp) p->pages->num =3D be32_to_cpu(packet->pages_used); if (p->pages->num > packet->pages_alloc) { error_setg(errp, "multifd: received packet " - "with %d pages and expected maximum pages are %d", + "with %u pages and expected maximum pages are %u", p->pages->num, packet->pages_alloc) ; return -1; } diff --git a/migration/trace-events b/migration/trace-events index b48d873b8a..5172cb3b3d 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -115,23 +115,23 @@ ram_write_tracking_ramblock_start(const char *block_i= d, size_t page_size, void * ram_write_tracking_ramblock_stop(const char *block_id, size_t page_size, v= oid *addr, size_t length) "%s: page_size: %zu addr: %p length: %zu" =20 # multifd.c -multifd_new_send_channel_async(uint8_t id) "channel %d" -multifd_recv(uint8_t id, uint64_t packet_num, uint32_t used, uint32_t flag= s, uint32_t next_packet_size) "channel %d packet_num %" PRIu64 " pages %d f= lags 0x%x next packet size %d" -multifd_recv_new_channel(uint8_t id) "channel %d" +multifd_new_send_channel_async(uint8_t id) "channel %u" +multifd_recv(uint8_t id, uint64_t packet_num, uint32_t used, uint32_t flag= s, uint32_t next_packet_size) "channel %u packet_num %" PRIu64 " pages %u f= lags 0x%x next packet size %u" +multifd_recv_new_channel(uint8_t id) "channel %u" multifd_recv_sync_main(long packet_num) "packet num %ld" -multifd_recv_sync_main_signal(uint8_t id) "channel %d" -multifd_recv_sync_main_wait(uint8_t id) "channel %d" +multifd_recv_sync_main_signal(uint8_t id) "channel %u" +multifd_recv_sync_main_wait(uint8_t id) "channel %u" multifd_recv_terminate_threads(bool error) "error %d" -multifd_recv_thread_end(uint8_t id, uint64_t packets, uint64_t pages) "cha= nnel %d packets %" PRIu64 " pages %" PRIu64 -multifd_recv_thread_start(uint8_t id) "%d" -multifd_send(uint8_t id, uint64_t packet_num, uint32_t used, uint32_t flag= s, uint32_t next_packet_size) "channel %d packet_num %" PRIu64 " pages %d f= lags 0x%x next packet size %d" -multifd_send_error(uint8_t id) "channel %d" +multifd_recv_thread_end(uint8_t id, uint64_t packets, uint64_t pages) "cha= nnel %u packets %" PRIu64 " pages %" PRIu64 +multifd_recv_thread_start(uint8_t id) "%u" +multifd_send(uint8_t id, uint64_t packet_num, uint32_t used, uint32_t flag= s, uint32_t next_packet_size) "channel %u packet_num %" PRIu64 " pages %u f= lags 0x%x next packet size %u" +multifd_send_error(uint8_t id) "channel %u" multifd_send_sync_main(long packet_num) "packet num %ld" -multifd_send_sync_main_signal(uint8_t id) "channel %d" -multifd_send_sync_main_wait(uint8_t id) "channel %d" +multifd_send_sync_main_signal(uint8_t id) "channel %u" +multifd_send_sync_main_wait(uint8_t id) "channel %u" multifd_send_terminate_threads(bool error) "error %d" -multifd_send_thread_end(uint8_t id, uint64_t packets, uint64_t pages) "cha= nnel %d packets %" PRIu64 " pages %" PRIu64 -multifd_send_thread_start(uint8_t id) "%d" +multifd_send_thread_end(uint8_t id, uint64_t packets, uint64_t pages) "cha= nnel %u packets %" PRIu64 " pages %" PRIu64 +multifd_send_thread_start(uint8_t id) "%u" multifd_tls_outgoing_handshake_start(void *ioc, void *tioc, const char *ho= stname) "ioc=3D%p tioc=3D%p hostname=3D%s" multifd_tls_outgoing_handshake_error(void *ioc, const char *err) "ioc=3D%p= err=3D%s" multifd_tls_outgoing_handshake_complete(void *ioc) "ioc=3D%p" --=20 2.34.1 From nobody Fri May 3 04:40:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641906024269284.7708605966061; Tue, 11 Jan 2022 05:00:24 -0800 (PST) Received: from localhost ([::1]:46092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n7GlC-000384-P7 for importer@patchew.org; Tue, 11 Jan 2022 08:00:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7GYm-0006Dq-Tx for qemu-devel@nongnu.org; Tue, 11 Jan 2022 07:47:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39960) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7GYk-0003Dk-Bj for qemu-devel@nongnu.org; Tue, 11 Jan 2022 07:47:31 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-580-R2Loxg5cOnek9EebsE8eRg-1; Tue, 11 Jan 2022 07:47:26 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9B39E1006AA8 for ; Tue, 11 Jan 2022 12:47:25 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A79E2AAA2; Tue, 11 Jan 2022 12:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641905248; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CQbBtcOQQqTGlmVLcvaCYCTmSqbpaVikGchlkLKdfGo=; b=QiAITfb+OGlmSNBePMi0sNQyUg3VfAmP4ZS3EX1cHsrQoqZe1YheVE7GIkPSoa6cyfvxxM xUdQmkbsUs7yhZOHPwQjd4Zg7gAG/AQllwC0Kb0zrfYkOVwgzypA5TOX4zrzakABHu4fuk emRQGdssrvVZbR6ZSiU6Pf0hfgy1Qvc= X-MC-Unique: R2Loxg5cOnek9EebsE8eRg-1 From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v3 2/6] migration: We only need last_stage in two places Date: Tue, 11 Jan 2022 13:45:52 +0100 Message-Id: <20220111124556.4892-3-quintela@redhat.com> In-Reply-To: <20220111124556.4892-1-quintela@redhat.com> References: <20220111124556.4892-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=quintela@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Cc: Leonardo Bras , "Dr. David Alan Gilbert" , Peter Xu , Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641906025905100001 Content-Type: text/plain; charset="utf-8" We only need last_stage in two places and we are passing it all around. Just add a field to RAMState that passes it. Signed-off-by: Juan Quintela Reviewed-by: Peter Xu --- Repeat subject (philmd suggestion) --- migration/ram.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 57efa67f20..7223b0d8ca 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -325,7 +325,8 @@ struct RAMState { uint64_t xbzrle_bytes_prev; /* Start using XBZRLE (e.g., after the first round). */ bool xbzrle_enabled; - + /* Are we on the last stage of migration */ + bool last_stage; /* compression statistics since the beginning of the period */ /* amount of count that no free thread to compress data */ uint64_t compress_thread_busy_prev; @@ -683,11 +684,10 @@ static void xbzrle_cache_zero_page(RAMState *rs, ram_= addr_t current_addr) * @current_addr: addr of the page * @block: block that contains the page we want to send * @offset: offset inside the block for the page - * @last_stage: if we are at the completion stage */ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data, ram_addr_t current_addr, RAMBlock *block, - ram_addr_t offset, bool last_stage) + ram_addr_t offset) { int encoded_len =3D 0, bytes_xbzrle; uint8_t *prev_cached_page; @@ -695,7 +695,7 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **cur= rent_data, if (!cache_is_cached(XBZRLE.cache, current_addr, ram_counters.dirty_sync_count)) { xbzrle_counters.cache_miss++; - if (!last_stage) { + if (!rs->last_stage) { if (cache_insert(XBZRLE.cache, current_addr, *current_data, ram_counters.dirty_sync_count) =3D=3D -1) { return -1; @@ -734,7 +734,7 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **cur= rent_data, * Update the cache contents, so that it corresponds to the data * sent, in all cases except where we skip the page. */ - if (!last_stage && encoded_len !=3D 0) { + if (!rs->last_stage && encoded_len !=3D 0) { memcpy(prev_cached_page, XBZRLE.current_buf, TARGET_PAGE_SIZE); /* * In the case where we couldn't compress, ensure that the caller @@ -1290,9 +1290,8 @@ static int save_normal_page(RAMState *rs, RAMBlock *b= lock, ram_addr_t offset, * @rs: current RAM state * @block: block that contains the page we want to send * @offset: offset inside the block for the page - * @last_stage: if we are at the completion stage */ -static int ram_save_page(RAMState *rs, PageSearchStatus *pss, bool last_st= age) +static int ram_save_page(RAMState *rs, PageSearchStatus *pss) { int pages =3D -1; uint8_t *p; @@ -1307,8 +1306,8 @@ static int ram_save_page(RAMState *rs, PageSearchStat= us *pss, bool last_stage) XBZRLE_cache_lock(); if (rs->xbzrle_enabled && !migration_in_postcopy()) { pages =3D save_xbzrle_page(rs, &p, current_addr, block, - offset, last_stage); - if (!last_stage) { + offset); + if (!rs->last_stage) { /* Can't send this cached data async, since the cache page * might get updated before it gets to the wire */ @@ -2129,10 +2128,8 @@ static bool save_compress_page(RAMState *rs, RAMBloc= k *block, ram_addr_t offset) * * @rs: current RAM state * @pss: data about the page we want to send - * @last_stage: if we are at the completion stage */ -static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, - bool last_stage) +static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss) { RAMBlock *block =3D pss->block; ram_addr_t offset =3D ((ram_addr_t)pss->page) << TARGET_PAGE_BITS; @@ -2171,7 +2168,7 @@ static int ram_save_target_page(RAMState *rs, PageSea= rchStatus *pss, return ram_save_multifd_page(rs, block, offset); } =20 - return ram_save_page(rs, pss, last_stage); + return ram_save_page(rs, pss); } =20 /** @@ -2190,10 +2187,8 @@ static int ram_save_target_page(RAMState *rs, PageSe= archStatus *pss, * @rs: current RAM state * @ms: current migration state * @pss: data about the page we want to send - * @last_stage: if we are at the completion stage */ -static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, - bool last_stage) +static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss) { int tmppages, pages =3D 0; size_t pagesize_bits =3D @@ -2211,7 +2206,7 @@ static int ram_save_host_page(RAMState *rs, PageSearc= hStatus *pss, do { /* Check the pages is dirty and if it is send it */ if (migration_bitmap_clear_dirty(rs, pss->block, pss->page)) { - tmppages =3D ram_save_target_page(rs, pss, last_stage); + tmppages =3D ram_save_target_page(rs, pss); if (tmppages < 0) { return tmppages; } @@ -2245,13 +2240,11 @@ static int ram_save_host_page(RAMState *rs, PageSea= rchStatus *pss, * or negative on error * * @rs: current RAM state - * @last_stage: if we are at the completion stage * * On systems where host-page-size > target-page-size it will send all the * pages in a host page that are dirty. */ - -static int ram_find_and_save_block(RAMState *rs, bool last_stage) +static int ram_find_and_save_block(RAMState *rs) { PageSearchStatus pss; int pages =3D 0; @@ -2280,7 +2273,7 @@ static int ram_find_and_save_block(RAMState *rs, bool= last_stage) } =20 if (found) { - pages =3D ram_save_host_page(rs, &pss, last_stage); + pages =3D ram_save_host_page(rs, &pss); } } while (!pages && again); =20 @@ -3080,7 +3073,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) break; } =20 - pages =3D ram_find_and_save_block(rs, false); + pages =3D ram_find_and_save_block(rs); /* no more pages to sent */ if (pages =3D=3D 0) { done =3D 1; @@ -3160,6 +3153,8 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) RAMState *rs =3D *temp; int ret =3D 0; =20 + rs->last_stage =3D !migration_in_colo_state(); + WITH_RCU_READ_LOCK_GUARD() { if (!migration_in_postcopy()) { migration_bitmap_sync_precopy(rs); @@ -3173,7 +3168,7 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) while (true) { int pages; =20 - pages =3D ram_find_and_save_block(rs, !migration_in_colo_state= ()); + pages =3D ram_find_and_save_block(rs); /* no more blocks to sent */ if (pages =3D=3D 0) { break; --=20 2.34.1 From nobody Fri May 3 04:40:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164190660901039.941554055159145; Tue, 11 Jan 2022 05:10:09 -0800 (PST) Received: from localhost ([::1]:54978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n7Gub-0001Pc-Cv for importer@patchew.org; Tue, 11 Jan 2022 08:10:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7GZV-0006WV-Hj for qemu-devel@nongnu.org; Tue, 11 Jan 2022 07:48:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:40673) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7GZL-0003Ha-Js for qemu-devel@nongnu.org; Tue, 11 Jan 2022 07:48:17 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-261-4I7nU-WMN0OT-CU7FGOCzA-1; Tue, 11 Jan 2022 07:48:04 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2516B1083F60 for ; Tue, 11 Jan 2022 12:48:03 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2D2A2AAA2; Tue, 11 Jan 2022 12:47:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641905285; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kCmLdBPGXLnysWXlHlHOtynqZm3tzzzs36PBUO5F6Ek=; b=KVT1lCBkMnAkG/INHyvNvko/ynxgt0FOBm2kzWw31byo6ILO1VnOJxlYmBNLj/bgJj2Hq2 Z5S6OlmSuxQxP4OI5gBEgWB8uKk1nlcLVareYApiMb0ks3TqJ95zA2gxwADokW8q+XD3bh x5wK5or7E0dONu3YVoedXg8O3kaR/wY= X-MC-Unique: 4I7nU-WMN0OT-CU7FGOCzA-1 From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v3 3/6] migration: ram_release_pages() always receive 1 page as argument Date: Tue, 11 Jan 2022 13:45:53 +0100 Message-Id: <20220111124556.4892-4-quintela@redhat.com> In-Reply-To: <20220111124556.4892-1-quintela@redhat.com> References: <20220111124556.4892-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=quintela@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Cc: Leonardo Bras , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Dr. David Alan Gilbert" , Peter Xu , Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641906610088100001 Remove the pages argument. And s/pages/page/ Signed-off-by: Juan Quintela Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Xu -- - Use 1LL instead of casts (philmd) - Change the whole 1ULL for TARGET_PAGE_SIZE Signed-off-by: Juan Quintela --- migration/ram.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 7223b0d8ca..881fe4974e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1204,13 +1204,13 @@ static int save_zero_page(RAMState *rs, RAMBlock *b= lock, ram_addr_t offset) return -1; } =20 -static void ram_release_pages(const char *rbname, uint64_t offset, int pag= es) +static void ram_release_page(const char *rbname, uint64_t offset) { if (!migrate_release_ram() || !migration_in_postcopy()) { return; } =20 - ram_discard_range(rbname, offset, ((ram_addr_t)pages) << TARGET_PAGE_B= ITS); + ram_discard_range(rbname, offset, TARGET_PAGE_SIZE); } =20 /* @@ -1365,7 +1365,7 @@ static bool do_compress_ram_page(QEMUFile *f, z_strea= m *stream, RAMBlock *block, } =20 exit: - ram_release_pages(block->idstr, offset & TARGET_PAGE_MASK, 1); + ram_release_page(block->idstr, offset & TARGET_PAGE_MASK); return zero_page; } =20 @@ -2153,7 +2153,7 @@ static int ram_save_target_page(RAMState *rs, PageSea= rchStatus *pss) xbzrle_cache_zero_page(rs, block->offset + offset); XBZRLE_cache_unlock(); } - ram_release_pages(block->idstr, offset, res); + ram_release_page(block->idstr, offset); return res; } =20 --=20 2.34.1 From nobody Fri May 3 04:40:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641906297308390.3562688811693; Tue, 11 Jan 2022 05:04:57 -0800 (PST) Received: from localhost ([::1]:49326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n7Gpb-0005is-6j for importer@patchew.org; Tue, 11 Jan 2022 08:04:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7GZX-0006Ym-Io for qemu-devel@nongnu.org; Tue, 11 Jan 2022 07:48:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:49930) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7GZW-0003Ik-1j for qemu-devel@nongnu.org; Tue, 11 Jan 2022 07:48:19 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-609-BFNQP_MeNCCgahj2rJzK9g-1; Tue, 11 Jan 2022 07:48:16 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 54156652 for ; Tue, 11 Jan 2022 12:48:15 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7CA932B45A; Tue, 11 Jan 2022 12:48:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641905297; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s5ojatPoOgbpjfe1lohCA2EO59QOGPUi8ARgrPJBFXg=; b=RuyKhUC+TfgYx0ZnyZ1tZybpMubw0G1I7SztkjPeC3htqBQ4HNu+i73LIdt6rlsWq19nzF poKapuiOMq9BGDw1w/KpWA68jnZzYirhxmjgT1jePzt2gdLKQpGLh25fBBIE64GlPcN+FD 3vlFdPCkc9Zi4zdgOY4HUS1ND2vA3Y0= X-MC-Unique: BFNQP_MeNCCgahj2rJzK9g-1 From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v3 4/6] migration: Remove masking for compression Date: Tue, 11 Jan 2022 13:45:54 +0100 Message-Id: <20220111124556.4892-5-quintela@redhat.com> In-Reply-To: <20220111124556.4892-1-quintela@redhat.com> References: <20220111124556.4892-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=quintela@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Cc: Leonardo Bras , "Dr. David Alan Gilbert" , Peter Xu , Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641906298690100003 Content-Type: text/plain; charset="utf-8" Remove the mask in the call to ram_release_pages(). Nothing else does it, and if the offset has that bits set, we have a lot of trouble. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 881fe4974e..fa49d22e69 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1340,7 +1340,7 @@ static bool do_compress_ram_page(QEMUFile *f, z_strea= m *stream, RAMBlock *block, ram_addr_t offset, uint8_t *source_buf) { RAMState *rs =3D ram_state; - uint8_t *p =3D block->host + (offset & TARGET_PAGE_MASK); + uint8_t *p =3D block->host + offset; bool zero_page =3D false; int ret; =20 @@ -1365,7 +1365,7 @@ static bool do_compress_ram_page(QEMUFile *f, z_strea= m *stream, RAMBlock *block, } =20 exit: - ram_release_page(block->idstr, offset & TARGET_PAGE_MASK); + ram_release_page(block->idstr, offset); return zero_page; } =20 --=20 2.34.1 From nobody Fri May 3 04:40:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641905708344416.40673919911; Tue, 11 Jan 2022 04:55:08 -0800 (PST) Received: from localhost ([::1]:34266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n7Gg7-0003P2-0S for importer@patchew.org; Tue, 11 Jan 2022 07:55:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7GZb-0006dW-MB for qemu-devel@nongnu.org; Tue, 11 Jan 2022 07:48:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40038) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7GZZ-0003JU-VL for qemu-devel@nongnu.org; Tue, 11 Jan 2022 07:48:23 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-208-IaJpfM4HMYGVBzMEtRGCWw-1; Tue, 11 Jan 2022 07:48:20 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8198B2FD16 for ; Tue, 11 Jan 2022 12:48:19 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id A95FF2B45A; Tue, 11 Jan 2022 12:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641905301; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dGSYPXKX7ZULzPp4ZznmYHOOL6TgtLyH+Wfqf39kLds=; b=J9N49xivC4O73CSYj4z/qOq9DazABJpdm3H+ISEpLaBR1t1wV81Je3noOy2hKY9K0OuqJs psF7e9SJLUTPXwZm1wf4TthpfgS1XM604EW1RwQNclHlVP6XEZPnnYrxrCfOV52tq6Y9C9 ljkMgAyU9vN9jTGvK1y4ka4TrakAV+Q= X-MC-Unique: IaJpfM4HMYGVBzMEtRGCWw-1 From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v3 5/6] migration: simplify do_compress_ram_page Date: Tue, 11 Jan 2022 13:45:55 +0100 Message-Id: <20220111124556.4892-6-quintela@redhat.com> In-Reply-To: <20220111124556.4892-1-quintela@redhat.com> References: <20220111124556.4892-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=quintela@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Cc: Leonardo Bras , "Dr. David Alan Gilbert" , Peter Xu , Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641905708917100001 Content-Type: text/plain; charset="utf-8" The goto is not needed at all. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index fa49d22e69..422c6bce28 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1341,12 +1341,11 @@ static bool do_compress_ram_page(QEMUFile *f, z_str= eam *stream, RAMBlock *block, { RAMState *rs =3D ram_state; uint8_t *p =3D block->host + offset; - bool zero_page =3D false; int ret; =20 if (save_zero_page_to_file(rs, f, block, offset)) { - zero_page =3D true; - goto exit; + ram_release_page(block->idstr, offset); + return true; } =20 save_page_header(rs, f, block, offset | RAM_SAVE_FLAG_COMPRESS_PAGE); @@ -1361,12 +1360,8 @@ static bool do_compress_ram_page(QEMUFile *f, z_stre= am *stream, RAMBlock *block, if (ret < 0) { qemu_file_set_error(migrate_get_current()->to_dst_file, ret); error_report("compressed data failed!"); - return false; } - -exit: - ram_release_page(block->idstr, offset); - return zero_page; + return false; } =20 static void --=20 2.34.1 From nobody Fri May 3 04:40:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641907270028442.54729535655235; Tue, 11 Jan 2022 05:21:10 -0800 (PST) Received: from localhost ([::1]:38034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n7H5I-0001de-Os for importer@patchew.org; Tue, 11 Jan 2022 08:21:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7GZh-0006gy-GM for qemu-devel@nongnu.org; Tue, 11 Jan 2022 07:48:34 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43514) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7GZb-0003Jj-Rt for qemu-devel@nongnu.org; Tue, 11 Jan 2022 07:48:25 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-260-0UHyBNrHMImCPKAim_34JQ-1; Tue, 11 Jan 2022 07:48:22 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3372F2FD16 for ; Tue, 11 Jan 2022 12:48:21 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8E5B2AAA2; Tue, 11 Jan 2022 12:48:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641905303; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1khIyfNNFWc9VNX4/2nGIMdiIvZ8naJgz6DXohUCbMM=; b=UapRliV94yGK6Hhxw6BxzjnGhAba612MU+HC9sbQRKRgoXigr45IoyjrZ83z666zscRsyN KHys2HRp9DGUlPHlk/5uHz5wI8PC04Lj2d2bKpyrWtjsnz5QG2SaArX0CgBtNN7+kVkNgr AiIFeWjNgLFxSrB7pAtysHaVe0YzrRc= X-MC-Unique: 0UHyBNrHMImCPKAim_34JQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v3 6/6] migration: Move ram_release_pages() call to save_zero_page_to_file() Date: Tue, 11 Jan 2022 13:45:56 +0100 Message-Id: <20220111124556.4892-7-quintela@redhat.com> In-Reply-To: <20220111124556.4892-1-quintela@redhat.com> References: <20220111124556.4892-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=quintela@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Cc: Leonardo Bras , "Dr. David Alan Gilbert" , Peter Xu , Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641907272411100001 Content-Type: text/plain; charset="utf-8" We always need to call it when we find a zero page, so put it in a single place. Signed-off-by: Juan Quintela Reviewed-by: Peter Xu --- migration/ram.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 422c6bce28..e9dcd3ca4e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1158,6 +1158,15 @@ static void migration_bitmap_sync_precopy(RAMState *= rs) } } =20 +static void ram_release_page(const char *rbname, uint64_t offset) +{ + if (!migrate_release_ram() || !migration_in_postcopy()) { + return; + } + + ram_discard_range(rbname, offset, TARGET_PAGE_SIZE); +} + /** * save_zero_page_to_file: send the zero page to the file * @@ -1179,6 +1188,7 @@ static int save_zero_page_to_file(RAMState *rs, QEMUF= ile *file, len +=3D save_page_header(rs, file, block, offset | RAM_SAVE_FLAG_= ZERO); qemu_put_byte(file, 0); len +=3D 1; + ram_release_page(block->idstr, offset); } return len; } @@ -1204,15 +1214,6 @@ static int save_zero_page(RAMState *rs, RAMBlock *bl= ock, ram_addr_t offset) return -1; } =20 -static void ram_release_page(const char *rbname, uint64_t offset) -{ - if (!migrate_release_ram() || !migration_in_postcopy()) { - return; - } - - ram_discard_range(rbname, offset, TARGET_PAGE_SIZE); -} - /* * @pages: the number of pages written by the control path, * < 0 - error @@ -1344,7 +1345,6 @@ static bool do_compress_ram_page(QEMUFile *f, z_strea= m *stream, RAMBlock *block, int ret; =20 if (save_zero_page_to_file(rs, f, block, offset)) { - ram_release_page(block->idstr, offset); return true; } =20 @@ -2148,7 +2148,6 @@ static int ram_save_target_page(RAMState *rs, PageSea= rchStatus *pss) xbzrle_cache_zero_page(rs, block->offset + offset); XBZRLE_cache_unlock(); } - ram_release_page(block->idstr, offset); return res; } =20 --=20 2.34.1