From patchwork Thu Mar 10 15:34:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 1603944 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TGx3CQTd; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4KDtSv1GCyz9sGD for ; Fri, 11 Mar 2022 02:36:13 +1100 (AEDT) Received: from localhost ([::1]:41492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSKpm-0003Ty-Gk for incoming@patchwork.ozlabs.org; Thu, 10 Mar 2022 10:36:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSKom-0003QL-8O for qemu-devel@nongnu.org; Thu, 10 Mar 2022 10:35:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:35078) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSKoi-0004DA-Ni for qemu-devel@nongnu.org; Thu, 10 Mar 2022 10:35:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646926503; 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=h06i63HZFhSUU2LHoPyhnxTJ86TvpzmPtf/TEmc+3ao=; b=TGx3CQTduXgXdPSUx5q89fhImwXs3T4MUOTAIeSvNtfSwmnaOImiF9rm5GLdlmBfNtvV66 SaRKVfO5UvCUFUqyc7t3TmyCE2otxR5QYPLMfixxVp46IWBhpwULM/ZejvKl+rRthwk067 LOb1UJ60BzemOFJGoSZshTfxb3/2uvM= 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-614-se6XiORVObuyZospK_h6xA-1; Thu, 10 Mar 2022 10:35:02 -0500 X-MC-Unique: se6XiORVObuyZospK_h6xA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9A9AA1091DA0; Thu, 10 Mar 2022 15:35:00 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B1328379E; Thu, 10 Mar 2022 15:34:58 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v5 1/8] migration: Export ram_transferred_ram() Date: Thu, 10 Mar 2022 16:34:47 +0100 Message-Id: <20220310153454.3929-2-quintela@redhat.com> In-Reply-To: <20220310153454.3929-1-quintela@redhat.com> References: <20220310153454.3929-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: Eduardo Habkost , Juan Quintela , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Xu , "Dr. David Alan Gilbert" , Yanan Wang , Leonardo Bras Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Reviewed-by: David Edmondson --- migration/ram.h | 2 ++ migration/ram.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/migration/ram.h b/migration/ram.h index 2c6dc3675d..2e27c49f90 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -64,6 +64,8 @@ int ram_postcopy_incoming_init(MigrationIncomingState *mis); void ram_handle_compressed(void *host, uint8_t ch, uint64_t size); +void ram_transferred_add(uint64_t bytes); + int ramblock_recv_bitmap_test(RAMBlock *rb, void *host_addr); bool ramblock_recv_bitmap_test_byte_offset(RAMBlock *rb, uint64_t byte_offset); void ramblock_recv_bitmap_set(RAMBlock *rb, void *host_addr); diff --git a/migration/ram.c b/migration/ram.c index 170e522a1f..947ed44c89 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -394,7 +394,7 @@ uint64_t ram_bytes_remaining(void) MigrationStats ram_counters; -static void ram_transferred_add(uint64_t bytes) +void ram_transferred_add(uint64_t bytes) { if (runstate_is_running()) { ram_counters.precopy_bytes += bytes; From patchwork Thu Mar 10 15:34:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 1603945 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NW0fynw4; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4KDtSw1z6dz9sGD for ; Fri, 11 Mar 2022 02:36:16 +1100 (AEDT) Received: from localhost ([::1]:41622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSKpq-0003a4-3F for incoming@patchwork.ozlabs.org; Thu, 10 Mar 2022 10:36:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35998) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSKoo-0003U3-Qy for qemu-devel@nongnu.org; Thu, 10 Mar 2022 10:35:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:21608) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSKom-0004Fm-N5 for qemu-devel@nongnu.org; Thu, 10 Mar 2022 10:35:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646926507; 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=V9RNk449/r7UeIupda5e3cnhwEkEAuC+chXFgMfufp8=; b=NW0fynw44MAj3IvQjlrjDGFitVQfZ1LpPzwQCtkpEVrk+uyi+iq+lGvgw3pRYSmXpVHVZn q98HPoLzd4fPcQNjvtjAtMocD6SHHn0lvy4wDyMvuAZHh7r2DNBsz2b/s2tu8cTXtd8IxR 3roUFGDsTx8ePSFFgjCiu1jZNNL33Uo= 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-183-_lE18LwHOA-7LVLMDcIzSQ-1; Thu, 10 Mar 2022 10:35:04 -0500 X-MC-Unique: _lE18LwHOA-7LVLMDcIzSQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 291161091DA0; Thu, 10 Mar 2022 15:35:03 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 157F88379D; Thu, 10 Mar 2022 15:35:00 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v5 2/8] multifd: Count the number of sent bytes correctly Date: Thu, 10 Mar 2022 16:34:48 +0100 Message-Id: <20220310153454.3929-3-quintela@redhat.com> In-Reply-To: <20220310153454.3929-1-quintela@redhat.com> References: <20220310153454.3929-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: Eduardo Habkost , Juan Quintela , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Xu , "Dr. David Alan Gilbert" , Yanan Wang , Leonardo Bras Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Current code asumes that all pages are whole. That is not true for example for compression already. Fix it for creating a new field ->sent_bytes that includes it. All ram_counters are used only from the migration thread, so we have two options: - put a mutex and fill everything when we sent it (not only ram_counters, also qemu_file->xfer_bytes). - Create a local variable that implements how much has been sent through each channel. And when we push another packet, we "add" the previous stats. I choose two due to less changes overall. On the previous code we increase transferred and then we sent. Current code goes the other way around. It sents the data, and after the fact, it updates the counters. Notice that each channel can have a maximum of half a megabyte of data without counting, so it is not very important. Signed-off-by: Juan Quintela --- migration/multifd.h | 2 ++ migration/multifd.c | 15 ++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/migration/multifd.h b/migration/multifd.h index 4dda900a0b..3afba8a198 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -119,6 +119,8 @@ typedef struct { uint32_t normal_num; /* used for compression methods */ void *data; + /* How many bytes have we sent on the last packet */ + uint64_t sent_bytes; } MultiFDSendParams; typedef struct { diff --git a/migration/multifd.c b/migration/multifd.c index 76b57a7177..ab87879471 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -398,7 +398,6 @@ static int multifd_send_pages(QEMUFile *f) static int next_channel; MultiFDSendParams *p = NULL; /* make happy gcc */ MultiFDPages_t *pages = multifd_send_state->pages; - uint64_t transferred; if (qatomic_read(&multifd_send_state->exiting)) { return -1; @@ -433,11 +432,10 @@ static int multifd_send_pages(QEMUFile *f) p->packet_num = multifd_send_state->packet_num++; multifd_send_state->pages = p->pages; p->pages = pages; - transferred = ((uint64_t) pages->num) * qemu_target_page_size() - + p->packet_len; - qemu_file_update_transfer(f, transferred); - ram_counters.multifd_bytes += transferred; - ram_counters.transferred += transferred; + ram_transferred_add(p->sent_bytes); + ram_counters.multifd_bytes += p->sent_bytes; + qemu_file_update_transfer(f, p->sent_bytes); + p->sent_bytes = 0; qemu_mutex_unlock(&p->mutex); qemu_sem_post(&p->sem); @@ -597,9 +595,6 @@ void multifd_send_sync_main(QEMUFile *f) p->packet_num = multifd_send_state->packet_num++; p->flags |= MULTIFD_FLAG_SYNC; p->pending_job++; - qemu_file_update_transfer(f, p->packet_len); - ram_counters.multifd_bytes += p->packet_len; - ram_counters.transferred += p->packet_len; qemu_mutex_unlock(&p->mutex); qemu_sem_post(&p->sem); } @@ -675,6 +670,8 @@ static void *multifd_send_thread(void *opaque) } qemu_mutex_lock(&p->mutex); + p->sent_bytes += p->packet_len;; + p->sent_bytes += p->next_packet_size; p->pending_job--; qemu_mutex_unlock(&p->mutex); From patchwork Thu Mar 10 15:34:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 1603953 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=I8u4Y/2i; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4KDtbW0wJwz9sGF for ; Fri, 11 Mar 2022 02:41:58 +1100 (AEDT) Received: from localhost ([::1]:57500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSKvL-0007Pa-6A for incoming@patchwork.ozlabs.org; Thu, 10 Mar 2022 10:41:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSKot-0003dF-VY for qemu-devel@nongnu.org; Thu, 10 Mar 2022 10:35:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50739) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSKoo-0004GV-Kg for qemu-devel@nongnu.org; Thu, 10 Mar 2022 10:35:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646926509; 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=41cdaUzXmvCThTuBCek1iGSroxx8oZt27BqgVNh16uQ=; b=I8u4Y/2iR2ukwmp9bKeAKchB60OwK1Eo4gNNdpgnIg4wn4kjXHGAJJn6EE0JcUoSNVz1Xo do1HktNQqV+ZHkG+WcDZnyMxIna+X0oK+6xoLTUkASB2BtW7Ur/mmykhlU2P3FLNk1+bS0 /ZR9LEbYYu2O4kVtCiUl6SK/IaOxCqg= 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-110-KaeqjlKqP5uFLwmpnk21mg-1; Thu, 10 Mar 2022 10:35:06 -0500 X-MC-Unique: KaeqjlKqP5uFLwmpnk21mg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 725D88031E1; Thu, 10 Mar 2022 15:35:05 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8312C7DE43; Thu, 10 Mar 2022 15:35:03 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v5 3/8] migration: Make ram_save_target_page() a pointer Date: Thu, 10 Mar 2022 16:34:49 +0100 Message-Id: <20220310153454.3929-4-quintela@redhat.com> In-Reply-To: <20220310153454.3929-1-quintela@redhat.com> References: <20220310153454.3929-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: Eduardo Habkost , Juan Quintela , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Xu , "Dr. David Alan Gilbert" , Yanan Wang , Leonardo Bras Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We are going to create a new function for multifd latest in the series. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 947ed44c89..1006d8d585 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -295,6 +295,9 @@ struct RAMSrcPageRequest { QSIMPLEQ_ENTRY(RAMSrcPageRequest) next_req; }; +typedef struct RAMState RAMState; +typedef struct PageSearchStatus PageSearchStatus; + /* State of RAM for migration */ struct RAMState { /* QEMUFile used for this migration */ @@ -349,8 +352,8 @@ struct RAMState { /* Queue of outstanding page requests from the destination */ QemuMutex src_page_req_mutex; QSIMPLEQ_HEAD(, RAMSrcPageRequest) src_page_requests; + int (*ram_save_target_page)(RAMState *rs, PageSearchStatus *pss); }; -typedef struct RAMState RAMState; static RAMState *ram_state; @@ -2126,14 +2129,14 @@ static bool save_compress_page(RAMState *rs, RAMBlock *block, ram_addr_t offset) } /** - * ram_save_target_page: save one target page + * ram_save_target_page_legacy: save one target page * * Returns the number of pages written * * @rs: current RAM state * @pss: data about the page we want to send */ -static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss) +static int ram_save_target_page_legacy(RAMState *rs, PageSearchStatus *pss) { RAMBlock *block = pss->block; ram_addr_t offset = ((ram_addr_t)pss->page) << TARGET_PAGE_BITS; @@ -2208,7 +2211,7 @@ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss) do { /* Check the pages is dirty and if it is send it */ if (migration_bitmap_clear_dirty(rs, pss->block, pss->page)) { - tmppages = ram_save_target_page(rs, pss); + tmppages = rs->ram_save_target_page(rs, pss); if (tmppages < 0) { return tmppages; } @@ -2937,6 +2940,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) ram_control_before_iterate(f, RAM_CONTROL_SETUP); ram_control_after_iterate(f, RAM_CONTROL_SETUP); + (*rsp)->ram_save_target_page = ram_save_target_page_legacy; multifd_send_sync_main(f); qemu_put_be64(f, RAM_SAVE_FLAG_EOS); qemu_fflush(f); From patchwork Thu Mar 10 15:34:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 1603951 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Qzf5GPWy; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4KDtXq1B9Yz9sGF for ; Fri, 11 Mar 2022 02:39:38 +1100 (AEDT) Received: from localhost ([::1]:52802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSKt6-0003ZE-Ej for incoming@patchwork.ozlabs.org; Thu, 10 Mar 2022 10:39:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSKor-0003Zv-Mn for qemu-devel@nongnu.org; Thu, 10 Mar 2022 10:35:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:27401) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSKoq-0004HB-4r for qemu-devel@nongnu.org; Thu, 10 Mar 2022 10:35:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646926511; 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=9c6uZ6c0JZKb0SZcQmE1PNMc5wI9Yl56LU5ySk1ZEkw=; b=Qzf5GPWycRqj7ee5f37v86LT+MGvd5wUrcvh70/BEkyxg7L86rkFtQeC1shG57CtKOyq80 ts0qjZIQK+4UUIhMzHwlQ8NcFdNCOT9v9rzJjXUtyL/vI6dSvoUxqIlykyF1TBqCkUNZiq K4xp8LCS4Q9T6KqJKHraMHHbkH813Bs= 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-421-GHsO-b7nOGKXclFZXjsyFA-1; Thu, 10 Mar 2022 10:35:09 -0500 X-MC-Unique: GHsO-b7nOGKXclFZXjsyFA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D24221854E21; Thu, 10 Mar 2022 15:35:07 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB4607DE43; Thu, 10 Mar 2022 15:35:05 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v5 4/8] multifd: Add property to enable/disable zero_page Date: Thu, 10 Mar 2022 16:34:50 +0100 Message-Id: <20220310153454.3929-5-quintela@redhat.com> In-Reply-To: <20220310153454.3929-1-quintela@redhat.com> References: <20220310153454.3929-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: Eduardo Habkost , Juan Quintela , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Xu , "Dr. David Alan Gilbert" , Yanan Wang , Leonardo Bras Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/migration.h | 3 +++ hw/core/machine.c | 4 +++- migration/migration.c | 11 +++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/migration/migration.h b/migration/migration.h index 2de861df01..5048d5241f 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -333,6 +333,8 @@ struct MigrationState { * This save hostname when out-going migration starts */ char *hostname; + /* Use multifd channel to send zero pages */ + bool multifd_zero_pages; }; void migrate_set_state(int *state, int old_state, int new_state); @@ -375,6 +377,7 @@ int migrate_multifd_channels(void); MultiFDCompression migrate_multifd_compression(void); int migrate_multifd_zlib_level(void); int migrate_multifd_zstd_level(void); +bool migrate_use_multifd_zero_page(void); int migrate_use_xbzrle(void); uint64_t migrate_xbzrle_cache_size(void); diff --git a/hw/core/machine.c b/hw/core/machine.c index d856485cb4..5d2bd2144b 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -37,7 +37,9 @@ #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-pci.h" -GlobalProperty hw_compat_6_2[] = {}; +GlobalProperty hw_compat_6_2[] = { + { "migration", "multifd-zero-pages", "false" }, +}; const size_t hw_compat_6_2_len = G_N_ELEMENTS(hw_compat_6_2); GlobalProperty hw_compat_6_1[] = { diff --git a/migration/migration.c b/migration/migration.c index 695f0f2900..a655fc0b79 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2511,6 +2511,15 @@ bool migrate_use_multifd(void) return s->enabled_capabilities[MIGRATION_CAPABILITY_MULTIFD]; } +bool migrate_use_multifd_zero_page(void) +{ + MigrationState *s; + + s = migrate_get_current(); + + return s->multifd_zero_pages; +} + bool migrate_pause_before_switchover(void) { MigrationState *s; @@ -4158,6 +4167,8 @@ static Property migration_properties[] = { clear_bitmap_shift, CLEAR_BITMAP_SHIFT_DEFAULT), /* Migration parameters */ + DEFINE_PROP_BOOL("multifd-zero-pages", MigrationState, + multifd_zero_pages, true), DEFINE_PROP_UINT8("x-compress-level", MigrationState, parameters.compress_level, DEFAULT_MIGRATE_COMPRESS_LEVEL), From patchwork Thu Mar 10 15:34:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 1603947 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=fuokvrv8; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4KDtVd1TqQz9sGD for ; Fri, 11 Mar 2022 02:37:45 +1100 (AEDT) Received: from localhost ([::1]:47960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSKrH-0008Fh-8i for incoming@patchwork.ozlabs.org; Thu, 10 Mar 2022 10:37:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSKos-0003bQ-IQ for qemu-devel@nongnu.org; Thu, 10 Mar 2022 10:35:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44191) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSKor-0004Hh-1p for qemu-devel@nongnu.org; Thu, 10 Mar 2022 10:35:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646926512; 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=cxHQWTjoWw2MktOSRwICsZzmQhqgB9npu4j6btIZ2Bk=; b=fuokvrv8COr1QugfhoBxX8+fYMwOxYzPqKdBieHu/HwDCYqVeiOiFlS50zxCzV27MKaUph 3PKh4F/etnAUBo4TIJmEC78IfFU0y0qZ/tYNgfSlmPsAGDJswvN/Kk7Fq2Q/9QE5RTYmX+ fB2x29LSOHbdPlgpYedbQtVvp5etobY= 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-492-SLiMktZBNAKjMUmBC5ZlaA-1; Thu, 10 Mar 2022 10:35:11 -0500 X-MC-Unique: SLiMktZBNAKjMUmBC5ZlaA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3ED6C801AFE; Thu, 10 Mar 2022 15:35:10 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 361D77DE43; Thu, 10 Mar 2022 15:35:08 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v5 5/8] migration: Export ram_release_page() Date: Thu, 10 Mar 2022 16:34:51 +0100 Message-Id: <20220310153454.3929-6-quintela@redhat.com> In-Reply-To: <20220310153454.3929-1-quintela@redhat.com> References: <20220310153454.3929-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: Eduardo Habkost , Juan Quintela , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Xu , "Dr. David Alan Gilbert" , Yanan Wang , Leonardo Bras Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Juan Quintela --- migration/ram.h | 1 + migration/ram.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/migration/ram.h b/migration/ram.h index 2e27c49f90..33686055b4 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -65,6 +65,7 @@ int ram_postcopy_incoming_init(MigrationIncomingState *mis); void ram_handle_compressed(void *host, uint8_t ch, uint64_t size); void ram_transferred_add(uint64_t bytes); +void ram_release_page(const char *rbname, uint64_t offset); int ramblock_recv_bitmap_test(RAMBlock *rb, void *host_addr); bool ramblock_recv_bitmap_test_byte_offset(RAMBlock *rb, uint64_t byte_offset); diff --git a/migration/ram.c b/migration/ram.c index 1006d8d585..1a642f1e70 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1180,7 +1180,7 @@ static void migration_bitmap_sync_precopy(RAMState *rs) } } -static void ram_release_page(const char *rbname, uint64_t offset) +void ram_release_page(const char *rbname, uint64_t offset) { if (!migrate_release_ram() || !migration_in_postcopy()) { return; From patchwork Thu Mar 10 15:34:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 1603954 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=aZd+ZDVj; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4KDtc435kKz9sGF for ; Fri, 11 Mar 2022 02:42:28 +1100 (AEDT) Received: from localhost ([::1]:58886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSKvq-0008Ls-EU for incoming@patchwork.ozlabs.org; Thu, 10 Mar 2022 10:42:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSKox-0003en-Mq for qemu-devel@nongnu.org; Thu, 10 Mar 2022 10:35:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42454) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSKov-0004Ig-JL for qemu-devel@nongnu.org; Thu, 10 Mar 2022 10:35:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646926517; 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=9cW1Wnicz65z06tPPp7Uik3etDAN4UJyzSEdQ7/Xy8c=; b=aZd+ZDVjiO3cpF7YjlVTEdnL/a/2J1d6NF39JbE3WJ7K8KDs8SWeJgOmIGmmXofcc65gy2 X8BbeoIkF/y88Vf6AfBvkv7JwDgJF1j091psEev1hs7t1Hd/s0SPLajyn1c1/YJhaEI19i FP8yOG2RFterbQ21nWStZqBbjvDcfOw= 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-656-wFgZfXL2PyuWq8yUZywM5w-1; Thu, 10 Mar 2022 10:35:13 -0500 X-MC-Unique: wFgZfXL2PyuWq8yUZywM5w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B28011800D50; Thu, 10 Mar 2022 15:35:12 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94CE77DE43; Thu, 10 Mar 2022 15:35:10 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v5 6/8] multifd: Support for zero pages transmission Date: Thu, 10 Mar 2022 16:34:52 +0100 Message-Id: <20220310153454.3929-7-quintela@redhat.com> In-Reply-To: <20220310153454.3929-1-quintela@redhat.com> References: <20220310153454.3929-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: Eduardo Habkost , Juan Quintela , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Xu , "Dr. David Alan Gilbert" , Yanan Wang , Leonardo Bras Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch adds counters and similar. Logic will be added on the following patch. Signed-off-by: Juan Quintela --- Added counters for duplicated/non duplicated pages. Removed reviewed by from David. Add total_zero_pages --- migration/multifd.h | 17 ++++++++++++++++- migration/multifd.c | 36 +++++++++++++++++++++++++++++------- migration/ram.c | 2 -- migration/trace-events | 8 ++++---- 4 files changed, 49 insertions(+), 14 deletions(-) diff --git a/migration/multifd.h b/migration/multifd.h index 3afba8a198..06c52081ab 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -49,7 +49,10 @@ typedef struct { /* size of the next packet that contains pages */ uint32_t next_packet_size; uint64_t packet_num; - uint64_t unused[4]; /* Reserved for future use */ + /* zero pages */ + uint32_t zero_pages; + uint32_t unused32[1]; /* Reserved for future use */ + uint64_t unused64[3]; /* Reserved for future use */ char ramblock[256]; uint64_t offset[]; } __attribute__((packed)) MultiFDPacket_t; @@ -107,6 +110,8 @@ typedef struct { uint64_t num_packets; /* non zero pages sent through this channel */ uint64_t total_normal_pages; + /* zero pages sent through this channel */ + uint64_t total_zero_pages; /* syncs main thread and channels */ QemuSemaphore sem_sync; /* buffers to send */ @@ -117,6 +122,10 @@ typedef struct { ram_addr_t *normal; /* num of non zero pages */ uint32_t normal_num; + /* Pages that are zero */ + ram_addr_t *zero; + /* num of zero pages */ + uint32_t zero_num; /* used for compression methods */ void *data; /* How many bytes have we sent on the last packet */ @@ -156,6 +165,8 @@ typedef struct { uint64_t num_packets; /* non zero pages recv through this channel */ uint64_t total_normal_pages; + /* zero pages recv through this channel */ + uint64_t total_zero_pages; /* syncs main thread and channels */ QemuSemaphore sem_sync; /* buffers to recv */ @@ -164,6 +175,10 @@ typedef struct { ram_addr_t *normal; /* num of non zero pages */ uint32_t normal_num; + /* Pages that are zero */ + ram_addr_t *zero; + /* num of zero pages */ + uint32_t zero_num; /* used for de-compression methods */ void *data; } MultiFDRecvParams; diff --git a/migration/multifd.c b/migration/multifd.c index ab87879471..41769ff99f 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -265,6 +265,7 @@ static void multifd_send_fill_packet(MultiFDSendParams *p) packet->normal_pages = cpu_to_be32(p->normal_num); packet->next_packet_size = cpu_to_be32(p->next_packet_size); packet->packet_num = cpu_to_be64(p->packet_num); + packet->zero_pages = cpu_to_be32(p->zero_num); if (p->pages->block) { strncpy(packet->ramblock, p->pages->block->idstr, 256); @@ -327,7 +328,15 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp) p->next_packet_size = be32_to_cpu(packet->next_packet_size); p->packet_num = be64_to_cpu(packet->packet_num); - if (p->normal_num == 0) { + p->zero_num = be32_to_cpu(packet->zero_pages); + if (p->zero_num > packet->pages_alloc - p->normal_num) { + error_setg(errp, "multifd: received packet " + "with %u zero pages and expected maximum pages are %u", + p->zero_num, packet->pages_alloc - p->normal_num) ; + return -1; + } + + if (p->normal_num == 0 && p->zero_num == 0) { return 0; } @@ -436,6 +445,8 @@ static int multifd_send_pages(QEMUFile *f) ram_counters.multifd_bytes += p->sent_bytes; qemu_file_update_transfer(f, p->sent_bytes); p->sent_bytes = 0; + ram_counters.normal += p->normal_num; + ram_counters.duplicate += p->zero_num; qemu_mutex_unlock(&p->mutex); qemu_sem_post(&p->sem); @@ -551,6 +562,8 @@ void multifd_save_cleanup(void) p->iov = NULL; g_free(p->normal); p->normal = NULL; + g_free(p->zero); + p->zero = NULL; multifd_send_state->ops->send_cleanup(p, &local_err); if (local_err) { migrate_set_error(migrate_get_current(), local_err); @@ -636,6 +649,7 @@ static void *multifd_send_thread(void *opaque) uint32_t flags = p->flags; p->iovs_num = 1; p->normal_num = 0; + p->zero_num = 0; for (int i = 0; i < p->pages->num; i++) { p->normal[p->normal_num] = p->pages->offset[i]; @@ -653,12 +667,13 @@ static void *multifd_send_thread(void *opaque) p->flags = 0; p->num_packets++; p->total_normal_pages += p->normal_num; + p->total_zero_pages += p->zero_num; p->pages->num = 0; p->pages->block = NULL; qemu_mutex_unlock(&p->mutex); - trace_multifd_send(p->id, packet_num, p->normal_num, flags, - p->next_packet_size); + trace_multifd_send(p->id, packet_num, p->normal_num, p->zero_num, + flags, p->next_packet_size); p->iov[0].iov_len = p->packet_len; p->iov[0].iov_base = p->packet; @@ -709,7 +724,8 @@ out: qemu_mutex_unlock(&p->mutex); rcu_unregister_thread(); - trace_multifd_send_thread_end(p->id, p->num_packets, p->total_normal_pages); + trace_multifd_send_thread_end(p->id, p->num_packets, p->total_normal_pages, + p->total_zero_pages); return NULL; } @@ -910,6 +926,7 @@ int multifd_save_setup(Error **errp) /* We need one extra place for the packet header */ p->iov = g_new0(struct iovec, page_count + 1); p->normal = g_new0(ram_addr_t, page_count); + p->zero = g_new0(ram_addr_t, page_count); socket_send_channel_create(multifd_new_send_channel_async, p); } @@ -1011,6 +1028,8 @@ int multifd_load_cleanup(Error **errp) p->iov = NULL; g_free(p->normal); p->normal = NULL; + g_free(p->zero); + p->zero = NULL; multifd_recv_state->ops->recv_cleanup(p); } qemu_sem_destroy(&multifd_recv_state->sem_sync); @@ -1084,10 +1103,11 @@ static void *multifd_recv_thread(void *opaque) flags = p->flags; /* recv methods don't know how to handle the SYNC flag */ p->flags &= ~MULTIFD_FLAG_SYNC; - trace_multifd_recv(p->id, p->packet_num, p->normal_num, flags, - p->next_packet_size); + trace_multifd_recv(p->id, p->packet_num, p->normal_num, p->zero_num, + flags, p->next_packet_size); p->num_packets++; p->total_normal_pages += p->normal_num; + p->total_normal_pages += p->zero_num; qemu_mutex_unlock(&p->mutex); if (p->normal_num) { @@ -1112,7 +1132,8 @@ static void *multifd_recv_thread(void *opaque) qemu_mutex_unlock(&p->mutex); rcu_unregister_thread(); - trace_multifd_recv_thread_end(p->id, p->num_packets, p->total_normal_pages); + trace_multifd_recv_thread_end(p->id, p->num_packets, p->total_normal_pages, + p->total_zero_pages); return NULL; } @@ -1150,6 +1171,7 @@ int multifd_load_setup(Error **errp) p->name = g_strdup_printf("multifdrecv_%d", i); p->iov = g_new0(struct iovec, page_count); p->normal = g_new0(ram_addr_t, page_count); + p->zero = g_new0(ram_addr_t, page_count); } for (i = 0; i < thread_count; i++) { diff --git a/migration/ram.c b/migration/ram.c index 1a642f1e70..141817d6a7 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1354,8 +1354,6 @@ static int ram_save_multifd_page(RAMState *rs, RAMBlock *block, if (multifd_queue_page(rs->f, block, offset) < 0) { return -1; } - ram_counters.normal++; - return 1; } diff --git a/migration/trace-events b/migration/trace-events index 1aec580e92..d70e89dbb9 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -114,21 +114,21 @@ unqueue_page(char *block, uint64_t offset, bool dirty) "ramblock '%s' offset 0x% # multifd.c multifd_new_send_channel_async(uint8_t id) "channel %u" -multifd_recv(uint8_t id, uint64_t packet_num, uint32_t used, uint32_t flags, uint32_t next_packet_size) "channel %u packet_num %" PRIu64 " pages %u flags 0x%x next packet size %u" +multifd_recv(uint8_t id, uint64_t packet_num, uint32_t normal, uint32_t zero, uint32_t flags, uint32_t next_packet_size) "channel %u packet_num %" PRIu64 " normal pages %u zero pages %u flags 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 %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) "channel %u packets %" PRIu64 " pages %" PRIu64 +multifd_recv_thread_end(uint8_t id, uint64_t packets, uint64_t normal_pages, uint64_t zero_pages) "channel %u packets %" PRIu64 " normal pages %" PRIu64 " zero pages %" PRIu64 multifd_recv_thread_start(uint8_t id) "%u" -multifd_send(uint8_t id, uint64_t packet_num, uint32_t normal, uint32_t flags, uint32_t next_packet_size) "channel %u packet_num %" PRIu64 " normal pages %u flags 0x%x next packet size %u" +multifd_send(uint8_t id, uint64_t packet_num, uint32_t normalpages, uint32_t zero_pages, uint32_t flags, uint32_t next_packet_size) "channel %u packet_num %" PRIu64 " normal pages %u zero pages %u flags 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 %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 normal_pages) "channel %u packets %" PRIu64 " normal pages %" PRIu64 +multifd_send_thread_end(uint8_t id, uint64_t packets, uint64_t normal_pages, uint64_t zero_pages) "channel %u packets %" PRIu64 " normal pages %" PRIu64 " zero pages %" PRIu64 multifd_send_thread_start(uint8_t id) "%u" multifd_tls_outgoing_handshake_start(void *ioc, void *tioc, const char *hostname) "ioc=%p tioc=%p hostname=%s" multifd_tls_outgoing_handshake_error(void *ioc, const char *err) "ioc=%p err=%s" From patchwork Thu Mar 10 15:34:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 1603952 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DnkTlyoL; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4KDtYW3mx1z9sGF for ; Fri, 11 Mar 2022 02:40:15 +1100 (AEDT) Received: from localhost ([::1]:54236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSKth-00051S-Ir for incoming@patchwork.ozlabs.org; Thu, 10 Mar 2022 10:40:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSKox-0003em-HA for qemu-devel@nongnu.org; Thu, 10 Mar 2022 10:35:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37884) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSKow-0004Ik-0A for qemu-devel@nongnu.org; Thu, 10 Mar 2022 10:35:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646926517; 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=Hy/jvMR/NmIxqgxWeXXMojUMtHbV0sZkV4HPX2gHOmg=; b=DnkTlyoLiPziU+SuHozpLnHm6BlMhrTefcgcJcidQQxxw8kfHpTk4jZGeVS9JwmGodG4Vp rGXGJZhlpohqmTbWp76+wu9iTyVC4kcYEg4wn1L7FNd6zX+SFp7BN703tbKVZSbVD36Tbn ivYAJ532KAFxe/0jQrw1eVj7LlHiD8s= 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-509-UBYx1s-oPmieMmpqzYijZg-1; Thu, 10 Mar 2022 10:35:16 -0500 X-MC-Unique: UBYx1s-oPmieMmpqzYijZg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 07C0D800D55; Thu, 10 Mar 2022 15:35:15 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B5507DE43; Thu, 10 Mar 2022 15:35:12 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v5 7/8] multifd: Zero pages transmission Date: Thu, 10 Mar 2022 16:34:53 +0100 Message-Id: <20220310153454.3929-8-quintela@redhat.com> In-Reply-To: <20220310153454.3929-1-quintela@redhat.com> References: <20220310153454.3929-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: Eduardo Habkost , Juan Quintela , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Xu , "Dr. David Alan Gilbert" , Yanan Wang , Leonardo Bras Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This implements the zero page dection and handling. Signed-off-by: Juan Quintela --- Add comment for offset (dave) Use local variables for offset/block to have shorter lines --- migration/multifd.h | 5 +++++ migration/multifd.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/migration/multifd.h b/migration/multifd.h index 06c52081ab..e84ce0ebcd 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -54,6 +54,11 @@ typedef struct { uint32_t unused32[1]; /* Reserved for future use */ uint64_t unused64[3]; /* Reserved for future use */ char ramblock[256]; + /* + * This array contains the pointers to: + * - normal pages (initial normal_pages entries) + * - zero pages (following zero_pages entries) + */ uint64_t offset[]; } __attribute__((packed)) MultiFDPacket_t; diff --git a/migration/multifd.c b/migration/multifd.c index 41769ff99f..1d7b6ffe24 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -11,6 +11,7 @@ */ #include "qemu/osdep.h" +#include "qemu/cutils.h" #include "qemu/rcu.h" #include "exec/target_page.h" #include "sysemu/sysemu.h" @@ -277,6 +278,12 @@ static void multifd_send_fill_packet(MultiFDSendParams *p) packet->offset[i] = cpu_to_be64(temp); } + for (i = 0; i < p->zero_num; i++) { + /* there are architectures where ram_addr_t is 32 bit */ + uint64_t temp = p->zero[i]; + + packet->offset[p->normal_num + i] = cpu_to_be64(temp); + } } static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp) @@ -362,6 +369,18 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp) p->normal[i] = offset; } + for (i = 0; i < p->zero_num; i++) { + uint64_t offset = be64_to_cpu(packet->offset[p->normal_num + i]); + + if (offset > (block->used_length - page_size)) { + error_setg(errp, "multifd: offset too long %" PRIu64 + " (max " RAM_ADDR_FMT ")", + offset, block->used_length); + return -1; + } + p->zero[i] = offset; + } + return 0; } @@ -624,6 +643,8 @@ static void *multifd_send_thread(void *opaque) { MultiFDSendParams *p = opaque; Error *local_err = NULL; + /* qemu older than 7.0 don't understand zero page on multifd channel */ + bool use_zero_page = migrate_use_multifd_zero_page(); int ret = 0; trace_multifd_send_thread_start(p->id); @@ -645,6 +666,7 @@ static void *multifd_send_thread(void *opaque) qemu_mutex_lock(&p->mutex); if (p->pending_job) { + RAMBlock *rb = p->pages->block; uint64_t packet_num = p->packet_num; uint32_t flags = p->flags; p->iovs_num = 1; @@ -652,8 +674,17 @@ static void *multifd_send_thread(void *opaque) p->zero_num = 0; for (int i = 0; i < p->pages->num; i++) { - p->normal[p->normal_num] = p->pages->offset[i]; - p->normal_num++; + uint64_t offset = p->pages->offset[i]; + size_t page_size = qemu_target_page_size(); + if (use_zero_page && + buffer_is_zero(rb->host + offset, page_size)) { + p->zero[p->zero_num] = offset; + p->zero_num++; + ram_release_page(rb->idstr, offset); + } else { + p->normal[p->normal_num] = offset; + p->normal_num++; + } } if (p->normal_num) { @@ -1117,6 +1148,13 @@ static void *multifd_recv_thread(void *opaque) } } + for (int i = 0; i < p->zero_num; i++) { + void *page = p->host + p->zero[i]; + if (!buffer_is_zero(page, qemu_target_page_size())) { + memset(page, 0, qemu_target_page_size()); + } + } + if (flags & MULTIFD_FLAG_SYNC) { qemu_sem_post(&multifd_recv_state->sem_sync); qemu_sem_wait(&p->sem_sync); From patchwork Thu Mar 10 15:34:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 1603956 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=EKm7PCXj; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4KDth14CZNz9sFq for ; Fri, 11 Mar 2022 02:45:53 +1100 (AEDT) Received: from localhost ([::1]:35978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSKz8-0003Xs-Qx for incoming@patchwork.ozlabs.org; Thu, 10 Mar 2022 10:45:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSKp2-0003h3-PI for qemu-devel@nongnu.org; Thu, 10 Mar 2022 10:35:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29402) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSKp0-0004N8-5y for qemu-devel@nongnu.org; Thu, 10 Mar 2022 10:35:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646926521; 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=h9ZbnAkRz5RqH5RpwJz8Auv9cqc1VYbhAksKZy/oBc0=; b=EKm7PCXj9jgBjZpMnxtZ/VXXpGDl150K+x6FjyDs2ABu9VOQoj/BQZIRQacAZe7Bq0Hu8d zuCaGlDARQNeTtD6/bq4JbvcYUg3MgX/vJeYExm4g8vtzPXfzkjio3CXUV7AS0fXwy/B9/ 0HOZaGytOm5bH0KIpQJI3l0TFnp9gjo= 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-541-6MYqeiKtPYOmQZzJ5zK_VA-1; Thu, 10 Mar 2022 10:35:18 -0500 X-MC-Unique: 6MYqeiKtPYOmQZzJ5zK_VA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 68497801DDB; Thu, 10 Mar 2022 15:35:17 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 61D7B7DE43; Thu, 10 Mar 2022 15:35:15 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v5 8/8] migration: Use multifd before we check for the zero page Date: Thu, 10 Mar 2022 16:34:54 +0100 Message-Id: <20220310153454.3929-9-quintela@redhat.com> In-Reply-To: <20220310153454.3929-1-quintela@redhat.com> References: <20220310153454.3929-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: Eduardo Habkost , Juan Quintela , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Xu , "Dr. David Alan Gilbert" , Yanan Wang , Leonardo Bras Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" So we use multifd to transmit zero pages. Signed-off-by: Juan Quintela --- - Check zero_page property before using new code (Dave) --- migration/ram.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/migration/ram.c b/migration/ram.c index 141817d6a7..628b5554ba 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2175,6 +2175,32 @@ static int ram_save_target_page_legacy(RAMState *rs, PageSearchStatus *pss) return ram_save_page(rs, pss); } +/** + * ram_save_target_page_multifd: save one target page + * + * Returns the number of pages written + * + * @rs: current RAM state + * @pss: data about the page we want to send + */ +static int ram_save_target_page_multifd(RAMState *rs, PageSearchStatus *pss) +{ + RAMBlock *block = pss->block; + ram_addr_t offset = ((ram_addr_t)pss->page) << TARGET_PAGE_BITS; + int res; + + if (!migration_in_postcopy()) { + return ram_save_multifd_page(rs, block, offset); + } + + res = save_zero_page(rs, block, offset); + if (res > 0) { + return res; + } + + return ram_save_page(rs, pss); +} + /** * ram_save_host_page: save a whole host page * @@ -2938,7 +2964,11 @@ static int ram_save_setup(QEMUFile *f, void *opaque) ram_control_before_iterate(f, RAM_CONTROL_SETUP); ram_control_after_iterate(f, RAM_CONTROL_SETUP); - (*rsp)->ram_save_target_page = ram_save_target_page_legacy; + if (migrate_use_multifd() && migrate_use_multifd_zero_page()) { + (*rsp)->ram_save_target_page = ram_save_target_page_multifd; + } else { + (*rsp)->ram_save_target_page = ram_save_target_page_legacy; + } multifd_send_sync_main(f); qemu_put_be64(f, RAM_SAVE_FLAG_EOS); qemu_fflush(f);