From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551491; cv=none; d=zohomail.com; s=zohoarc; b=HIMmCd4Xu4DKGUphyszbijvD2G9YXQ9RBBkggQJ659x+cUQfvCrZjfowMsrkwfLS5D71HaMdkAKGKjhIswjMV+4ykibSKOj/G328G81uKM3VyGLjY+akY5hEGQNZmcRh6OHRK/lKEp14VNdtapkh7XUzpUPt97GuGVtAVK7bMus= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551491; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iASxFEoWiPyah9Q2oGPwe6Y9ChWz1tfzV9Lc03jcZnI=; b=XDgBrOkG6ERsIeEPVBf3l/n30QR8tbcu/hHJ7hWycUcvOBaOSFAZY+eqqp0v9IGDyFfnjQs6uy41jg3aRFOAJYprtr12mcIUazfezdbUUbpV0Uu9FIemoHKAv9Dla0nQImzOHwCcxVaIY5WQx5gb2oDPCyCXEfeUcgA604/uwjk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683551491469833.376432293686; Mon, 8 May 2023 06:11:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0cM-0003Fy-RT; Mon, 08 May 2023 09:09:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0cK-0003Cq-J1 for qemu-devel@nongnu.org; Mon, 08 May 2023 09:09:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0cI-0000g9-P8 for qemu-devel@nongnu.org; Mon, 08 May 2023 09:09:28 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-350-eHbtCzQFOT6V2ZCvlnbDZQ-1; Mon, 08 May 2023 09:09:22 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3633C1824600; Mon, 8 May 2023 13:09:21 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D92F2166B40; Mon, 8 May 2023 13:09:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551366; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iASxFEoWiPyah9Q2oGPwe6Y9ChWz1tfzV9Lc03jcZnI=; b=F4miIr4DixWIKnpn7gdugVe+ZHzX2xHKVUbNv1HMidQj39va/ZxUlsyJBZSu22W1NyNF50 j39a+NBzVb6SXWXbxxjDO+JISO5/JVP4F8BTnmV7NIMVjl0QQxO0sM9hA6wdKZkRhpr2zY oDoyytv9RQXG6AoO6ZQy67xFoOuings= X-MC-Unique: eHbtCzQFOT6V2ZCvlnbDZQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 01/21] migration: A rate limit value of 0 is valid Date: Mon, 8 May 2023 15:08:49 +0200 Message-Id: <20230508130909.65420-2-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551493346100005 Content-Type: text/plain; charset="utf-8" And it is the best way to not have rate_limit. Signed-off-by: Juan Quintela Reviewed-by: C=C3=A9dric Le Goater --- migration/migration.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 232e387109..1192f1ebf1 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2117,12 +2117,7 @@ static int postcopy_start(MigrationState *ms) * will notice we're in POSTCOPY_ACTIVE and not actually * wrap their state up here */ - /* 0 max-postcopy-bandwidth means unlimited */ - if (!bandwidth) { - qemu_file_set_rate_limit(ms->to_dst_file, INT64_MAX); - } else { - qemu_file_set_rate_limit(ms->to_dst_file, bandwidth / XFER_LIMIT_R= ATIO); - } + qemu_file_set_rate_limit(ms->to_dst_file, bandwidth / XFER_LIMIT_RATIO= ); if (migrate_postcopy_ram()) { /* Ping just for debugging, helps line traces up */ qemu_savevm_send_ping(ms->to_dst_file, 2); --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551414; cv=none; d=zohomail.com; s=zohoarc; b=XYnv3sw+0+msWmPmrTosG7vCB2l9laPqiGzt8YL4ZQaLKZdcimImg4wqQKsTSU6GyxtAMl8tNa3qxKYFrMoMCMiVLrzp0u5X3Vel6BPU//TgIvnkjlvEYijRzs3/zAuelZuEUKhwAMFUsf24jpXfppKhobVgThCZufTDYtJufkg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551414; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LOKoZz49zmYiL+teS5naxCwwtV6uR/rQiaaJ066Psh0=; b=mbw48F0Lg/K0RgLTUwvmUa4h7RbQAd04IAa7yLeJuzHXSz3W65rw+MmQC2DtM6e1bZBO1pBrBcTNM+zJ/op0Cv+5j3ZMYSePDkfDhwoWjdPolO6bXxqNK7Eq5S1TOIB3du5iphVpvtQQCvXhv2gVcPVjoDJExq6U3GkwyutQiA4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683551414164319.955421125934; Mon, 8 May 2023 06:10:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0cS-0003Ha-Ug; Mon, 08 May 2023 09:09:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0cR-0003HP-G7 for qemu-devel@nongnu.org; Mon, 08 May 2023 09:09:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0cQ-0000j6-4N for qemu-devel@nongnu.org; Mon, 08 May 2023 09:09:35 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-602-7lMtbiYyOYuxWJLW45eEQQ-1; Mon, 08 May 2023 09:09:27 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 45485867946; Mon, 8 May 2023 13:09:25 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7917C2166B40; Mon, 8 May 2023 13:09:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551373; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LOKoZz49zmYiL+teS5naxCwwtV6uR/rQiaaJ066Psh0=; b=iBYzR7LgexfClulJGpGWSf3b4xOFNTGy7elQ+uRPI/GZF+MjlPHLOe1DxBUGQzpfvYcIgN smoLZK5DJwQQ5Wu/f9akoDe1EL3LQOG1EZKSXdoOsmLFj9cgSHbxN3cudnIXQoLFLRY2Sg /ocQKefdepgWfX7e3CVSVnVSbEfL7bU= X-MC-Unique: 7lMtbiYyOYuxWJLW45eEQQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 02/21] migration: Don't use INT64_MAX for unlimited rate Date: Mon, 8 May 2023 15:08:50 +0200 Message-Id: <20230508130909.65420-3-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551416361100003 Content-Type: text/plain; charset="utf-8" Use 0 instead. Signed-off-by: Juan Quintela --- migration/migration.c | 4 ++-- migration/qemu-file.c | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 1192f1ebf1..3979a98949 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2296,7 +2296,7 @@ static void migration_completion(MigrationState *s) } if (ret >=3D 0) { s->block_inactive =3D !migrate_colo(); - qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX); + qemu_file_set_rate_limit(s->to_dst_file, 0); ret =3D qemu_savevm_state_complete_precopy(s->to_dst_file,= false, s->block_inactive= ); } @@ -3044,7 +3044,7 @@ static void *bg_migration_thread(void *opaque) rcu_register_thread(); object_ref(OBJECT(s)); =20 - qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX); + qemu_file_set_rate_limit(s->to_dst_file, 0); =20 setup_start =3D qemu_clock_get_ms(QEMU_CLOCK_HOST); /* diff --git a/migration/qemu-file.c b/migration/qemu-file.c index f4cfd05c67..745361d238 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -731,6 +731,9 @@ int qemu_file_rate_limit(QEMUFile *f) if (qemu_file_get_error(f)) { return 1; } + /* + * rate_limit_max =3D=3D 0 means no rate_limit enfoncement. + */ if (f->rate_limit_max > 0 && f->rate_limit_used > f->rate_limit_max) { return 1; } --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551430; cv=none; d=zohomail.com; s=zohoarc; b=OCL0RIyS+7DOsrIZ8qJ+0MxEwiCViFkIG1Ns7hdtsdGqeAUdpxJjDXct0SewjVDty6gpnob6VdXxWycxPXc94FjpwAs6lfCWygJTxC66C/8czdKWkooWmXV/Oay7HBqGm8zpFbb+9IyUuBrEEJNJIPkyIkyOw96bI/dMnQKFd/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551430; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lYeutPKog/HcFBUEouJIGxFSbZ2ttV5wtAhlcbyXyQI=; b=g5TbNQmrw6sfDKeuF5nXvs0939o7H5iAWUvRlxUE6iUeIi6c7Pp/Oe5K9w//zt2Cn7/7RJ0eIKncRjSaQYnNQzaHBNedsCYGNG/21/ImKiKkw/eDlptafV3bH1R42d9rhQFzWgInxmHmCgSYi3EPF4RNxX5k0o9zHVIBhYLjOBE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683551430135854.4734652097867; Mon, 8 May 2023 06:10:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0cs-0003aF-RX; Mon, 08 May 2023 09:10:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0cq-0003Ys-AN for qemu-devel@nongnu.org; Mon, 08 May 2023 09:10:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0co-0000mB-O1 for qemu-devel@nongnu.org; Mon, 08 May 2023 09:10:00 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-508-lBku-1jNNa-33SCYRdWI4g-1; Mon, 08 May 2023 09:09:53 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D7E953813F2C; Mon, 8 May 2023 13:09:52 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D4F12166B40; Mon, 8 May 2023 13:09:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551398; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lYeutPKog/HcFBUEouJIGxFSbZ2ttV5wtAhlcbyXyQI=; b=L6+8pOel1wKDR0ADO1QY1JuUpPRE+ZM1yS0UN+n4MQ5QZtWW7i7CwKulbF83QwVYxCDvNR Si6HoOTnqTFMQtv+OFdyZUC0zlbnSGF92hm51YhRgC0kw3i10VYI2cipoE5qlFWHsDcvIq 4bgrPdJkrwEL1kkT8boYPOTjZ/N9Fik= X-MC-Unique: lBku-1jNNa-33SCYRdWI4g-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 03/21] migration: We set the rate_limit by a second Date: Mon, 8 May 2023 15:08:51 +0200 Message-Id: <20230508130909.65420-4-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551432106100001 Content-Type: text/plain; charset="utf-8" That the implementation does the check every 100 milliseconds is an implementation detail that shouldn't be seen on the interfaz. Notice that all callers of qemu_file_set_rate_limit() used the division or pass 0, so this change is a NOP. Signed-off-by: Juan Quintela Reviewed-by: C=C3=A9dric Le Goater --- migration/migration.c | 7 +++---- migration/options.c | 4 ++-- migration/qemu-file.c | 6 +++++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 3979a98949..e17a6538b4 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2117,7 +2117,7 @@ static int postcopy_start(MigrationState *ms) * will notice we're in POSTCOPY_ACTIVE and not actually * wrap their state up here */ - qemu_file_set_rate_limit(ms->to_dst_file, bandwidth / XFER_LIMIT_RATIO= ); + qemu_file_set_rate_limit(ms->to_dst_file, bandwidth); if (migrate_postcopy_ram()) { /* Ping just for debugging, helps line traces up */ qemu_savevm_send_ping(ms->to_dst_file, 2); @@ -3207,11 +3207,10 @@ void migrate_fd_connect(MigrationState *s, Error *e= rror_in) =20 if (resume) { /* This is a resumed migration */ - rate_limit =3D migrate_max_postcopy_bandwidth() / - XFER_LIMIT_RATIO; + rate_limit =3D migrate_max_postcopy_bandwidth(); } else { /* This is a fresh new migration */ - rate_limit =3D migrate_max_bandwidth() / XFER_LIMIT_RATIO; + rate_limit =3D migrate_max_bandwidth(); =20 /* Notify before starting migration thread */ notifier_list_notify(&migration_state_notifiers, s); diff --git a/migration/options.c b/migration/options.c index 2e759cc306..d04b5fbc3a 100644 --- a/migration/options.c +++ b/migration/options.c @@ -1243,7 +1243,7 @@ static void migrate_params_apply(MigrateSetParameters= *params, Error **errp) s->parameters.max_bandwidth =3D params->max_bandwidth; if (s->to_dst_file && !migration_in_postcopy()) { qemu_file_set_rate_limit(s->to_dst_file, - s->parameters.max_bandwidth / XFER_LIMIT_R= ATIO); + s->parameters.max_bandwidth); } } =20 @@ -1275,7 +1275,7 @@ static void migrate_params_apply(MigrateSetParameters= *params, Error **errp) s->parameters.max_postcopy_bandwidth =3D params->max_postcopy_band= width; if (s->to_dst_file && migration_in_postcopy()) { qemu_file_set_rate_limit(s->to_dst_file, - s->parameters.max_postcopy_bandwidth / XFER_LIMIT_RATI= O); + s->parameters.max_postcopy_bandwidth); } } if (params->has_max_cpu_throttle) { diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 745361d238..12cf7fb04e 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -29,6 +29,7 @@ #include "migration.h" #include "qemu-file.h" #include "trace.h" +#include "options.h" #include "qapi/error.h" =20 #define IO_BUF_SIZE 32768 @@ -747,7 +748,10 @@ int64_t qemu_file_get_rate_limit(QEMUFile *f) =20 void qemu_file_set_rate_limit(QEMUFile *f, int64_t limit) { - f->rate_limit_max =3D limit; + /* + * 'limit' is per second. But we check it each 100 miliseconds. + */ + f->rate_limit_max =3D limit / XFER_LIMIT_RATIO; } =20 void qemu_file_reset_rate_limit(QEMUFile *f) --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551489; cv=none; d=zohomail.com; s=zohoarc; b=dxEpl35W9IwLu5+6y44dYAc7W4lmyZt7rGrEoWDJc8o9EqG96j/4bfhldP9izGOH+kUTSl4iqYg8OKZwlpeF/kgUaUaj0DQPTtZhFnD4fWEbq3MLoigWet/y3DoLno5IHiGVvNwmonZ/Hd78Zkzie78Ht2WAD4t3sNyo5sIuVcU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551489; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FD13sygxW3Jcptff0lDq6unYwnKy8R527CfsZIqXBQY=; b=NGvSzQG/THsIpr/GaJdyl8+30S3h6e0Vtls1fNctXNMqAYgEFA3dnwkPyJGwoUzb3oZw0SF5lPKIpcydSxKTGUivdxlFxmCDFATA118W3FmS7N8cJsdU/zR5ZQTLjOfKhRJ4ac9IAlhrtr9wVPqskabZmRuwIZ/Wd4dWY6lIsSg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683551489275261.3062963506185; Mon, 8 May 2023 06:11:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0d1-0003gn-Rl; Mon, 08 May 2023 09:10:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0d0-0003fy-1m for qemu-devel@nongnu.org; Mon, 08 May 2023 09:10:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0cu-0000zS-W4 for qemu-devel@nongnu.org; Mon, 08 May 2023 09:10:09 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-80-bh_unPGONKmaoXENtLUoUA-1; Mon, 08 May 2023 09:09:57 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E72C8280605F; Mon, 8 May 2023 13:09:56 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 275EA2166B40; Mon, 8 May 2023 13:09:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FD13sygxW3Jcptff0lDq6unYwnKy8R527CfsZIqXBQY=; b=AWoL9Y8rReRAf2mfeDg84A6khIrkTM1S6NeAwzB85z3YZMIYHpqyVE59jhEdpWPrHukR5t jT7fiZRp77S6UHHt3LBsyLiYu1Ui4V+/SUWYm65kY8TSMzm0Q0vcz69wg5zbeEIG9lBNA9 Uf05NtG3DIqGwj8zhNaK0OFa4InZ6T0= X-MC-Unique: bh_unPGONKmaoXENtLUoUA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 04/21] qemu-file: make qemu_file_[sg]et_rate_limit() use an uint64_t Date: Mon, 8 May 2023 15:08:52 +0200 Message-Id: <20230508130909.65420-5-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551491384100003 Content-Type: text/plain; charset="utf-8" It is really size_t. Everything else uses uint64_t, so move this to uint64_t as well. A size can't be negative anyways. Signed-off-by: Juan Quintela Message-Id: <20230504113841.23130-4-quintela@redhat.com> Reviewed-by: C=C3=A9dric Le Goater --- Don't drop the check if rate_limit_max is zero. --- migration/qemu-file.c | 6 +++--- migration/qemu-file.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 12cf7fb04e..346b683929 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -44,7 +44,7 @@ struct QEMUFile { * Maximum amount of data in bytes to transfer during one * rate limiting time window */ - int64_t rate_limit_max; + uint64_t rate_limit_max; /* * Total amount of data in bytes queued for transfer * during this rate limiting time window @@ -741,12 +741,12 @@ int qemu_file_rate_limit(QEMUFile *f) return 0; } =20 -int64_t qemu_file_get_rate_limit(QEMUFile *f) +uint64_t qemu_file_get_rate_limit(QEMUFile *f) { return f->rate_limit_max; } =20 -void qemu_file_set_rate_limit(QEMUFile *f, int64_t limit) +void qemu_file_set_rate_limit(QEMUFile *f, uint64_t limit) { /* * 'limit' is per second. But we check it each 100 miliseconds. diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 4f26bf6961..04ca48cbef 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -138,8 +138,8 @@ void qemu_file_reset_rate_limit(QEMUFile *f); * need to be applied to the rate limiting calcuations */ void qemu_file_acct_rate_limit(QEMUFile *f, int64_t len); -void qemu_file_set_rate_limit(QEMUFile *f, int64_t new_rate); -int64_t qemu_file_get_rate_limit(QEMUFile *f); +void qemu_file_set_rate_limit(QEMUFile *f, uint64_t new_rate); +uint64_t qemu_file_get_rate_limit(QEMUFile *f); int qemu_file_get_error_obj(QEMUFile *f, Error **errp); int qemu_file_get_error_obj_any(QEMUFile *f1, QEMUFile *f2, Error **errp); void qemu_file_set_error_obj(QEMUFile *f, int ret, Error *err); --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551499; cv=none; d=zohomail.com; s=zohoarc; b=cktjZsK+tfc0mQVey/aAFSjT81y5sjCDK951mwJiprv6IegM5p4gTO+hGrc5TM469dbTwauZoJA9K73xjZss3K6aZNqpcS8CUyjWyaNCabrAPIQ06obhJzZNBNWYweyYFlTrr6lUsUys25uB+NXmApJkQDWWJsNoy//8gcrQqMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551499; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5rp022K/cF/xFfzjk00dh7oy4g2njIAS+QRouSOLaW0=; b=GOIq1Acozntz49qpo4LO9pYeYtwUYinGj6BbLyWqIGejwEZhIEIK16PdYYl8htFLWSEnxj0FwNzY1sltzIq1MjPhd99o9BWAjJxY273RpHogBHeZneYUc+Z4viq1uAx4A/eI2Sh/jU7XGG5rh9Hj51SnpPelCf/zHfesnAIa6tI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683551499634450.7527432646524; Mon, 8 May 2023 06:11:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0e1-0004Z6-6N; Mon, 08 May 2023 09:11:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0d5-0003mS-Px for qemu-devel@nongnu.org; Mon, 08 May 2023 09:10:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0cx-0000zm-Ok for qemu-devel@nongnu.org; Mon, 08 May 2023 09:10:15 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-348-SYF2vH3yP3GSZ8WsZM4wRg-1; Mon, 08 May 2023 09:10:02 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 26D5E181E070; Mon, 8 May 2023 13:10:01 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B8B32166B40; Mon, 8 May 2023 13:09:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551405; 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=5rp022K/cF/xFfzjk00dh7oy4g2njIAS+QRouSOLaW0=; b=FHoibeN+YZCI1CpAjwXcDGdVBC0/8eiA2fyqSm8UxHiK31g+ocrUQ8GAoJ3jyCuhIiwjuN 1aeO/hgNoIsaE1Wqd9oG6SJelTSgrQgUmJJ1kVyl7eAZAFdiALZxJqSOYYaD2QFoMpx9Xf bd45HzenQLImuss1pgGJEOYAKsqsgZA= X-MC-Unique: SYF2vH3yP3GSZ8WsZM4wRg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH 05/21] qemu-file: Make rate_limit_used an uint64_t Date: Mon, 8 May 2023 15:08:53 +0200 Message-Id: <20230508130909.65420-6-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551500131100003 Change all the functions that use it. It was already passed as uint64_t. Signed-off-by: Juan Quintela Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20230504113841.23130-5-quintela@redhat.com> Reviewed-by: C=C3=A9dric Le Goater --- migration/qemu-file.c | 4 ++-- migration/qemu-file.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 346b683929..f3cb0cd94f 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -49,7 +49,7 @@ struct QEMUFile { * Total amount of data in bytes queued for transfer * during this rate limiting time window */ - int64_t rate_limit_used; + uint64_t rate_limit_used; =20 /* The sum of bytes transferred on the wire */ uint64_t total_transferred; @@ -759,7 +759,7 @@ void qemu_file_reset_rate_limit(QEMUFile *f) f->rate_limit_used =3D 0; } =20 -void qemu_file_acct_rate_limit(QEMUFile *f, int64_t len) +void qemu_file_acct_rate_limit(QEMUFile *f, uint64_t len) { f->rate_limit_used +=3D len; } diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 04ca48cbef..d758e7f10b 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -137,7 +137,7 @@ void qemu_file_reset_rate_limit(QEMUFile *f); * out of band from the main file object I/O methods, and * need to be applied to the rate limiting calcuations */ -void qemu_file_acct_rate_limit(QEMUFile *f, int64_t len); +void qemu_file_acct_rate_limit(QEMUFile *f, uint64_t len); void qemu_file_set_rate_limit(QEMUFile *f, uint64_t new_rate); uint64_t qemu_file_get_rate_limit(QEMUFile *f); int qemu_file_get_error_obj(QEMUFile *f, Error **errp); --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551645; cv=none; d=zohomail.com; s=zohoarc; b=a+Krnj9kLA4SsGGzjaCRSBHAaXkMZiVrwsnssFSmVZ/2h/YmtApkV+zwuCqTyXbVC+XtWIBRdF7VRuWOMGB/j/3xPc0gFHkgDUdIS0IqJzQ39xzhbu7m4puj3M3rO4IiFAFUh/wqa6YEC05EhcYm6omObcbLCPjcVidj0L8iFkM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551645; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XFas+oW+J1q9+8K/q//rQzFEL7jXYXvDyd0woIcR0no=; b=TtYCHgLcZaipz6Ls13PsvnOoBtff6hq14ko+Dc4M4qjWc754U39/IRwlX2vsMNMcCqetA2kd0wS6BuFQ8D0wqcCufZSzLUOpv0tgWTKgt+FZMVTS8adxKxUO+68iPGMFjW67mqEpNiiMK1T63Lm1JHCaS/jckQuqHESrYN7Mrko= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683551645757665.2394138463266; Mon, 8 May 2023 06:14:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0e9-00056V-Vf; Mon, 08 May 2023 09:11:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0dD-0003pC-Ab for qemu-devel@nongnu.org; Mon, 08 May 2023 09:10:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0cy-00010O-Rk for qemu-devel@nongnu.org; Mon, 08 May 2023 09:10:18 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-170-b7wwLYGbN3eW81-3EaYM4w-1; Mon, 08 May 2023 09:10:06 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2F902100F650; Mon, 8 May 2023 13:10:05 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 710DF2166B40; Mon, 8 May 2023 13:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551407; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XFas+oW+J1q9+8K/q//rQzFEL7jXYXvDyd0woIcR0no=; b=LEBtJdPGLfuekKLZQcvHCdnY4cKWBPK5NxbdLEWBh3BofUngk8SyEXT1a17qdOLmLj7FHB M4i4tksM/YbKXlLtP0wNM020PIWFNIUWtRfG98TE7zVbVR5xQz2oEvReJFPGdv479Q5dhB dPJy0P7E6ycAt4sX2+833vtyoDJPAVY= X-MC-Unique: b7wwLYGbN3eW81-3EaYM4w-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 06/21] qemu-file: Remove total from qemu_file_total_transferred_*() Date: Mon, 8 May 2023 15:08:54 +0200 Message-Id: <20230508130909.65420-7-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551647584100003 Content-Type: text/plain; charset="utf-8" Function is already quite long. Signed-off-by: Juan Quintela Reviewed-by: C=C3=A9dric Le Goater --- migration/block.c | 4 ++-- migration/migration.c | 2 +- migration/qemu-file.c | 4 ++-- migration/qemu-file.h | 10 +++++----- migration/savevm.c | 6 +++--- migration/vmstate.c | 5 ++--- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/migration/block.c b/migration/block.c index a37678ce95..12617b4152 100644 --- a/migration/block.c +++ b/migration/block.c @@ -747,7 +747,7 @@ static int block_save_setup(QEMUFile *f, void *opaque) static int block_save_iterate(QEMUFile *f, void *opaque) { int ret; - uint64_t last_bytes =3D qemu_file_total_transferred(f); + uint64_t last_bytes =3D qemu_file_transferred(f); =20 trace_migration_block_save("iterate", block_mig_state.submitted, block_mig_state.transferred); @@ -799,7 +799,7 @@ static int block_save_iterate(QEMUFile *f, void *opaque) } =20 qemu_put_be64(f, BLK_MIG_FLAG_EOS); - uint64_t delta_bytes =3D qemu_file_total_transferred(f) - last_bytes; + uint64_t delta_bytes =3D qemu_file_transferred(f) - last_bytes; return (delta_bytes > 0); } =20 diff --git a/migration/migration.c b/migration/migration.c index e17a6538b4..b1cfb56523 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2621,7 +2621,7 @@ static MigThrError migration_detect_error(MigrationSt= ate *s) /* How many bytes have we transferred since the beginning of the migration= */ static uint64_t migration_total_bytes(MigrationState *s) { - return qemu_file_total_transferred(s->to_dst_file) + + return qemu_file_transferred(s->to_dst_file) + stat64_get(&mig_stats.multifd_bytes); } =20 diff --git a/migration/qemu-file.c b/migration/qemu-file.c index f3cb0cd94f..6ebc2bd3ec 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -709,7 +709,7 @@ int coroutine_mixed_fn qemu_get_byte(QEMUFile *f) return result; } =20 -uint64_t qemu_file_total_transferred_fast(QEMUFile *f) +uint64_t qemu_file_transferred_fast(QEMUFile *f) { uint64_t ret =3D f->total_transferred; int i; @@ -721,7 +721,7 @@ uint64_t qemu_file_total_transferred_fast(QEMUFile *f) return ret; } =20 -uint64_t qemu_file_total_transferred(QEMUFile *f) +uint64_t qemu_file_transferred(QEMUFile *f) { qemu_fflush(f); return f->total_transferred; diff --git a/migration/qemu-file.h b/migration/qemu-file.h index d758e7f10b..ab164a58d0 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -68,7 +68,7 @@ void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks= *hooks); int qemu_fclose(QEMUFile *f); =20 /* - * qemu_file_total_transferred: + * qemu_file_transferred: * * Report the total number of bytes transferred with * this file. @@ -83,19 +83,19 @@ int qemu_fclose(QEMUFile *f); * * Returns: the total bytes transferred */ -uint64_t qemu_file_total_transferred(QEMUFile *f); +uint64_t qemu_file_transferred(QEMUFile *f); =20 /* - * qemu_file_total_transferred_fast: + * qemu_file_transferred_fast: * - * As qemu_file_total_transferred except for writable + * As qemu_file_transferred except for writable * files, where no flush is performed and the reported * amount will include the size of any queued buffers, * on top of the amount actually transferred. * * Returns: the total bytes transferred and queued */ -uint64_t qemu_file_total_transferred_fast(QEMUFile *f); +uint64_t qemu_file_transferred_fast(QEMUFile *f); =20 /* * put_buffer without copying the buffer. diff --git a/migration/savevm.c b/migration/savevm.c index 032044b1d5..e33788343a 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -927,9 +927,9 @@ static int vmstate_load(QEMUFile *f, SaveStateEntry *se) static void vmstate_save_old_style(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc) { - uint64_t old_offset =3D qemu_file_total_transferred_fast(f); + uint64_t old_offset =3D qemu_file_transferred_fast(f); se->ops->save_state(f, se->opaque); - uint64_t size =3D qemu_file_total_transferred_fast(f) - old_offset; + uint64_t size =3D qemu_file_transferred_fast(f) - old_offset; =20 if (vmdesc) { json_writer_int64(vmdesc, "size", size); @@ -2956,7 +2956,7 @@ bool save_snapshot(const char *name, bool overwrite, = const char *vmstate, goto the_end; } ret =3D qemu_savevm_state(f, errp); - vm_state_size =3D qemu_file_total_transferred(f); + vm_state_size =3D qemu_file_transferred(f); ret2 =3D qemu_fclose(f); if (ret < 0) { goto the_end; diff --git a/migration/vmstate.c b/migration/vmstate.c index 351f56104e..af01d54b6f 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -361,7 +361,7 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDesc= ription *vmsd, void *curr_elem =3D first_elem + size * i; =20 vmsd_desc_field_start(vmsd, vmdesc_loop, field, i, n_elems= ); - old_offset =3D qemu_file_total_transferred_fast(f); + old_offset =3D qemu_file_transferred_fast(f); if (field->flags & VMS_ARRAY_OF_POINTER) { assert(curr_elem); curr_elem =3D *(void **)curr_elem; @@ -391,8 +391,7 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDesc= ription *vmsd, return ret; } =20 - written_bytes =3D qemu_file_total_transferred_fast(f) - - old_offset; + written_bytes =3D qemu_file_transferred_fast(f) - old_offs= et; vmsd_desc_field_end(vmsd, vmdesc_loop, field, written_byte= s, i); =20 /* Compressed arrays only care about the first element */ --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551501; cv=none; d=zohomail.com; s=zohoarc; b=TY/McpeOP8+bJ5Kdw0YAh8XdLM1P5L2h/1Jy9LjXfOFbsnYOajiaFRbInNQq81J4gSlkfu6ZBZ2OaT9cEuZ6vT2hhZH+y5D82zqvZqLr5z3KnbZV348mOnP4RSjteNjbdCUS6pYGl8ldXcOOSSEvXTnmc1FLZlNBN75MSSrY6KI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551501; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GB/E/hAWcVrYzDkJg8/L6PWbVxUIBoKyVIoYkxWecV8=; b=bF8lvfqYSrk3ywfD8alz/5mV02FUqzOD0edwgKYHpZtDPueCf8wy3hzK8Ew4VRHicb2mvMg+VKbG3APDiV0SuSrK08rQ7sgv6WeLoaurgd7h8gtjgMVxEDQ8edepscQC9NQTYWFq+I0MwboN9Dz+a5NrAl0yvcn8lTnjjv7D/c4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683551501524405.82029860307216; Mon, 8 May 2023 06:11:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0e9-00050P-BN; Mon, 08 May 2023 09:11:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0d8-0003nM-D4 for qemu-devel@nongnu.org; Mon, 08 May 2023 09:10:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0d5-00011Y-Cr for qemu-devel@nongnu.org; Mon, 08 May 2023 09:10:17 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-590-NG_VgO9WPfaxggjCILkf3A-1; Mon, 08 May 2023 09:10:10 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5CD97181E06C; Mon, 8 May 2023 13:10:09 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76F142166B40; Mon, 8 May 2023 13:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551413; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GB/E/hAWcVrYzDkJg8/L6PWbVxUIBoKyVIoYkxWecV8=; b=VU0dNLTKql7piKeJp8k2F4ykSncYsvi6R4rCTZM4qAhMv9xyXVic/tKCNvnfdfAGmevn+z NtZLiiCbixtPU1Utf5irIYqdfQ1nZTc/TRr51oKhtaJO6CZ5pbQhf5+Abrgeia8d17JjpH iEst/84OfrttXpIdWGT17wYh43ZXTqQ= X-MC-Unique: NG_VgO9WPfaxggjCILkf3A-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 07/21] migration: Correct transferred bytes value Date: Mon, 8 May 2023 15:08:55 +0200 Message-Id: <20230508130909.65420-8-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551502132100007 Content-Type: text/plain; charset="utf-8" We forget several places to add to trasferred amount of data. With this fixes I get: qemu_file_transferred() + multifd_bytes =3D=3D transferred The only place whrer this is not true is during devices sending. But going all through the full tree searching for devices that use QEMUFile directly is a bit too much. Multifd, precopy and xbzrle work as expected. Postocpy still misses 35 bytes, but searching for them is getting complicated, so I stop here. Signed-off-by: Juan Quintela --- migration/meson.build | 2 +- migration/ram.c | 14 ++++++++++++++ migration/savevm.c | 19 +++++++++++++++++-- migration/vmstate.c | 3 +++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/migration/meson.build b/migration/meson.build index da1897fadf..b27fc9eeb6 100644 --- a/migration/meson.build +++ b/migration/meson.build @@ -1,5 +1,6 @@ # Files needed by unit tests migration_files =3D files( + 'migration-stats.c', 'page_cache.c', 'xbzrle.c', 'vmstate-types.c', @@ -19,7 +20,6 @@ softmmu_ss.add(files( 'fd.c', 'global_state.c', 'migration-hmp-cmds.c', - 'migration-stats.c', 'migration.c', 'multifd.c', 'multifd-zlib.c', diff --git a/migration/ram.c b/migration/ram.c index 5e7bf20ca5..5ae1fdba45 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -337,6 +337,7 @@ int64_t ramblock_recv_bitmap_send(QEMUFile *file, =20 g_free(le_bitmap); =20 + stat64_add(&mig_stats.transferred, 8 + size + 8); if (qemu_file_get_error(file)) { return qemu_file_get_error(file); } @@ -1617,6 +1618,7 @@ static int find_dirty_block(RAMState *rs, PageSearchS= tatus *pss) return ret; } qemu_put_be64(f, RAM_SAVE_FLAG_MULTIFD_FLUSH); + stat64_add(&mig_stats.transferred, 8); qemu_fflush(f); } /* @@ -3245,6 +3247,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) RAMState **rsp =3D opaque; RAMBlock *block; int ret; + size_t size =3D 0; =20 if (compress_threads_save_setup()) { return -1; @@ -3263,16 +3266,20 @@ static int ram_save_setup(QEMUFile *f, void *opaque) qemu_put_be64(f, ram_bytes_total_with_ignored() | RAM_SAVE_FLAG_MEM_SIZE); =20 + size +=3D 8; RAMBLOCK_FOREACH_MIGRATABLE(block) { qemu_put_byte(f, strlen(block->idstr)); qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idst= r)); qemu_put_be64(f, block->used_length); + size +=3D 1 + strlen(block->idstr) + 8; if (migrate_postcopy_ram() && block->page_size !=3D qemu_host_page_size) { qemu_put_be64(f, block->page_size); + size +=3D 8; } if (migrate_ignore_shared()) { qemu_put_be64(f, block->mr->addr); + size +=3D 8; } } } @@ -3289,11 +3296,14 @@ static int ram_save_setup(QEMUFile *f, void *opaque) =20 if (!migrate_multifd_flush_after_each_section()) { qemu_put_be64(f, RAM_SAVE_FLAG_MULTIFD_FLUSH); + size +=3D 8; } =20 qemu_put_be64(f, RAM_SAVE_FLAG_EOS); + size +=3D 8; qemu_fflush(f); =20 + stat64_add(&mig_stats.transferred, size); return 0; } =20 @@ -3434,6 +3444,7 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) RAMState **temp =3D opaque; RAMState *rs =3D *temp; int ret =3D 0; + size_t size =3D 0; =20 rs->last_stage =3D !migration_in_colo_state(); =20 @@ -3478,8 +3489,11 @@ static int ram_save_complete(QEMUFile *f, void *opaq= ue) =20 if (!migrate_multifd_flush_after_each_section()) { qemu_put_be64(f, RAM_SAVE_FLAG_MULTIFD_FLUSH); + size +=3D 8; } qemu_put_be64(f, RAM_SAVE_FLAG_EOS); + size +=3D 8; + stat64_add(&mig_stats.transferred, size); qemu_fflush(f); =20 return 0; diff --git a/migration/savevm.c b/migration/savevm.c index e33788343a..c7af9050c2 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -952,6 +952,7 @@ static void save_section_header(QEMUFile *f, SaveStateE= ntry *se, qemu_put_byte(f, section_type); qemu_put_be32(f, se->section_id); =20 + size_t size =3D 1 + 4; if (section_type =3D=3D QEMU_VM_SECTION_FULL || section_type =3D=3D QEMU_VM_SECTION_START) { /* ID string */ @@ -961,7 +962,9 @@ static void save_section_header(QEMUFile *f, SaveStateE= ntry *se, =20 qemu_put_be32(f, se->instance_id); qemu_put_be32(f, se->version_id); + size +=3D 1 + len + 4 + 4; } + stat64_add(&mig_stats.transferred, size); } =20 /* @@ -973,6 +976,7 @@ static void save_section_footer(QEMUFile *f, SaveStateE= ntry *se) if (migrate_get_current()->send_section_footer) { qemu_put_byte(f, QEMU_VM_SECTION_FOOTER); qemu_put_be32(f, se->section_id); + stat64_add(&mig_stats.transferred, 1 + 4); } } =20 @@ -1032,6 +1036,7 @@ static void qemu_savevm_command_send(QEMUFile *f, qemu_put_be16(f, (uint16_t)command); qemu_put_be16(f, len); qemu_put_buffer(f, data, len); + stat64_add(&mig_stats.transferred, 1 + 2 + 2 + len); qemu_fflush(f); } =20 @@ -1212,11 +1217,13 @@ void qemu_savevm_state_header(QEMUFile *f) trace_savevm_state_header(); qemu_put_be32(f, QEMU_VM_FILE_MAGIC); qemu_put_be32(f, QEMU_VM_FILE_VERSION); - + size_t size =3D 4 + 4; if (migrate_get_current()->send_configuration) { qemu_put_byte(f, QEMU_VM_CONFIGURATION); + size +=3D 1; vmstate_save_state(f, &vmstate_configuration, &savevm_state, 0); } + stat64_add(&mig_stats.transferred, size); } =20 bool qemu_savevm_state_guest_unplug_pending(void) @@ -1384,6 +1391,7 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f) { SaveStateEntry *se; int ret; + size_t size =3D 0; =20 QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { if (!se->ops || !se->ops->save_live_complete_postcopy) { @@ -1398,7 +1406,7 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f) /* Section type */ qemu_put_byte(f, QEMU_VM_SECTION_END); qemu_put_be32(f, se->section_id); - + size +=3D 1 + 4; ret =3D se->ops->save_live_complete_postcopy(f, se->opaque); trace_savevm_section_end(se->idstr, se->section_id, ret); save_section_footer(f, se); @@ -1409,6 +1417,8 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f) } =20 qemu_put_byte(f, QEMU_VM_EOF); + size +=3D 1; + stat64_add(&mig_stats.transferred, size); qemu_fflush(f); } =20 @@ -1484,6 +1494,7 @@ int qemu_savevm_state_complete_precopy_non_iterable(Q= EMUFile *f, if (!in_postcopy) { /* Postcopy stream will still be going */ qemu_put_byte(f, QEMU_VM_EOF); + stat64_add(&mig_stats.transferred, 1); } =20 json_writer_end_array(vmdesc); @@ -1664,15 +1675,18 @@ void qemu_savevm_live_state(QEMUFile *f) /* save QEMU_VM_SECTION_END section */ qemu_savevm_state_complete_precopy(f, true, false); qemu_put_byte(f, QEMU_VM_EOF); + stat64_add(&mig_stats.transferred, 1); } =20 int qemu_save_device_state(QEMUFile *f) { SaveStateEntry *se; + size_t size =3D 0; =20 if (!migration_in_colo_state()) { qemu_put_be32(f, QEMU_VM_FILE_MAGIC); qemu_put_be32(f, QEMU_VM_FILE_VERSION); + size =3D 4 + 4; } cpu_synchronize_all_states(); =20 @@ -1690,6 +1704,7 @@ int qemu_save_device_state(QEMUFile *f) =20 qemu_put_byte(f, QEMU_VM_EOF); =20 + stat64_add(&mig_stats.transferred, size + 1); return qemu_file_get_error(f); } =20 diff --git a/migration/vmstate.c b/migration/vmstate.c index af01d54b6f..ee3b70a6a8 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -12,6 +12,7 @@ =20 #include "qemu/osdep.h" #include "migration.h" +#include "migration-stats.h" #include "migration/vmstate.h" #include "savevm.h" #include "qapi/qmp/json-writer.h" @@ -394,6 +395,7 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDesc= ription *vmsd, written_bytes =3D qemu_file_transferred_fast(f) - old_offs= et; vmsd_desc_field_end(vmsd, vmdesc_loop, field, written_byte= s, i); =20 + stat64_add(&mig_stats.transferred, written_bytes); /* Compressed arrays only care about the first element */ if (vmdesc_loop && vmsd_can_compress(field)) { vmdesc_loop =3D NULL; @@ -517,6 +519,7 @@ static int vmstate_subsection_save(QEMUFile *f, const V= MStateDescription *vmsd, qemu_put_byte(f, len); qemu_put_buffer(f, (uint8_t *)vmsdsub->name, len); qemu_put_be32(f, vmsdsub->version_id); + stat64_add(&mig_stats.transferred, 1 + 1 + len + 4); ret =3D vmstate_save_state(f, vmsdsub, opaque, vmdesc); if (ret) { return ret; --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551492; cv=none; d=zohomail.com; s=zohoarc; b=EFiv7M0cSrDY54t0j/7FApw5vpxdP2CM71YzJmQ2YzdnPfEKKV6sYI+eahDCKe4TF7PAVanR63fbvA5OeN85y3UCtChYsjBTpETj7WeAyftURHvRjnrSXyyevHLkTYZcBOFDCSoddictAAmf+MRKWkNfP2vHx91F/ctA7A9WO4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551492; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=x0/64K/qSP6S4qwokn5M1j0REskez/N1l4Un71CnZyM=; b=COLeN6+EgYQ8lbjBGdGfzgNTOLUYpzvAMAfviI+unDcS3BHqTi7iLdYbPTFzyCTY1tJ0V14Gz/u4zWZE+uHb/y27VSMPS1g9KPhhT39QINnlsop6t1axldMd+dI7+3mtXktsFbqZgSK0OalyT2ekK1Ix3eCPTX0xqcH6yylRmAM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168355149233236.35185334606092; Mon, 8 May 2023 06:11:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0e1-0004cb-8R; Mon, 08 May 2023 09:11:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0dN-00040W-86 for qemu-devel@nongnu.org; Mon, 08 May 2023 09:10:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0dD-00012Y-1j for qemu-devel@nongnu.org; Mon, 08 May 2023 09:10:24 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-29-4kVC3C01PCy7cgz6l21Pog-1; Mon, 08 May 2023 09:10:14 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6AD27100F658; Mon, 8 May 2023 13:10:13 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F6BF2166B40; Mon, 8 May 2023 13:10:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551417; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x0/64K/qSP6S4qwokn5M1j0REskez/N1l4Un71CnZyM=; b=GYHWx6Donll6PTPf2KfGXbYCn85W6byhpTInIbNKR06euOS/gLtQuQD7sDdN24WiFiNEHR UjQ7EezN3FnbqSVIxjr7/OoF4dMt32lwUhYYbdBL9gkJVYQ3bA2BrquGmNnKQF7jxSvJs8 IGQbuWO0jVV2NyDF2vtC1Y/DiKgutFY= X-MC-Unique: 4kVC3C01PCy7cgz6l21Pog-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 08/21] migration: Move setup_time to mig_stats Date: Mon, 8 May 2023 15:08:56 +0200 Message-Id: <20230508130909.65420-9-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551498391100001 Content-Type: text/plain; charset="utf-8" It is a time that needs to be cleaned each time cancel migration. Once there ccreate calculate_time_since() to calculate how time since a time in the past. Signed-off-by: Juan Quintela --- migration/migration-stats.c | 7 +++++++ migration/migration-stats.h | 14 ++++++++++++++ migration/migration.c | 9 ++++----- migration/migration.h | 1 - 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/migration/migration-stats.c b/migration/migration-stats.c index 2f2cea965c..5278c6c821 100644 --- a/migration/migration-stats.c +++ b/migration/migration-stats.c @@ -12,6 +12,13 @@ =20 #include "qemu/osdep.h" #include "qemu/stats64.h" +#include "qemu/timer.h" #include "migration-stats.h" =20 MigrationAtomicStats mig_stats; + +void calculate_time_since(Stat64 *val, int64_t since) +{ + int64_t now =3D qemu_clock_get_ms(QEMU_CLOCK_HOST); + stat64_set(val, now - since); +} diff --git a/migration/migration-stats.h b/migration/migration-stats.h index cf8a4f0410..73c73d75b9 100644 --- a/migration/migration-stats.h +++ b/migration/migration-stats.h @@ -69,6 +69,10 @@ typedef struct { * Number of bytes sent during precopy stage. */ Stat64 precopy_bytes; + /* + * How long has the setup stage took. + */ + Stat64 setup_time; /* * Total number of bytes transferred. */ @@ -81,4 +85,14 @@ typedef struct { =20 extern MigrationAtomicStats mig_stats; =20 +/** + * calculate_time_since: Calculate how much time has passed + * + * @val: stat64 where to store the time + * @since: reference time since we want to calculate + * + * Returns: Nothing. The time is stored in val. + */ + +void calculate_time_since(Stat64 *val, int64_t since); #endif diff --git a/migration/migration.c b/migration/migration.c index b1cfb56523..72286de969 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -884,7 +884,7 @@ static void populate_time_info(MigrationInfo *info, Mig= rationState *s) { info->has_status =3D true; info->has_setup_time =3D true; - info->setup_time =3D s->setup_time; + info->setup_time =3D stat64_get(&mig_stats.setup_time); =20 if (s->state =3D=3D MIGRATION_STATUS_COMPLETED) { info->has_total_time =3D true; @@ -1387,7 +1387,6 @@ void migrate_init(MigrationState *s) s->pages_per_second =3D 0.0; s->downtime =3D 0; s->expected_downtime =3D 0; - s->setup_time =3D 0; s->start_postcopy =3D false; s->postcopy_after_devices =3D false; s->migration_thread_running =3D false; @@ -2640,7 +2639,7 @@ static void migration_calculate_complete(MigrationSta= te *s) s->downtime =3D end_time - s->downtime_start; } =20 - transfer_time =3D s->total_time - s->setup_time; + transfer_time =3D s->total_time - stat64_get(&mig_stats.setup_time); if (transfer_time) { s->mbps =3D ((double) bytes * 8.0) / transfer_time / 1000; } @@ -2965,7 +2964,7 @@ static void *migration_thread(void *opaque) qemu_savevm_wait_unplug(s, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_ACTIVE); =20 - s->setup_time =3D qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start; + calculate_time_since(&mig_stats.setup_time, setup_start); =20 trace_migration_thread_setup_complete(); =20 @@ -3077,7 +3076,7 @@ static void *bg_migration_thread(void *opaque) qemu_savevm_wait_unplug(s, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_ACTIVE); =20 - s->setup_time =3D qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start; + calculate_time_since(&mig_stats.setup_time, setup_start); =20 trace_migration_thread_setup_complete(); s->downtime_start =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); diff --git a/migration/migration.h b/migration/migration.h index 3a918514e7..7f554455ac 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -311,7 +311,6 @@ struct MigrationState { int64_t downtime; int64_t expected_downtime; bool capabilities[MIGRATION_CAPABILITY__MAX]; - int64_t setup_time; /* * Whether guest was running when we enter the completion stage. * If migration is interrupted by any reason, we need to continue --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551542; cv=none; d=zohomail.com; s=zohoarc; b=nnWuFpVCjhsKfq/YmbzWnh1FCEViBYRMxjHa56oyFFSSgnWHmjxrun633kuUrsFApos1wU5w2Ggt3dKDmyG9bGFuKm/a4qXIAjXy3B9AZxR1MbutWFcSO6Q3QUL+HceFGU7wjCZiVT/d0ptJNg3XK9yE5Wqu9ilkPEW4dIDB69U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551542; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=H/hKGndNrp0PsXrFDZ6n1QgzwLLa55x5VOyYS7RgSyU=; b=i0DFEAXdBoa1t3fbb9n5XlAUtYBkYD5oPX2jl0BI8Qf3wvehHKTlUkGNsKc2yTiHsZQwW91SuYYWpMDGFQ4jmdKS6WNwvdAQjKAitx+fjywiS5Oz5a6Hz0vorfbQ3H7kRpvB+sCfaAxYE2dtX+x42xJdr+tdDdT14lnFFrZzM/4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683551542493736.3433411483176; Mon, 8 May 2023 06:12:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0eE-0005dp-Nr; Mon, 08 May 2023 09:11:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0dQ-00043J-9E for qemu-devel@nongnu.org; Mon, 08 May 2023 09:10:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0dD-00013H-4f for qemu-devel@nongnu.org; Mon, 08 May 2023 09:10:31 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-442-fVKP_jbxMTWcxRe3rNcgbg-1; Mon, 08 May 2023 09:10:19 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F393C1C0950E; Mon, 8 May 2023 13:10:17 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id B63A42166B40; Mon, 8 May 2023 13:10:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551422; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H/hKGndNrp0PsXrFDZ6n1QgzwLLa55x5VOyYS7RgSyU=; b=cEczX0/VOT+N0hynt8gdpKox4PLaQVGRNitV1XokXmw9+nsW0zwNlFb5Bo+zppdMEwZf/h Z+bnnQquPj4hOcgPXB6Fe+v2Ux+t7Dy/aGHgvti3orpZTB/vt8rELvg4FWhGVCmhPYXPS+ RDPru8dgKfmon7AOErafoI+4XCddumo= X-MC-Unique: fVKP_jbxMTWcxRe3rNcgbg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 09/21] qemu-file: Account for rate_limit usage on qemu_fflush() Date: Mon, 8 May 2023 15:08:57 +0200 Message-Id: <20230508130909.65420-10-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551544492100001 Content-Type: text/plain; charset="utf-8" That is the moment we know we have transferred something. Signed-off-by: Juan Quintela Reviewed-by: C=C3=A9dric Le Goater --- migration/qemu-file.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 6ebc2bd3ec..8de1ecd082 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -301,7 +301,9 @@ void qemu_fflush(QEMUFile *f) &local_error) < 0) { qemu_file_set_error_obj(f, -EIO, local_error); } else { - f->total_transferred +=3D iov_size(f->iov, f->iovcnt); + uint64_t size =3D iov_size(f->iov, f->iovcnt); + qemu_file_acct_rate_limit(f, size); + f->total_transferred +=3D size; } =20 qemu_iovec_release_ram(f); @@ -518,7 +520,6 @@ void qemu_put_buffer_async(QEMUFile *f, const uint8_t *= buf, size_t size, return; } =20 - f->rate_limit_used +=3D size; add_to_iovec(f, buf, size, may_free); } =20 @@ -536,7 +537,6 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, s= ize_t size) l =3D size; } memcpy(f->buf + f->buf_index, buf, l); - f->rate_limit_used +=3D l; add_buf_to_iovec(f, l); if (qemu_file_get_error(f)) { break; @@ -553,7 +553,6 @@ void qemu_put_byte(QEMUFile *f, int v) } =20 f->buf[f->buf_index] =3D v; - f->rate_limit_used++; add_buf_to_iovec(f, 1); } =20 --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551685; cv=none; d=zohomail.com; s=zohoarc; b=iokuTzmCVlGXfUvNdEyCoxeJZwiNnqjRCNCCmh1KiK8aQVpogZWbf0CEogpi8ka1eLpbOUkShUUXhJmwxVTgrz4B2PbeIVh8SRXrc+T+V9wPl1MFGOy7WTWTghWafYU8LztZbtA3Qg1HKK/6JeeIC026m1PyavlWoN/A6He6oak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551685; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8ggDepUiU3Ico3Wyr8zvEIW3dkO/SQNMYUXWDzbwm9Q=; b=NWQ1q880rrpyav9Pa6qsEUk0K/+l45Er8Bo8PxA5mQcqFMX6N+79p/d/bu0ktghf/L1F0ao1XWs7NBt1i2MW4aMkB34wtIkRMCTyDWtb5wp+qcJDNDCm5N4DxHSZX1TSNishVhr1pzbX6L/DgzDPoQ8Y2WqECMmYbUjpic7xSWQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683551685817458.5939456012293; Mon, 8 May 2023 06:14:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0eR-0007L6-Tb; Mon, 08 May 2023 09:11:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0e0-0004cg-6D for qemu-devel@nongnu.org; Mon, 08 May 2023 09:11:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0de-00014m-P3 for qemu-devel@nongnu.org; Mon, 08 May 2023 09:10:57 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-240-Aq3p38OUOyydGcrjQssTaw-1; Mon, 08 May 2023 09:10:24 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A04B81C0950A; Mon, 8 May 2023 13:10:23 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52F882166B40; Mon, 8 May 2023 13:10:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551429; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8ggDepUiU3Ico3Wyr8zvEIW3dkO/SQNMYUXWDzbwm9Q=; b=TxFkuGPRgx3QXIE62Gk+egP+Ikv3PtDA9kMdkJGdPnX08G5ejO06dhF0yE61xysdx4xOPx W3wwAw7UiLYGGpar0n6rrDTVJIltkgVsdvtYgY74E5w8H/jPlkXqPxgSbodL95JII9hIf5 nas3T2Qs2liHjLPOUGLnfLIMXoozaQg= X-MC-Unique: Aq3p38OUOyydGcrjQssTaw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 10/21] migration: Move rate_limit_max and rate_limit_used to migration_stats Date: Mon, 8 May 2023 15:08:58 +0200 Message-Id: <20230508130909.65420-11-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551687914100001 Content-Type: text/plain; charset="utf-8" This way we can make them atomic and use this functions from any place. I also moved all functions that use rate_limit to migration-stats. Functions got renamed, they are not qemu_file anymore. qemu_file_rate_limit -> migration_rate_limit_exceeded qemu_file_set_rate_limit -> migration_rate_limit_set qemu_file_get_rate_limit -> migration_rate_limit_get qemu_file_reset_rate_limit -> migration_rate_limit_reset qemu_file_acct_rate_limit -> migration_rate_limit_account. Signed-off-by: Juan Quintela Reviewed-by: Harsh Prateek Bora --- If you have any good suggestion for better names, I am all ears. --- hw/ppc/spapr.c | 5 +-- hw/s390x/s390-stattrib.c | 2 +- include/migration/qemu-file-types.h | 2 +- migration/block-dirty-bitmap.c | 2 +- migration/block.c | 5 +-- migration/migration-stats.c | 41 ++++++++++++++++++++++ migration/migration-stats.h | 42 +++++++++++++++++++++++ migration/migration.c | 14 ++++---- migration/multifd.c | 2 +- migration/options.c | 7 ++-- migration/qemu-file.c | 53 ++--------------------------- migration/qemu-file.h | 11 ------ migration/ram.c | 2 +- migration/savevm.c | 2 +- 14 files changed, 108 insertions(+), 82 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index ddc9c7b1a1..dbd2753278 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2166,7 +2166,7 @@ static void htab_save_first_pass(QEMUFile *f, SpaprMa= chineState *spapr, break; } } - } while ((index < htabslots) && !qemu_file_rate_limit(f)); + } while ((index < htabslots) && !migration_rate_limit_exceeded(f)); =20 if (index >=3D htabslots) { assert(index =3D=3D htabslots); @@ -2237,7 +2237,8 @@ static int htab_save_later_pass(QEMUFile *f, SpaprMac= hineState *spapr, assert(index =3D=3D htabslots); index =3D 0; } - } while ((examined < htabslots) && (!qemu_file_rate_limit(f) || final)= ); + } while ((examined < htabslots) && + (!migration_rate_limit_exceeded(f) || final)); =20 if (index >=3D htabslots) { assert(index =3D=3D htabslots); diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c index aed919ad7d..fb0a20f2e1 100644 --- a/hw/s390x/s390-stattrib.c +++ b/hw/s390x/s390-stattrib.c @@ -209,7 +209,7 @@ static int cmma_save(QEMUFile *f, void *opaque, int fin= al) return -ENOMEM; } =20 - while (final ? 1 : qemu_file_rate_limit(f) =3D=3D 0) { + while (final ? 1 : migration_rate_limit_exceeded(f) =3D=3D 0) { reallen =3D sac->get_stattr(sas, &start_gfn, buflen, buf); if (reallen < 0) { g_free(buf); diff --git a/include/migration/qemu-file-types.h b/include/migration/qemu-f= ile-types.h index 1436f9ce92..0354f45198 100644 --- a/include/migration/qemu-file-types.h +++ b/include/migration/qemu-file-types.h @@ -165,6 +165,6 @@ size_t coroutine_mixed_fn qemu_get_counted_string(QEMUF= ile *f, char buf[256]); =20 void qemu_put_counted_string(QEMUFile *f, const char *name); =20 -int qemu_file_rate_limit(QEMUFile *f); +bool migration_rate_limit_exceeded(QEMUFile *f); =20 #endif diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 20f36e6bd8..a815678926 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -706,7 +706,7 @@ static void bulk_phase(QEMUFile *f, DBMSaveState *s, bo= ol limit) QSIMPLEQ_FOREACH(dbms, &s->dbms_list, entry) { while (!dbms->bulk_completed) { bulk_phase_send_chunk(f, s, dbms); - if (limit && qemu_file_rate_limit(f)) { + if (limit && migration_rate_limit_exceeded(f)) { return; } } diff --git a/migration/block.c b/migration/block.c index 12617b4152..fc1caa9ca6 100644 --- a/migration/block.c +++ b/migration/block.c @@ -23,6 +23,7 @@ #include "block/dirty-bitmap.h" #include "migration/misc.h" #include "migration.h" +#include "migration-stats.h" #include "migration/register.h" #include "qemu-file.h" #include "migration/vmstate.h" @@ -625,7 +626,7 @@ static int flush_blks(QEMUFile *f) =20 blk_mig_lock(); while ((blk =3D QSIMPLEQ_FIRST(&block_mig_state.blk_list)) !=3D NULL) { - if (qemu_file_rate_limit(f)) { + if (migration_rate_limit_exceeded(f)) { break; } if (blk->ret < 0) { @@ -762,7 +763,7 @@ static int block_save_iterate(QEMUFile *f, void *opaque) /* control the rate of transfer */ blk_mig_lock(); while (block_mig_state.read_done * BLK_MIG_BLOCK_SIZE < - qemu_file_get_rate_limit(f) && + migration_rate_limit_get() && block_mig_state.submitted < MAX_PARALLEL_IO && (block_mig_state.submitted + block_mig_state.read_done) < MAX_IO_BUFFERS) { diff --git a/migration/migration-stats.c b/migration/migration-stats.c index 5278c6c821..e01842cabc 100644 --- a/migration/migration-stats.c +++ b/migration/migration-stats.c @@ -13,6 +13,7 @@ #include "qemu/osdep.h" #include "qemu/stats64.h" #include "qemu/timer.h" +#include "qemu-file.h" #include "migration-stats.h" =20 MigrationAtomicStats mig_stats; @@ -22,3 +23,43 @@ void calculate_time_since(Stat64 *val, int64_t since) int64_t now =3D qemu_clock_get_ms(QEMU_CLOCK_HOST); stat64_set(val, now - since); } + +bool migration_rate_limit_exceeded(QEMUFile *f) +{ + if (qemu_file_get_error(f)) { + return true; + } + + uint64_t rate_limit_used =3D stat64_get(&mig_stats.rate_limit_used); + uint64_t rate_limit_max =3D stat64_get(&mig_stats.rate_limit_max); + /* + * rate_limit_max =3D=3D 0 means no rate_limit enfoncement. + */ + if (rate_limit_max > 0 && rate_limit_used > rate_limit_max) { + return true; + } + return false; +} + +uint64_t migration_rate_limit_get(void) +{ + return stat64_get(&mig_stats.rate_limit_max); +} + +void migration_rate_limit_set(uint64_t limit) +{ + /* + * 'limit' is per second. But we check it each BUFER_DELAY milisecond= s. + */ + stat64_set(&mig_stats.rate_limit_max, limit); +} + +void migration_rate_limit_reset(void) +{ + stat64_set(&mig_stats.rate_limit_used, 0); +} + +void migration_rate_limit_account(uint64_t len) +{ + stat64_add(&mig_stats.rate_limit_used, len); +} diff --git a/migration/migration-stats.h b/migration/migration-stats.h index 73c73d75b9..65f11ec7d1 100644 --- a/migration/migration-stats.h +++ b/migration/migration-stats.h @@ -69,6 +69,14 @@ typedef struct { * Number of bytes sent during precopy stage. */ Stat64 precopy_bytes; + /* + * Maximum amount of data we can send in a cycle. + */ + Stat64 rate_limit_max; + /* + * Amount of data we have sent in the current cycle. + */ + Stat64 rate_limit_used; /* * How long has the setup stage took. */ @@ -95,4 +103,38 @@ extern MigrationAtomicStats mig_stats; */ =20 void calculate_time_since(Stat64 *val, int64_t since); + +/** + * migration_rate_limit_account: Increase the number of bytes transferred. + * + * Report on a number of bytes the have been transferred that need to + * be applied to the rate limiting calcuations. + * + * @len: amount of bytes transferred + */ +void migration_rate_limit_account(uint64_t len); + +/** + * migration_rate_limit_get: Get the maximum amount that can be transferre= d. + * + * Returns the maximum number of bytes that can be transferred in a cycle. + */ +uint64_t migration_rate_limit_get(void); + +/** + * migration_rate_limit_reset: Reset the rate limit counter. + * + * This is called when we know we start a new transfer cycle. + */ +void migration_rate_limit_reset(void); + +/** + * migration_rate_limit_set: Set the maximum amount that can be transferre= d. + * + * Sets the maximum amount of bytes that can be transferred in one cycle. + * + * @new_rate: new maximum amount + */ +void migration_rate_limit_set(uint64_t new_rate); + #endif diff --git a/migration/migration.c b/migration/migration.c index 72286de969..370998600e 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2116,7 +2116,7 @@ static int postcopy_start(MigrationState *ms) * will notice we're in POSTCOPY_ACTIVE and not actually * wrap their state up here */ - qemu_file_set_rate_limit(ms->to_dst_file, bandwidth); + migration_rate_limit_set(bandwidth); if (migrate_postcopy_ram()) { /* Ping just for debugging, helps line traces up */ qemu_savevm_send_ping(ms->to_dst_file, 2); @@ -2295,7 +2295,7 @@ static void migration_completion(MigrationState *s) } if (ret >=3D 0) { s->block_inactive =3D !migrate_colo(); - qemu_file_set_rate_limit(s->to_dst_file, 0); + migration_rate_limit_set(0); ret =3D qemu_savevm_state_complete_precopy(s->to_dst_file,= false, s->block_inactive= ); } @@ -2691,7 +2691,7 @@ static void migration_update_counters(MigrationState = *s, stat64_get(&mig_stats.dirty_bytes_last_sync) / bandwidth; } =20 - qemu_file_reset_rate_limit(s->to_dst_file); + migration_rate_limit_reset(); =20 update_iteration_initial_status(s); =20 @@ -2847,7 +2847,7 @@ bool migration_rate_limit(void) =20 bool urgent =3D false; migration_update_counters(s, now); - if (qemu_file_rate_limit(s->to_dst_file)) { + if (migration_rate_limit_exceeded(s->to_dst_file)) { =20 if (qemu_file_get_error(s->to_dst_file)) { return false; @@ -2969,7 +2969,7 @@ static void *migration_thread(void *opaque) trace_migration_thread_setup_complete(); =20 while (migration_is_active(s)) { - if (urgent || !qemu_file_rate_limit(s->to_dst_file)) { + if (urgent || !migration_rate_limit_exceeded(s->to_dst_file)) { MigIterateState iter_state =3D migration_iteration_run(s); if (iter_state =3D=3D MIG_ITERATE_SKIP) { continue; @@ -3043,7 +3043,7 @@ static void *bg_migration_thread(void *opaque) rcu_register_thread(); object_ref(OBJECT(s)); =20 - qemu_file_set_rate_limit(s->to_dst_file, 0); + migration_rate_limit_set(0); =20 setup_start =3D qemu_clock_get_ms(QEMU_CLOCK_HOST); /* @@ -3215,7 +3215,7 @@ void migrate_fd_connect(MigrationState *s, Error *err= or_in) notifier_list_notify(&migration_state_notifiers, s); } =20 - qemu_file_set_rate_limit(s->to_dst_file, rate_limit); + migration_rate_limit_set(rate_limit); qemu_file_set_blocking(s->to_dst_file, true); =20 /* diff --git a/migration/multifd.c b/migration/multifd.c index 4e71c19292..2efb313be4 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -432,7 +432,7 @@ static int multifd_send_pages(QEMUFile *f) multifd_send_state->pages =3D p->pages; p->pages =3D pages; transferred =3D ((uint64_t) pages->num) * p->page_size + p->packet_len; - qemu_file_acct_rate_limit(f, transferred); + migration_rate_limit_account(transferred); qemu_mutex_unlock(&p->mutex); stat64_add(&mig_stats.transferred, transferred); stat64_add(&mig_stats.multifd_bytes, transferred); diff --git a/migration/options.c b/migration/options.c index d04b5fbc3a..a024fa3ce6 100644 --- a/migration/options.c +++ b/migration/options.c @@ -23,6 +23,7 @@ #include "migration/colo.h" #include "migration/misc.h" #include "migration.h" +#include "migration-stats.h" #include "qemu-file.h" #include "ram.h" #include "options.h" @@ -1242,8 +1243,7 @@ static void migrate_params_apply(MigrateSetParameters= *params, Error **errp) if (params->has_max_bandwidth) { s->parameters.max_bandwidth =3D params->max_bandwidth; if (s->to_dst_file && !migration_in_postcopy()) { - qemu_file_set_rate_limit(s->to_dst_file, - s->parameters.max_bandwidth); + migration_rate_limit_set(s->parameters.max_bandwidth); } } =20 @@ -1274,8 +1274,7 @@ static void migrate_params_apply(MigrateSetParameters= *params, Error **errp) if (params->has_max_postcopy_bandwidth) { s->parameters.max_postcopy_bandwidth =3D params->max_postcopy_band= width; if (s->to_dst_file && migration_in_postcopy()) { - qemu_file_set_rate_limit(s->to_dst_file, - s->parameters.max_postcopy_bandwidth); + migration_rate_limit_set(s->parameters.max_postcopy_bandwidth); } } if (params->has_max_cpu_throttle) { diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 8de1ecd082..3f993e24af 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -27,6 +27,7 @@ #include "qemu/error-report.h" #include "qemu/iov.h" #include "migration.h" +#include "migration-stats.h" #include "qemu-file.h" #include "trace.h" #include "options.h" @@ -40,17 +41,6 @@ struct QEMUFile { QIOChannel *ioc; bool is_writable; =20 - /* - * Maximum amount of data in bytes to transfer during one - * rate limiting time window - */ - uint64_t rate_limit_max; - /* - * Total amount of data in bytes queued for transfer - * during this rate limiting time window - */ - uint64_t rate_limit_used; - /* The sum of bytes transferred on the wire */ uint64_t total_transferred; =20 @@ -302,7 +292,7 @@ void qemu_fflush(QEMUFile *f) qemu_file_set_error_obj(f, -EIO, local_error); } else { uint64_t size =3D iov_size(f->iov, f->iovcnt); - qemu_file_acct_rate_limit(f, size); + migration_rate_limit_account(size); f->total_transferred +=3D size; } =20 @@ -355,7 +345,7 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t bl= ock_offset, int ret =3D f->hooks->save_page(f, block_offset, offset, size, bytes_sent); if (ret !=3D RAM_SAVE_CONTROL_NOT_SUPP) { - qemu_file_acct_rate_limit(f, size); + migration_rate_limit_account(size); } =20 if (ret !=3D RAM_SAVE_CONTROL_DELAYED && @@ -726,43 +716,6 @@ uint64_t qemu_file_transferred(QEMUFile *f) return f->total_transferred; } =20 -int qemu_file_rate_limit(QEMUFile *f) -{ - if (qemu_file_get_error(f)) { - return 1; - } - /* - * rate_limit_max =3D=3D 0 means no rate_limit enfoncement. - */ - if (f->rate_limit_max > 0 && f->rate_limit_used > f->rate_limit_max) { - return 1; - } - return 0; -} - -uint64_t qemu_file_get_rate_limit(QEMUFile *f) -{ - return f->rate_limit_max; -} - -void qemu_file_set_rate_limit(QEMUFile *f, uint64_t limit) -{ - /* - * 'limit' is per second. But we check it each 100 miliseconds. - */ - f->rate_limit_max =3D limit / XFER_LIMIT_RATIO; -} - -void qemu_file_reset_rate_limit(QEMUFile *f) -{ - f->rate_limit_used =3D 0; -} - -void qemu_file_acct_rate_limit(QEMUFile *f, uint64_t len) -{ - f->rate_limit_used +=3D len; -} - void qemu_put_be16(QEMUFile *f, unsigned int v) { qemu_put_byte(f, v >> 8); diff --git a/migration/qemu-file.h b/migration/qemu-file.h index ab164a58d0..46029b951c 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -129,17 +129,6 @@ void qemu_file_skip(QEMUFile *f, int size); * accounting information tracks the total migration traffic. */ void qemu_file_credit_transfer(QEMUFile *f, size_t size); -void qemu_file_reset_rate_limit(QEMUFile *f); -/* - * qemu_file_acct_rate_limit: - * - * Report on a number of bytes the have been transferred - * out of band from the main file object I/O methods, and - * need to be applied to the rate limiting calcuations - */ -void qemu_file_acct_rate_limit(QEMUFile *f, uint64_t len); -void qemu_file_set_rate_limit(QEMUFile *f, uint64_t new_rate); -uint64_t qemu_file_get_rate_limit(QEMUFile *f); int qemu_file_get_error_obj(QEMUFile *f, Error **errp); int qemu_file_get_error_obj_any(QEMUFile *f1, QEMUFile *f2, Error **errp); void qemu_file_set_error_obj(QEMUFile *f, int ret, Error *err); diff --git a/migration/ram.c b/migration/ram.c index 5ae1fdba45..2339a99932 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3351,7 +3351,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) =20 t0 =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); i =3D 0; - while ((ret =3D qemu_file_rate_limit(f)) =3D=3D 0 || + while ((ret =3D migration_rate_limit_exceeded(f)) =3D=3D 0 || postcopy_has_request(rs)) { int pages; =20 diff --git a/migration/savevm.c b/migration/savevm.c index c7af9050c2..376118bc98 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1345,7 +1345,7 @@ int qemu_savevm_state_iterate(QEMUFile *f, bool postc= opy) !(se->ops->has_postcopy && se->ops->has_postcopy(se->opaque)))= { continue; } - if (qemu_file_rate_limit(f)) { + if (migration_rate_limit_exceeded(f)) { return 0; } trace_savevm_section_start(se->idstr, se->section_id); --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551506; cv=none; d=zohomail.com; s=zohoarc; b=M2SsCOhTgCuCnQHczHITCeON6WqHratk3XFVM1J46yNR7IbuIq8LwYMoH6ItOtFBk4sVX3QGjOEkrlSgKWbJb4PtAIJ5cK3vH3XcT/wjXQrFGTLF6aYv9KlbJzc9WMyr+GdfRRbXHyJ5HZfFKj9mxDC9OsxzIh4kh6e7ayuw0k0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551506; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zxVq3XMHcGOljMpMBdbQV6LRAPheG9dTdkNJsu4Wxvk=; b=MyIwk1Wmosz8UMjQy63K3Z+HiMOzgjwNrUXpBBt+BkD2MiVazV0c2NRnsRMvBrXJ23nCC3rTXYt+005GxLzLJ7nyYhE1lVPe+ffiP1oQYGjd9rtVFFI4uQxLS6PlG4U75P+g90DbEbhF9cVm6BEAZjTTFkkOsGxiFSrG2CTdKe0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683551506843193.07442540987665; Mon, 8 May 2023 06:11:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0eN-0006vH-Sg; Mon, 08 May 2023 09:11:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0e0-0004cp-AM for qemu-devel@nongnu.org; Mon, 08 May 2023 09:11:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0df-000170-QN for qemu-devel@nongnu.org; Mon, 08 May 2023 09:10:56 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-517-GbgUA867OWOf3uw9t8EYMw-1; Mon, 08 May 2023 09:10:28 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B5B9D2806065; Mon, 8 May 2023 13:10:27 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA94C2166B41; Mon, 8 May 2023 13:10:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551432; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zxVq3XMHcGOljMpMBdbQV6LRAPheG9dTdkNJsu4Wxvk=; b=EofCp2+7cDuomo2W5L82WQf/FMTWaV2sqfpwrXgTO1+vWNsOUck7McUooqO9Eb9gMH7+yy EhRXQC2uvNpc/Xqt/nX9igqr1jC64JSAXKCrWhbN9noTX6z2q6z+O2I5JFahS1/oBqMc9f zEBKxO3kxp1ElJEW/WZTgJl9hXIeZLk= X-MC-Unique: GbgUA867OWOf3uw9t8EYMw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 11/21] migration: Move migration_total_bytes() to migration-stats.c Date: Mon, 8 May 2023 15:08:59 +0200 Message-Id: <20230508130909.65420-12-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551508879100003 Content-Type: text/plain; charset="utf-8" Once there rename it to migration_transferred_bytes() and pass a QEMUFile instead of a migration object. Signed-off-by: Juan Quintela Reviewed-by: C=C3=A9dric Le Goater --- migration/migration-stats.c | 6 ++++++ migration/migration-stats.h | 9 +++++++++ migration/migration.c | 13 +++---------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/migration/migration-stats.c b/migration/migration-stats.c index e01842cabc..fba66c4577 100644 --- a/migration/migration-stats.c +++ b/migration/migration-stats.c @@ -63,3 +63,9 @@ void migration_rate_limit_account(uint64_t len) { stat64_add(&mig_stats.rate_limit_used, len); } + +uint64_t migration_transferred_bytes(QEMUFile *f) +{ + return qemu_file_transferred(f) + stat64_get(&mig_stats.multifd_bytes); +} + diff --git a/migration/migration-stats.h b/migration/migration-stats.h index 65f11ec7d1..c82fce9608 100644 --- a/migration/migration-stats.h +++ b/migration/migration-stats.h @@ -137,4 +137,13 @@ void migration_rate_limit_reset(void); */ void migration_rate_limit_set(uint64_t new_rate); =20 +/** + * migration_transferred_bytes: Return number of bytes transferred + * + * Returtns how many bytes have we transferred since the beginning of + * the migration. It accounts for bytes sent through any migration + * channel, multifd, qemu_file, rdma, .... + */ +uint64_t migration_transferred_bytes(QEMUFile *f); + #endif diff --git a/migration/migration.c b/migration/migration.c index 370998600e..e6d262ffe1 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2617,16 +2617,9 @@ static MigThrError migration_detect_error(MigrationS= tate *s) } } =20 -/* How many bytes have we transferred since the beginning of the migration= */ -static uint64_t migration_total_bytes(MigrationState *s) -{ - return qemu_file_transferred(s->to_dst_file) + - stat64_get(&mig_stats.multifd_bytes); -} - static void migration_calculate_complete(MigrationState *s) { - uint64_t bytes =3D migration_total_bytes(s); + uint64_t bytes =3D migration_transferred_bytes(s->to_dst_file); int64_t end_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); int64_t transfer_time; =20 @@ -2652,7 +2645,7 @@ static void update_iteration_initial_status(Migration= State *s) * wrong speed calculation. */ s->iteration_start_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); - s->iteration_initial_bytes =3D migration_total_bytes(s); + s->iteration_initial_bytes =3D migration_transferred_bytes(s->to_dst_f= ile); s->iteration_initial_pages =3D ram_get_total_transferred_pages(); } =20 @@ -2667,7 +2660,7 @@ static void migration_update_counters(MigrationState = *s, return; } =20 - current_bytes =3D migration_total_bytes(s); + current_bytes =3D migration_transferred_bytes(s->to_dst_file); transferred =3D current_bytes - s->iteration_initial_bytes; time_spent =3D current_time - s->iteration_start_time; bandwidth =3D (double)transferred / time_spent; --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551646; cv=none; d=zohomail.com; s=zohoarc; b=Uqf62ySwuQRC1W9kySGOwRTe5XZInU9gknXuBb9pvYPG0CdJ1MYwPdZtRLotJl9tdu89faMGsnwnuyDNgFAXOck15VsxyH+5UXtnCGBoXzKIg8/4XFD4QnzgDjYi6VOGDcjhKoOE7Sne7Vhfjn5pGygqiHcqe+4W7RLOSNlLyGg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551646; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XO42lZwmpFfzP+zpKw6CGo01wgk3f3UI1ez/JHRkb70=; b=cBm7r5Lrf3oJcTq5q7xwsbRKdn8iDvWDNp3sL1qH2prw9uy5LkDy8HmjNBRDpTL9cqYBN54uo1nl2pFZIYy42FvED6EC7g+PnBVYfNyu6bCdsvrKtNWNJ8vG7kU3/FEyuwKUVRPiWlhehmgUp41zJ2GQ1lKkY///jOKLFhjVvDU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683551646727635.9499000517113; Mon, 8 May 2023 06:14:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0eB-0005Ln-Kt; Mon, 08 May 2023 09:11:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0df-0004DY-Vv for qemu-devel@nongnu.org; Mon, 08 May 2023 09:10:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0dS-00017o-TM for qemu-devel@nongnu.org; Mon, 08 May 2023 09:10:42 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-601-AE7Na5zyNmujhrymI778jQ-1; Mon, 08 May 2023 09:10:32 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC3F7802A95; Mon, 8 May 2023 13:10:31 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03E072166B40; Mon, 8 May 2023 13:10:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551435; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XO42lZwmpFfzP+zpKw6CGo01wgk3f3UI1ez/JHRkb70=; b=BlrIIkNxJC5YDYrFlFhbdf9bes5AI20xgTAwlrAg/wJ2HsluqG79bmDJhgpTpBKYUdWUOZ rbyIoeeCj/ylJNs1xi9Ll6dKUsvZxVEeJI/1XmDuOsWJNLMqKEzp7+k60fGn5FRtp5gfB6 frTvcb6x0vKN2n3Yvm/IOzup4nNvtZ8= X-MC-Unique: AE7Na5zyNmujhrymI778jQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 12/21] migration: Add a trace for migration_transferred_bytes Date: Mon, 8 May 2023 15:09:00 +0200 Message-Id: <20230508130909.65420-13-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551647656100004 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela Reviewed-by: C=C3=A9dric Le Goater --- migration/migration-stats.c | 8 ++++++-- migration/trace-events | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/migration/migration-stats.c b/migration/migration-stats.c index fba66c4577..46b2b0d06e 100644 --- a/migration/migration-stats.c +++ b/migration/migration-stats.c @@ -14,6 +14,7 @@ #include "qemu/stats64.h" #include "qemu/timer.h" #include "qemu-file.h" +#include "trace.h" #include "migration-stats.h" =20 MigrationAtomicStats mig_stats; @@ -66,6 +67,9 @@ void migration_rate_limit_account(uint64_t len) =20 uint64_t migration_transferred_bytes(QEMUFile *f) { - return qemu_file_transferred(f) + stat64_get(&mig_stats.multifd_bytes); -} + uint64_t multifd =3D stat64_get(&mig_stats.multifd_bytes); + uint64_t qemu_file =3D qemu_file_transferred(f); =20 + trace_migration_transferred_bytes(qemu_file, multifd); + return qemu_file + multifd; +} diff --git a/migration/trace-events b/migration/trace-events index 92161eeac5..4b6e802833 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -186,6 +186,9 @@ process_incoming_migration_co_end(int ret, int ps) "ret= =3D%d postcopy-state=3D%d" process_incoming_migration_co_postcopy_end_main(void) "" postcopy_preempt_enabled(bool value) "%d" =20 +# migration-stats +migration_transferred_bytes(uint64_t qemu_file, uint64_t multifd) "qemu_fi= le %" PRIu64 " multifd %" PRIu64 + # channel.c migration_set_incoming_channel(void *ioc, const char *ioctype) "ioc=3D%p i= octype=3D%s" migration_set_outgoing_channel(void *ioc, const char *ioctype, const char = *hostname, void *err) "ioc=3D%p ioctype=3D%s hostname=3D%s err=3D%p" --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551609; cv=none; d=zohomail.com; s=zohoarc; b=S1yX6bVazQqG8lBPyEsysMquB2oqo6fugvikD4+4mZakHLukEEAD7ysoAai+2ZsGKqQwCiWrKGOdVtti0OWm4hZdKZDuXE5ZV4ytR1b/i0c1EzUtWkC8FTk715sPw7RfgJjsNMw7pIICvbfh74FGCnIwCdsUUI180Mc+86MYM04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551609; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sk+T4+c1clYy4lrV9FOJAderCO0LRvuls5DTHUJl6e0=; b=EWrV+dFS9TaCf4zSd4tc1Mph76pToyjqEZhY5gJ6Hpk2O+14DGe6icSpA8/IfzlwUU02WPaAp5uYQnhVIC1TyhYD79h22f8+QnFc4Z3gCFCc8gS7AnhmjB5GBGnRY5ZHZHsYhWYtmwUnan8BP44isR6W/nEIXj4T/m67aa4gL3U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683551609779961.4895769635299; Mon, 8 May 2023 06:13:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0eM-0006hM-Md; Mon, 08 May 2023 09:11:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0e0-0004cl-95 for qemu-devel@nongnu.org; Mon, 08 May 2023 09:11:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0db-00019Y-Sv for qemu-devel@nongnu.org; Mon, 08 May 2023 09:11:00 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-618-m-VIvm6aMayeOCN346prGw-1; Mon, 08 May 2023 09:10:36 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC0F880080E; Mon, 8 May 2023 13:10:35 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A1EC2166B40; Mon, 8 May 2023 13:10:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551441; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sk+T4+c1clYy4lrV9FOJAderCO0LRvuls5DTHUJl6e0=; b=crwj02IYDMvTqfRSuKIjHm7z/tZoITj5IQGOKfWfV3bsgRQOb+/GOGHE9/LLbIUYTcW9gI zxAfTEkSSKh+IqBiuTMfG88qqhmqf9+7tqPucWQSNdZQQqVjnVWZMNH/1OIvfLGy8r7v+B A1ryENZRryVs4Q5RpJKiiEs36N1pENk= X-MC-Unique: m-VIvm6aMayeOCN346prGw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 13/21] migration: Use migration_transferred_bytes() to calculate rate_limit Date: Mon, 8 May 2023 15:09:01 +0200 Message-Id: <20230508130909.65420-14-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551611797100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela Reviewed-by: C=C3=A9dric Le Goater --- migration/migration-stats.c | 7 +++++-- migration/migration-stats.h | 6 +++++- migration/migration.c | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/migration/migration-stats.c b/migration/migration-stats.c index 46b2b0d06e..eb1a2c1ad4 100644 --- a/migration/migration-stats.c +++ b/migration/migration-stats.c @@ -31,7 +31,9 @@ bool migration_rate_limit_exceeded(QEMUFile *f) return true; } =20 - uint64_t rate_limit_used =3D stat64_get(&mig_stats.rate_limit_used); + uint64_t rate_limit_start =3D stat64_get(&mig_stats.rate_limit_start); + uint64_t rate_limit_current =3D migration_transferred_bytes(f); + uint64_t rate_limit_used =3D rate_limit_current - rate_limit_start; uint64_t rate_limit_max =3D stat64_get(&mig_stats.rate_limit_max); /* * rate_limit_max =3D=3D 0 means no rate_limit enfoncement. @@ -55,9 +57,10 @@ void migration_rate_limit_set(uint64_t limit) stat64_set(&mig_stats.rate_limit_max, limit); } =20 -void migration_rate_limit_reset(void) +void migration_rate_limit_reset(QEMUFile *f) { stat64_set(&mig_stats.rate_limit_used, 0); + stat64_set(&mig_stats.rate_limit_start, migration_transferred_bytes(f)= ); } =20 void migration_rate_limit_account(uint64_t len) diff --git a/migration/migration-stats.h b/migration/migration-stats.h index c82fce9608..4029f1deab 100644 --- a/migration/migration-stats.h +++ b/migration/migration-stats.h @@ -69,6 +69,10 @@ typedef struct { * Number of bytes sent during precopy stage. */ Stat64 precopy_bytes; + /* + * Amount of transferred data at the start of current cycle. + */ + Stat64 rate_limit_start; /* * Maximum amount of data we can send in a cycle. */ @@ -126,7 +130,7 @@ uint64_t migration_rate_limit_get(void); * * This is called when we know we start a new transfer cycle. */ -void migration_rate_limit_reset(void); +void migration_rate_limit_reset(QEMUFile *f); =20 /** * migration_rate_limit_set: Set the maximum amount that can be transferre= d. diff --git a/migration/migration.c b/migration/migration.c index e6d262ffe1..6922c612e4 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2684,7 +2684,7 @@ static void migration_update_counters(MigrationState = *s, stat64_get(&mig_stats.dirty_bytes_last_sync) / bandwidth; } =20 - migration_rate_limit_reset(); + migration_rate_limit_reset(s->to_dst_file); =20 update_iteration_initial_status(s); =20 --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551890; cv=none; d=zohomail.com; s=zohoarc; b=ayTPHBtg/bnifAI4URkJRdsbjpaxVtacn3BvHddAVCwWOOjiwAyVHQmNEi5WWMWLBdGYeGaBDVgO2Le60TbgFZqQb2Rkw71IR5Jeon3yk04i5Q19qEiLQjBTQTWKvXsRd74AD17l2Kx7ZnNMeUDTrXGCUAshFiFwIa0oAepln04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551890; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=G+dw1pC6wZ/5iTwWZa5ifsIIHozBgmQP+Ps8bOHYi+I=; b=JBKa8QwZrgqkRlqTh3As+nqulij8cvR5vfYqG9EULY7YFpLsnVhvotLnbrR31DMhYEqIz2Iyn3KZ3raSNESXzuRlljv9v5mR1iv3nud+uFpUhy89QuW0SjwwQUkJnATedX4nBIKSqYJb4L8Yx11gqqzHEu2J1kvTywYpVnMkziY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683551890063727.2399269159076; Mon, 8 May 2023 06:18:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0fV-0000Uy-HH; Mon, 08 May 2023 09:12:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0e1-0004h2-Jj for qemu-devel@nongnu.org; Mon, 08 May 2023 09:11:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0dz-0001AB-5T for qemu-devel@nongnu.org; Mon, 08 May 2023 09:11:13 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-159-psW2waxuOzOQlFbCwTemPA-1; Mon, 08 May 2023 09:10:40 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC32A100F64F; Mon, 8 May 2023 13:10:39 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09BCC2166B40; Mon, 8 May 2023 13:10:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551445; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G+dw1pC6wZ/5iTwWZa5ifsIIHozBgmQP+Ps8bOHYi+I=; b=diOd5mylmwEGMRwqPO75/VxkTk7MUdyUhS6pQ0lp1N30+JA+/kCHixtKDVZyvVk0DrjycG nO8gx+chDbjT4TW2tm2MOibs88/3F2kGh34d9FmZ83YbAQtlbx7LDjNTvKcSnsRa5SahTW CPhqkYUJVHwd7oLAqMQL3fxETjz47s8= X-MC-Unique: psW2waxuOzOQlFbCwTemPA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 14/21] migration: We don't need the field rate_limit_used anymore Date: Mon, 8 May 2023 15:09:02 +0200 Message-Id: <20230508130909.65420-15-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551891098100001 Content-Type: text/plain; charset="utf-8" Since previous commit, we calculate how much data we have send with migration_transferred_bytes() so no need to maintain this counter and remember to always update it. Signed-off-by: Juan Quintela Reviewed-by: C=C3=A9dric Le Goater --- migration/migration-stats.c | 6 ------ migration/migration-stats.h | 14 -------------- migration/multifd.c | 1 - migration/qemu-file.c | 4 ---- 4 files changed, 25 deletions(-) diff --git a/migration/migration-stats.c b/migration/migration-stats.c index eb1a2c1ad4..a42b5d953e 100644 --- a/migration/migration-stats.c +++ b/migration/migration-stats.c @@ -59,15 +59,9 @@ void migration_rate_limit_set(uint64_t limit) =20 void migration_rate_limit_reset(QEMUFile *f) { - stat64_set(&mig_stats.rate_limit_used, 0); stat64_set(&mig_stats.rate_limit_start, migration_transferred_bytes(f)= ); } =20 -void migration_rate_limit_account(uint64_t len) -{ - stat64_add(&mig_stats.rate_limit_used, len); -} - uint64_t migration_transferred_bytes(QEMUFile *f) { uint64_t multifd =3D stat64_get(&mig_stats.multifd_bytes); diff --git a/migration/migration-stats.h b/migration/migration-stats.h index 4029f1deab..ab4cc15a74 100644 --- a/migration/migration-stats.h +++ b/migration/migration-stats.h @@ -77,10 +77,6 @@ typedef struct { * Maximum amount of data we can send in a cycle. */ Stat64 rate_limit_max; - /* - * Amount of data we have sent in the current cycle. - */ - Stat64 rate_limit_used; /* * How long has the setup stage took. */ @@ -108,16 +104,6 @@ extern MigrationAtomicStats mig_stats; =20 void calculate_time_since(Stat64 *val, int64_t since); =20 -/** - * migration_rate_limit_account: Increase the number of bytes transferred. - * - * Report on a number of bytes the have been transferred that need to - * be applied to the rate limiting calcuations. - * - * @len: amount of bytes transferred - */ -void migration_rate_limit_account(uint64_t len); - /** * migration_rate_limit_get: Get the maximum amount that can be transferre= d. * diff --git a/migration/multifd.c b/migration/multifd.c index 2efb313be4..9d2ade7abc 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -432,7 +432,6 @@ static int multifd_send_pages(QEMUFile *f) multifd_send_state->pages =3D p->pages; p->pages =3D pages; transferred =3D ((uint64_t) pages->num) * p->page_size + p->packet_len; - migration_rate_limit_account(transferred); qemu_mutex_unlock(&p->mutex); stat64_add(&mig_stats.transferred, transferred); stat64_add(&mig_stats.multifd_bytes, transferred); diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 3f993e24af..0086d67d83 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -292,7 +292,6 @@ void qemu_fflush(QEMUFile *f) qemu_file_set_error_obj(f, -EIO, local_error); } else { uint64_t size =3D iov_size(f->iov, f->iovcnt); - migration_rate_limit_account(size); f->total_transferred +=3D size; } =20 @@ -344,9 +343,6 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t bl= ock_offset, if (f->hooks && f->hooks->save_page) { int ret =3D f->hooks->save_page(f, block_offset, offset, size, bytes_sent); - if (ret !=3D RAM_SAVE_CONTROL_NOT_SUPP) { - migration_rate_limit_account(size); - } =20 if (ret !=3D RAM_SAVE_CONTROL_DELAYED && ret !=3D RAM_SAVE_CONTROL_NOT_SUPP) { --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551534; cv=none; d=zohomail.com; s=zohoarc; b=D0x0XQQNZ7dxAwPGeshGUTmPxuEldE0zo+EwRLXahSGEhcX/HGV8u9w1PwULV6fR+A4cGO3wjXGoVsp0Q/AfZhF5fseQFdbSHoJrDz61xM5VlxMBJNlyZ7JRMSa1noWY8F7YF1NspLNNIpqfrR0OevM7j3raZhAwDW7RqIvZTO8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551534; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TsDj3iX2uWM8XobG5FO5OOcrbCglFSGHSTFJFAtUZPo=; b=Rb++MPRAwCTLP0JcKa9Wn+sZesEhitkA0fqye3SK2IkKyfZzFLJwaqVPZR+6ANT0lw+Tw2rlchcwlulMD/BImDvTGaTj22qqsxPeH7Bnp5YnHDdmo7PU5EA4GMrZ1d522aeHP6QqJpusUD2ydMBSYzmtl0Gm7lJ0ouB2g97hBsM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683551534789951.0237560609165; Mon, 8 May 2023 06:12:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0eh-0007qp-Jf; Mon, 08 May 2023 09:12:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0e4-0004jd-CB for qemu-devel@nongnu.org; Mon, 08 May 2023 09:11:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0dz-0001Ah-FE for qemu-devel@nongnu.org; Mon, 08 May 2023 09:11:15 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-138-Mi5HC7vmP1q5HMX8IsJCcA-1; Mon, 08 May 2023 09:10:44 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C78ED2806061; Mon, 8 May 2023 13:10:43 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0AE6E2166B40; Mon, 8 May 2023 13:10:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551447; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TsDj3iX2uWM8XobG5FO5OOcrbCglFSGHSTFJFAtUZPo=; b=bNMB1wLuEV7m7BhYpZyuNyMFj7voAyywKULGfmVNHxFNPOBsrBWA1RzGYOjI2QpCN74spF aNAi+nyPJrs2Bz9klyilJrEXIjgx07fOqlGCTZUzoHM/GzW4mGi1tPXq9x8BVfVR2CFm+3 KzoLZpP0oXeiB+n4NlMjHeU2NUnrv9A= X-MC-Unique: Mi5HC7vmP1q5HMX8IsJCcA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 15/21] migration: Don't abuse qemu_file transferred for RDMA Date: Mon, 8 May 2023 15:09:03 +0200 Message-Id: <20230508130909.65420-16-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551536320100003 Content-Type: text/plain; charset="utf-8" Just create a variable for it, the same way that multifd does. This way it is safe to use for other thread, etc, etc. Signed-off-by: Juan Quintela --- migration/migration-stats.c | 5 +++-- migration/migration-stats.h | 4 ++++ migration/rdma.c | 22 ++++++++++++++++++++-- migration/trace-events | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/migration/migration-stats.c b/migration/migration-stats.c index a42b5d953e..1c2c0b3077 100644 --- a/migration/migration-stats.c +++ b/migration/migration-stats.c @@ -65,8 +65,9 @@ void migration_rate_limit_reset(QEMUFile *f) uint64_t migration_transferred_bytes(QEMUFile *f) { uint64_t multifd =3D stat64_get(&mig_stats.multifd_bytes); + uint64_t rdma =3D stat64_get(&mig_stats.rdma_bytes); uint64_t qemu_file =3D qemu_file_transferred(f); =20 - trace_migration_transferred_bytes(qemu_file, multifd); - return qemu_file + multifd; + trace_migration_transferred_bytes(qemu_file, multifd, rdma); + return qemu_file + multifd + rdma; } diff --git a/migration/migration-stats.h b/migration/migration-stats.h index ab4cc15a74..cbab99cfdc 100644 --- a/migration/migration-stats.h +++ b/migration/migration-stats.h @@ -77,6 +77,10 @@ typedef struct { * Maximum amount of data we can send in a cycle. */ Stat64 rate_limit_max; + /* + * Number of bytes sent through RDMA. + */ + Stat64 rdma_bytes; /* * How long has the setup stage took. */ diff --git a/migration/rdma.c b/migration/rdma.c index 2cd8f1cc66..941797506a 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2122,9 +2122,18 @@ retry: return -EIO; } =20 + /* + * TODO: Here we are sending something, but we are not + * accounting for anything transferred. The following is = wrong: + * + * stat64_add(&mig_stats.rdma_bytes, sge.length); + * + * because we are using some kind of compression. I + * would think that head.len would be the more similar + * thing to a correct value. + */ stat64_add(&mig_stats.zero_pages, sge.length / qemu_target_page_size()); - return 1; } =20 @@ -2232,8 +2241,17 @@ retry: =20 set_bit(chunk, block->transit_bitmap); stat64_add(&mig_stats.normal_pages, sge.length / qemu_target_page_size= ()); + /* + * We are adding to transferred the amount of data written, but no + * overhead at all. I will asume that RDMA is magicaly and don't + * need to transfer (at least) the addresses where it wants to + * write the pages. Here it looks like it should be something + * like: + * sizeof(send_wr) + sge.length + * but this being RDMA, who knows. + */ + stat64_add(&mig_stats.rdma_bytes, sge.length); ram_transferred_add(sge.length); - qemu_file_credit_transfer(f, sge.length); rdma->total_writes++; =20 return 0; diff --git a/migration/trace-events b/migration/trace-events index 4b6e802833..800cfce547 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -187,7 +187,7 @@ process_incoming_migration_co_postcopy_end_main(void) "" postcopy_preempt_enabled(bool value) "%d" =20 # migration-stats -migration_transferred_bytes(uint64_t qemu_file, uint64_t multifd) "qemu_fi= le %" PRIu64 " multifd %" PRIu64 +migration_transferred_bytes(uint64_t qemu_file, uint64_t multifd, uint64_t= rdma) "qemu_file %" PRIu64 " multifd %" PRIu64 " RDMA %" PRIu64 =20 # channel.c migration_set_incoming_channel(void *ioc, const char *ioctype) "ioc=3D%p i= octype=3D%s" --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551797; cv=none; d=zohomail.com; s=zohoarc; b=fKfCWpNOSXSF0iKdjv9had3a7q2/JtU3/zLNxt9tnkZkG7+7RmEfWKW0EHKROlaZhTtXQjVAQCNY30C54578drwrXSq76Hc8vIHvBH4L1JGZxXAl15mmllNtz9tuFOg33C2KcZnYzxId/kF6wYY8TBqh4cM/A32+bA38PazxiA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551797; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BK2tBdnVeBEogv9h6P/23lEejuwt6iGvZLkAMRoiK88=; b=KedIN9Sl0+rEBMu8DbJtBTNAeI0+fmh71MjYcK9YOFcBru+IxMtqCrqk2rDFeAoXDlUqltPK62ebWlca6gsLsKAl92/VWPyUp+hhx+TJD5W+MNhtNOk8F+D+QD5/N+X1vB/0SR8VTgoyi88Y5Z8ALnQcE3/Ojw9cfcCVDh/rs1I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683551797502830.0797631930029; Mon, 8 May 2023 06:16:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0eE-0005eg-Qd; Mon, 08 May 2023 09:11:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0e0-0004cv-C2 for qemu-devel@nongnu.org; Mon, 08 May 2023 09:11:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0dg-0001Bp-NU for qemu-devel@nongnu.org; Mon, 08 May 2023 09:10:59 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-116-GFfRxwZDPpC3H7lG7cXgkQ-1; Mon, 08 May 2023 09:10:48 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D391585A588; Mon, 8 May 2023 13:10:47 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 195902166B41; Mon, 8 May 2023 13:10:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551452; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BK2tBdnVeBEogv9h6P/23lEejuwt6iGvZLkAMRoiK88=; b=hSrn0TdGJK2nZvEaP9gyGlklqlG8sRUJpgD9JJO3onldJ7RQDhAch/HjDOQ1PBxpjGZPnI tKeXFYGJI3Ox5TnHsPQvk/mq2YxCncN/fA4I9Yvss+xklKUEcWYSZsDvYGd1MqPqrjqDwP ev+zTrzjcNsl4sd0R4jLBujDoAL1yV0= X-MC-Unique: GFfRxwZDPpC3H7lG7cXgkQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 16/21] migration/RDMA: It is accounting for zero/normal pages in two places Date: Mon, 8 May 2023 15:09:04 +0200 Message-Id: <20230508130909.65420-17-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551797884100001 Content-Type: text/plain; charset="utf-8" Remove the one in control_save_page(). Signed-off-by: Juan Quintela --- migration/ram.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 2339a99932..558f2ed3b1 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1356,13 +1356,6 @@ static bool control_save_page(PageSearchStatus *pss,= RAMBlock *block, if (ret =3D=3D RAM_SAVE_CONTROL_DELAYED) { return true; } - - if (bytes_xmit > 0) { - stat64_add(&mig_stats.normal_pages, 1); - } else if (bytes_xmit =3D=3D 0) { - stat64_add(&mig_stats.zero_pages, 1); - } - return true; } =20 --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551777; cv=none; d=zohomail.com; s=zohoarc; b=ATK5C7tzvyTah6LUswgA/CWpDgNwFC9La6JGVkTseZwnwC5M3xMZgCf+H7zYkWc6ud6qhCGgfZX8P5o9XY5FAKRDyaUKL+80kr77qR8YikM8Ax2z1n7QT4v51891C2Nl7tRuvrWnGJx+R1x0YRcsE++KC0lvIbfGl7h1oTPIXdA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551777; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/lzvT+i/e0GhQATSDEFlzB7LEHZv8Tc7zznWcficXPQ=; b=cDiFtYrjU5+HZxpEdnP6sst/gwL+duOBXVyDGuv5V9e/+ywv7TR/i5s/1nqCkUaFP1+Fk/9BU3SB96+PX0RaTX0TJTIgF8psIEh4iD7UuT4Iy0a5lmsf7Aftlm/g6Weor4qm30oHUPB2mCtuR6oOm+x9hDGStzF83vEWH+vPsR0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683551777595378.3051849804457; Mon, 8 May 2023 06:16:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0fG-0000FA-0t; Mon, 08 May 2023 09:12:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0e7-0004pp-I5 for qemu-devel@nongnu.org; Mon, 08 May 2023 09:11:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0dz-0001D8-Ha for qemu-devel@nongnu.org; Mon, 08 May 2023 09:11:19 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-479-euG0b-fBMdSLlbXSiWHEMw-1; Mon, 08 May 2023 09:10:53 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BE8333813F53; Mon, 8 May 2023 13:10:52 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26BEE2166B40; Mon, 8 May 2023 13:10:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551457; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/lzvT+i/e0GhQATSDEFlzB7LEHZv8Tc7zznWcficXPQ=; b=WyhIczYjpAIY1X1G3EoWaLSk9taP4MgKz4Ae+JwuIc9biKPU4Ozy8KAgeGGj5TUvxuB8hs jvhIPGmZwJSVVT9VeR3LUmCYOwfl6plqZk3gBivhri+9Bs1lPuJm1l56q6iF282RSOEOqL 6uISHQ6GxiJy1PBqcEvl3sXFS6J2Gbg= X-MC-Unique: euG0b-fBMdSLlbXSiWHEMw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 17/21] migration/rdma: Remove QEMUFile parameter when not used Date: Mon, 8 May 2023 15:09:05 +0200 Message-Id: <20230508130909.65420-18-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551778658100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela --- migration/rdma.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 941797506a..dac3d91e16 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2027,7 +2027,7 @@ static int qemu_rdma_exchange_recv(RDMAContext *rdma,= RDMAControlHeader *head, * If we're using dynamic registration on the dest-side, we have to * send a registration command first. */ -static int qemu_rdma_write_one(QEMUFile *f, RDMAContext *rdma, +static int qemu_rdma_write_one(RDMAContext *rdma, int current_index, uint64_t current_addr, uint64_t length) { @@ -2263,7 +2263,7 @@ retry: * We support sending out multiple chunks at the same time. * Not all of them need to get signaled in the completion queue. */ -static int qemu_rdma_write_flush(QEMUFile *f, RDMAContext *rdma) +static int qemu_rdma_write_flush(RDMAContext *rdma) { int ret; =20 @@ -2271,7 +2271,7 @@ static int qemu_rdma_write_flush(QEMUFile *f, RDMACon= text *rdma) return 0; } =20 - ret =3D qemu_rdma_write_one(f, rdma, + ret =3D qemu_rdma_write_one(rdma, rdma->current_index, rdma->current_addr, rdma->current_length); =20 if (ret < 0) { @@ -2344,7 +2344,7 @@ static inline int qemu_rdma_buffer_mergable(RDMAConte= xt *rdma, * and only require that a batch gets acknowledged in the completion * queue instead of each individual chunk. */ -static int qemu_rdma_write(QEMUFile *f, RDMAContext *rdma, +static int qemu_rdma_write(RDMAContext *rdma, uint64_t block_offset, uint64_t offset, uint64_t len) { @@ -2355,7 +2355,7 @@ static int qemu_rdma_write(QEMUFile *f, RDMAContext *= rdma, =20 /* If we cannot merge it, we flush the current buffer first. */ if (!qemu_rdma_buffer_mergable(rdma, current_addr, len)) { - ret =3D qemu_rdma_write_flush(f, rdma); + ret =3D qemu_rdma_write_flush(rdma); if (ret) { return ret; } @@ -2377,7 +2377,7 @@ static int qemu_rdma_write(QEMUFile *f, RDMAContext *= rdma, =20 /* flush it if buffer is too large */ if (rdma->current_length >=3D RDMA_MERGE_MAX) { - return qemu_rdma_write_flush(f, rdma); + return qemu_rdma_write_flush(rdma); } =20 return 0; @@ -2798,7 +2798,6 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *io= c, Error **errp) { QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(ioc); - QEMUFile *f =3D rioc->file; RDMAContext *rdma; int ret; ssize_t done =3D 0; @@ -2819,7 +2818,7 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *io= c, * Push out any writes that * we're queued up for VM's ram. */ - ret =3D qemu_rdma_write_flush(f, rdma); + ret =3D qemu_rdma_write_flush(rdma); if (ret < 0) { rdma->error_state =3D ret; error_setg(errp, "qemu_rdma_write_flush returned %d", ret); @@ -2958,11 +2957,11 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *i= oc, /* * Block until all the outstanding chunks have been delivered by the hardw= are. */ -static int qemu_rdma_drain_cq(QEMUFile *f, RDMAContext *rdma) +static int qemu_rdma_drain_cq(RDMAContext *rdma) { int ret; =20 - if (qemu_rdma_write_flush(f, rdma) < 0) { + if (qemu_rdma_write_flush(rdma) < 0) { return -EIO; } =20 @@ -3272,7 +3271,7 @@ static size_t qemu_rdma_save_page(QEMUFile *f, * is full, or the page doesn't belong to the current chunk, * an actual RDMA write will occur and a new chunk will be formed. */ - ret =3D qemu_rdma_write(f, rdma, block_offset, offset, size); + ret =3D qemu_rdma_write(rdma, block_offset, offset, size); if (ret < 0) { error_report("rdma migration: write error! %d", ret); goto err; @@ -3928,7 +3927,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, CHECK_ERROR_STATE(); =20 qemu_fflush(f); - ret =3D qemu_rdma_drain_cq(f, rdma); + ret =3D qemu_rdma_drain_cq(rdma); =20 if (ret < 0) { goto err; --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551890; cv=none; d=zohomail.com; s=zohoarc; b=DZs7lj6p3inaGJbtUmo3XJLb32bCNchkemIp/4KdemOBjg7CoYgdImHGPVO9TFlVfAxQJGdahiBGSfTn7uT9z3X6o4TIJ/8e4jz10qBK0tPFkRhlqD2wAIvW9PpOEpq7/mYFlJN0J8hwh8kHA5BVhr8FQbGXbjU4/HnP2CPTesM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551890; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AHCtbJSxzlOY15iuPfGvkQzOQhhBSgMM4kBlxSMibZ4=; b=QAtTMF4qvVK76t3Rid/w4Xw5MXVNjTNbA8JSRsHdCs/AIVSecej2rLTM+MZzYzc8gyveXpfPbW5pBOtO7XXHttfhEwVeTe4b2UMr6Rx2ROSLSu2RkKuj1Hgo+589eRtGjyJ9Xd2egF5/HnTnVViTMr2fKhcUCIZaTHKW3rWtww0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168355189012530.039521740635564; Mon, 8 May 2023 06:18:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0f6-000051-6n; Mon, 08 May 2023 09:12:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0e4-0004jc-Bm for qemu-devel@nongnu.org; Mon, 08 May 2023 09:11:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0dz-0001Dz-Cc for qemu-devel@nongnu.org; Mon, 08 May 2023 09:11:15 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-617-HRWezuDcNJGpaqw5GQ6SiA-1; Mon, 08 May 2023 09:10:57 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D99F084AF30; Mon, 8 May 2023 13:10:56 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C1BD2166B40; Mon, 8 May 2023 13:10:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AHCtbJSxzlOY15iuPfGvkQzOQhhBSgMM4kBlxSMibZ4=; b=cFYs+JkzVcZqgoeCFbBQTIxmMBjBu3r8G/sKMlFZ9VjZ3pRXDJNt5ni8CpzHWygd02lsvR brmP4cnU8/a4MLvbJbV+bYi7gdLY8c6MP+M6fjkaG/K6kfI0OlqOaH6qVlXA5oj8Yqlyqb ZVjVxK9zqetyIro6Am7LkEDED5E1F8w= X-MC-Unique: HRWezuDcNJGpaqw5GQ6SiA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 18/21] migration/rdma: Don't use imaginary transfers Date: Mon, 8 May 2023 15:09:06 +0200 Message-Id: <20230508130909.65420-19-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551892293100009 Content-Type: text/plain; charset="utf-8" RDMA protocol is completely asynchronous, so in qemu_rdma_save_page() they "invent" that a byte has been transferred. And then they call qemu_file_credit_transfer() and ram_transferred_add() with that byte. Just remove that calls as nothing has been sent. Signed-off-by: Juan Quintela --- migration/qemu-file.c | 5 +---- migration/ram.c | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 0086d67d83..951f046c39 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -346,13 +346,10 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t = block_offset, =20 if (ret !=3D RAM_SAVE_CONTROL_DELAYED && ret !=3D RAM_SAVE_CONTROL_NOT_SUPP) { - if (bytes_sent && *bytes_sent > 0) { - qemu_file_credit_transfer(f, *bytes_sent); - } else if (ret < 0) { + if (ret < 0) { qemu_file_set_error(f, ret); } } - return ret; } =20 diff --git a/migration/ram.c b/migration/ram.c index 558f2ed3b1..f889e39a20 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1349,7 +1349,6 @@ static bool control_save_page(PageSearchStatus *pss, = RAMBlock *block, } =20 if (bytes_xmit) { - ram_transferred_add(bytes_xmit); *pages =3D 1; } =20 --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551891; cv=none; d=zohomail.com; s=zohoarc; b=lDMaBTCfpfBaHmJh/cDL5rYB2Tu075Pozy7hpuJPXRmMiJJecWDb1+RjkXA/APWnJe0F9Wozmf1LFCvrHqPYX4z+1rwIYUV6MED+cl+9D0GhCxal0wjP2LFHqld/rKAhyvPT0w7ctdCe1ak6zSWIyhI9omE84UCq3OL4LiPoVBU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551891; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=piyqIYTPSTj4lwnLsvDk2JcXXdmH/6Ki3/rFC0L1iy4=; b=fnX0VHjU6gMGSRGWo2kz4iZ6X67lVleYsV2CPzfIET6RJ9ggWGUwQX0zUbkEu9dz2Q9PSRrd5kHQcgj7dz4ztkZVDHNNDnGR7jqi13nnZ+c7eap4iTbVwmH5IlieytxBU6ZF9VTGfXwCBR4sskXLCcUY1NF83xEPQ1EHSr3uzEI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683551891464687.9259398097508; Mon, 8 May 2023 06:18:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0fV-0000VD-Lh; Mon, 08 May 2023 09:12:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0e2-0004h8-E1 for qemu-devel@nongnu.org; Mon, 08 May 2023 09:11:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0dz-0001EH-7P for qemu-devel@nongnu.org; Mon, 08 May 2023 09:11:14 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-561-MqUf5ENCMxWzIQlf4zc04Q-1; Mon, 08 May 2023 09:11:02 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E6112886460; Mon, 8 May 2023 13:11:00 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 28B372166B40; Mon, 8 May 2023 13:10:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551463; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=piyqIYTPSTj4lwnLsvDk2JcXXdmH/6Ki3/rFC0L1iy4=; b=QW2+aSP/Dy8IeaGy4O1wO8ttWHQJFNVIHap7uWBC/QUQo5e/aAH/op/fMpUIvqv/0g8aP4 I/C2fq+PT+oDn+R3edkVFBY8FjDz1U4tBxgrqmBTGB7s0zue0EsVu/c5Acf+W94YlsIwn1 BIEpOSqaeZPI+2Vbcsbt1TUqz9VwZ5w= X-MC-Unique: MqUf5ENCMxWzIQlf4zc04Q-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 19/21] migration: Remove unused qemu_file_credit_transfer() Date: Mon, 8 May 2023 15:09:07 +0200 Message-Id: <20230508130909.65420-20-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551891745100003 Content-Type: text/plain; charset="utf-8" After this change, nothing abuses QEMUFile to account for data transferrefd during migration. Signed-off-by: Juan Quintela --- migration/qemu-file.c | 5 ----- migration/qemu-file.h | 8 -------- 2 files changed, 13 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 951f046c39..bfaba840ca 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -411,11 +411,6 @@ static ssize_t coroutine_mixed_fn qemu_fill_buffer(QEM= UFile *f) return len; } =20 -void qemu_file_credit_transfer(QEMUFile *f, size_t size) -{ - f->total_transferred +=3D size; -} - /** Closes the file * * Returns negative error value if any error happened on previous operatio= ns or diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 46029b951c..9feac5edbc 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -121,14 +121,6 @@ int qemu_put_qemu_file(QEMUFile *f_des, QEMUFile *f_sr= c); */ int coroutine_mixed_fn qemu_peek_byte(QEMUFile *f, int offset); void qemu_file_skip(QEMUFile *f, int size); -/* - * qemu_file_credit_transfer: - * - * Report on a number of bytes that have been transferred - * out of band from the main file object I/O methods. This - * accounting information tracks the total migration traffic. - */ -void qemu_file_credit_transfer(QEMUFile *f, size_t size); int qemu_file_get_error_obj(QEMUFile *f, Error **errp); int qemu_file_get_error_obj_any(QEMUFile *f1, QEMUFile *f2, Error **errp); void qemu_file_set_error_obj(QEMUFile *f, int ret, Error *err); --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551677; cv=none; d=zohomail.com; s=zohoarc; b=BXglyjkzg84fCMK1FqEAL10lc3O8dxcbVfZMv2cptpdC6TBHirHO02NXSD9DkM6ASvzwLY7+VZuTHAkdpQwuq0kCD4aOzJ6bl5rE4+sPvwpwKef6xA1tLy+USEsyB150SeTnBaXCCQWnAHMO4Reca+WtdOUavhPPsWGb+mVVAXc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551677; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QTI3XI1mn3nOILptLbolD8Lc7y/Fzs+9HtAB2JrHHI4=; b=XV6IEL77359TplXptADKJhq3FoWaVRSYevuPJjrgKInpx6pxBdQitY/0QyWaujMtdmPGYXTMHkylVfboO6jAROKT9ruul5yN/MIEmu4uY+MNvesU1ZhFZfqVPuCr4/y6Sl+T0SjBq85+tbtD6Q1QvpRDDL1p1L+L+SM00GkZzmM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683551677740177.7878166422047; Mon, 8 May 2023 06:14:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0f0-0008EC-Ky; Mon, 08 May 2023 09:12:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0ec-0007s9-UB for qemu-devel@nongnu.org; Mon, 08 May 2023 09:11:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0eZ-0001cK-1u for qemu-devel@nongnu.org; Mon, 08 May 2023 09:11:50 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-221-SGx0mRElO52jOSWFGcRdLQ-1; Mon, 08 May 2023 09:11:42 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 36CF486796B; Mon, 8 May 2023 13:11:28 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B4032166B40; Mon, 8 May 2023 13:11:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551506; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QTI3XI1mn3nOILptLbolD8Lc7y/Fzs+9HtAB2JrHHI4=; b=dG/EGUAJThPNhMP98h/LVFyY9zFqLY0bVNmaTwOrcAx54W/Twfy4YSW/5oipY4ZSveOFhR 14W/Xqz0gmG8RrAoA8r1UW9IsEff1GNg9Ilsb8g0n+K6OM/drDtpvILzhToTsQSiwMMpMD J0hdC0R1ILis2gu4yPMAJYzc9nhw9d4= X-MC-Unique: SGx0mRElO52jOSWFGcRdLQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 20/21] migration/rdma: Simplify the function that saves a page Date: Mon, 8 May 2023 15:09:08 +0200 Message-Id: <20230508130909.65420-21-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551680004100002 Content-Type: text/plain; charset="utf-8" When we sent a page through QEMUFile hooks (RDMA) there are three posiblities: - We are not using RDMA. return RAM_SAVE_CONTROL_DELAYED and control_save_page() returns false to let anything else to proceed. - There is one error but we are using RDMA. Then we return a negative value, control_save_page() needs to return true. - Everything goes well and RDMA start the sent of the page asynchronously. It returns RAM_SAVE_CONTROL_DELAYED and we need to return 1 for ram_save_page_legacy. Clear? I know, I know, the interfaz is as bad as it gets. I think that now it is a bit clearer, but this needs to be done some other way. Signed-off-by: Juan Quintela --- migration/qemu-file.c | 12 ++++++------ migration/qemu-file.h | 14 ++++++-------- migration/ram.c | 10 +++------- migration/rdma.c | 19 +++---------------- 4 files changed, 18 insertions(+), 37 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index bfaba840ca..58ae7a40c9 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -336,14 +336,14 @@ void ram_control_load_hook(QEMUFile *f, uint64_t flag= s, void *data) } } =20 -size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset, - ram_addr_t offset, size_t size, - uint64_t *bytes_sent) +int ram_control_save_page(QEMUFile *f, ram_addr_t block_offset, + ram_addr_t offset, size_t size) { if (f->hooks && f->hooks->save_page) { - int ret =3D f->hooks->save_page(f, block_offset, - offset, size, bytes_sent); - + int ret =3D f->hooks->save_page(f, block_offset, offset, size); + /* + * RAM_SAVE_CONTROL_* are negative values + */ if (ret !=3D RAM_SAVE_CONTROL_DELAYED && ret !=3D RAM_SAVE_CONTROL_NOT_SUPP) { if (ret < 0) { diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 9feac5edbc..6573e2b62d 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -49,11 +49,10 @@ typedef int (QEMURamHookFunc)(QEMUFile *f, uint64_t fla= gs, void *data); * This function allows override of where the RAM page * is saved (such as RDMA, for example.) */ -typedef size_t (QEMURamSaveFunc)(QEMUFile *f, - ram_addr_t block_offset, - ram_addr_t offset, - size_t size, - uint64_t *bytes_sent); +typedef int (QEMURamSaveFunc)(QEMUFile *f, + ram_addr_t block_offset, + ram_addr_t offset, + size_t size); =20 typedef struct QEMUFileHooks { QEMURamHookFunc *before_ram_iterate; @@ -145,9 +144,8 @@ void ram_control_load_hook(QEMUFile *f, uint64_t flags,= void *data); #define RAM_SAVE_CONTROL_NOT_SUPP -1000 #define RAM_SAVE_CONTROL_DELAYED -2000 =20 -size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset, - ram_addr_t offset, size_t size, - uint64_t *bytes_sent); +int ram_control_save_page(QEMUFile *f, ram_addr_t block_offset, + ram_addr_t offset, size_t size); QIOChannel *qemu_file_get_ioc(QEMUFile *file); =20 #endif diff --git a/migration/ram.c b/migration/ram.c index f889e39a20..ec3bf831fb 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1338,23 +1338,19 @@ static int save_zero_page(PageSearchStatus *pss, QE= MUFile *f, RAMBlock *block, static bool control_save_page(PageSearchStatus *pss, RAMBlock *block, ram_addr_t offset, int *pages) { - uint64_t bytes_xmit =3D 0; int ret; =20 - *pages =3D -1; ret =3D ram_control_save_page(pss->pss_channel, block->offset, offset, - TARGET_PAGE_SIZE, &bytes_xmit); + TARGET_PAGE_SIZE); if (ret =3D=3D RAM_SAVE_CONTROL_NOT_SUPP) { return false; } =20 - if (bytes_xmit) { - *pages =3D 1; - } - if (ret =3D=3D RAM_SAVE_CONTROL_DELAYED) { + *pages =3D 1; return true; } + *pages =3D ret; return true; } =20 diff --git a/migration/rdma.c b/migration/rdma.c index dac3d91e16..afdd359878 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3239,13 +3239,12 @@ qio_channel_rdma_shutdown(QIOChannel *ioc, * * @size : Number of bytes to transfer * - * @bytes_sent : User-specificed pointer to indicate how many bytes were + * @pages_sent : User-specificed pointer to indicate how many pages were * sent. Usually, this will not be more than a few bytes = of * the protocol because most transfers are sent asynchron= ously. */ -static size_t qemu_rdma_save_page(QEMUFile *f, - ram_addr_t block_offset, ram_addr_t offs= et, - size_t size, uint64_t *bytes_sent) +static int qemu_rdma_save_page(QEMUFile *f, ram_addr_t block_offset, + ram_addr_t offset, size_t size) { QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(qemu_file_get_ioc(f)); RDMAContext *rdma; @@ -3277,18 +3276,6 @@ static size_t qemu_rdma_save_page(QEMUFile *f, goto err; } =20 - /* - * We always return 1 bytes because the RDMA - * protocol is completely asynchronous. We do not yet know - * whether an identified chunk is zero or not because we're - * waiting for other pages to potentially be merged with - * the current chunk. So, we have to call qemu_update_position() - * later on when the actual write occurs. - */ - if (bytes_sent) { - *bytes_sent =3D 1; - } - /* * Drain the Completion Queue if possible, but do not block, * just poll. --=20 2.40.0 From nobody Tue May 21 07:35:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683551770; cv=none; d=zohomail.com; s=zohoarc; b=CCdT3JDXjDd4YrjINixrHw0oFYE+nimJG+eACMMXgR9XmYpDGhMpdPIgJ3VCg66m7k2r5zfdz4jFBkyPm4X/p0BnRmLy6+Z8HaxexywWF6N3dsOD4CaTH2nOhcJCSTIGeP2jZhWhl7zmCx5epUjcZIb/cuSmHNfnbWXAQm8oSdY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683551770; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EPSjqeVWM17XH9xo4fkTkuI4cQmJACpPRQiCrdlQFfc=; b=j8fvpRE2NOO9lxMXUsSxea/YPlftUYcU5CtN+LCl3IeQFXS2jYwiDLLuL9Rk/qylkd3mE6L7e2UEjSk44a9GEHK3FZkmd1GfBKOECK+HD09MMPDRoKmv25Jjhc56XY+kRguOenGPqC/u+Q4Oh5xaO7sbIhsZ4BG08oyFKDu/WD8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683551770163480.32186875001867; Mon, 8 May 2023 06:16:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw0fw-00012v-Ao; Mon, 08 May 2023 09:13:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0ee-0007u1-3o for qemu-devel@nongnu.org; Mon, 08 May 2023 09:11:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw0ec-0001eE-GT for qemu-devel@nongnu.org; Mon, 08 May 2023 09:11:51 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-158-NtjEahS9M5uRwFWSxS89SA-1; Mon, 08 May 2023 09:11:44 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 34320108BDDE; Mon, 8 May 2023 13:11:32 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77D502166B40; Mon, 8 May 2023 13:11:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683551509; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EPSjqeVWM17XH9xo4fkTkuI4cQmJACpPRQiCrdlQFfc=; b=hSzJL+VuzhZUIIWqckblS44qnFbf4z1YTVr4ls395aw9xV270vXOAPH3io7PDDg03Wi82K x0Ilu0Roza6fJU16BgwUT0QaKAmNiOTupKN6wsOMgeBhF+gmSr8OHPUNFMtqjhKBTcz/qo 7dq6AvgtRMg/R1Dpu92QCHSICRMYgww= X-MC-Unique: NtjEahS9M5uRwFWSxS89SA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , qemu-block@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Juan Quintela , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Fam Zheng , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Leonardo Bras , Ilya Leoshkevich Subject: [PATCH 21/21] migration/multifd: Compute transferred bytes correctly Date: Mon, 8 May 2023 15:09:09 +0200 Message-Id: <20230508130909.65420-22-quintela@redhat.com> In-Reply-To: <20230508130909.65420-1-quintela@redhat.com> References: <20230508130909.65420-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683551771172100002 Content-Type: text/plain; charset="utf-8" In the past, we had to put the in the main thread all the operations related with sizes due to qemu_file not beeing thread safe. As now all counters are atomic, we can update the counters just after the do the write. As an aditional bonus, we are able to use the right value for the compression methods. Right now we were assuming that there were no compression at all. Signed-off-by: Juan Quintela Reviewed-by: Peter Xu --- migration/multifd.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index 9d2ade7abc..3a19d8e304 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -175,6 +175,7 @@ void multifd_register_ops(int method, MultiFDMethods *o= ps) static int multifd_send_initial_packet(MultiFDSendParams *p, Error **errp) { MultiFDInit_t msg =3D {}; + size_t size =3D sizeof(msg); int ret; =20 msg.magic =3D cpu_to_be32(MULTIFD_MAGIC); @@ -182,10 +183,12 @@ static int multifd_send_initial_packet(MultiFDSendPar= ams *p, Error **errp) msg.id =3D p->id; memcpy(msg.uuid, &qemu_uuid.data, sizeof(msg.uuid)); =20 - ret =3D qio_channel_write_all(p->c, (char *)&msg, sizeof(msg), errp); + ret =3D qio_channel_write_all(p->c, (char *)&msg, size, errp); if (ret !=3D 0) { return -1; } + stat64_add(&mig_stats.multifd_bytes, size); + stat64_add(&mig_stats.transferred, size); return 0; } =20 @@ -396,7 +399,6 @@ static int multifd_send_pages(QEMUFile *f) static int next_channel; MultiFDSendParams *p =3D NULL; /* make happy gcc */ MultiFDPages_t *pages =3D multifd_send_state->pages; - uint64_t transferred; =20 if (qatomic_read(&multifd_send_state->exiting)) { return -1; @@ -431,10 +433,7 @@ static int multifd_send_pages(QEMUFile *f) p->packet_num =3D multifd_send_state->packet_num++; multifd_send_state->pages =3D p->pages; p->pages =3D pages; - transferred =3D ((uint64_t) pages->num) * p->page_size + p->packet_len; qemu_mutex_unlock(&p->mutex); - stat64_add(&mig_stats.transferred, transferred); - stat64_add(&mig_stats.multifd_bytes, transferred); qemu_sem_post(&p->sem); =20 return 1; @@ -716,6 +715,8 @@ static void *multifd_send_thread(void *opaque) if (ret !=3D 0) { break; } + stat64_add(&mig_stats.multifd_bytes, p->packet_len); + stat64_add(&mig_stats.transferred, p->packet_len); } else { /* Send header using the same writev call */ p->iov[0].iov_len =3D p->packet_len; @@ -728,6 +729,8 @@ static void *multifd_send_thread(void *opaque) break; } =20 + stat64_add(&mig_stats.multifd_bytes, p->next_packet_size); + stat64_add(&mig_stats.transferred, p->next_packet_size); qemu_mutex_lock(&p->mutex); p->pending_job--; qemu_mutex_unlock(&p->mutex); --=20 2.40.0