From nobody Tue Feb 10 05:41:46 2026 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=1684180845; cv=none; d=zohomail.com; s=zohoarc; b=dl5VwHoLeAFUkieUlnmeqyaM3dFZMWhT5FXi/w9g5WSLXwWcYlRozhUju0hVtRm4Uh65+ESMScG5a96MiFyNG8ml9h6Fn64Wc4IhTEMH2RftHvF+YDV1qhPbTIK+Q11hwsgdP5gECQOR2z/VSBToxNtyZXz8cdVvvEUOa1qhle4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684180845; 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=rv0OW6U2taWTBZp3ks0AuejA0Q/nSmNZ/Pvn3eecT5c=; b=UrGgtlTPSYUjeJHHOdWs9hhj+M9YMAWBuWnLI9HLjsTD2Xt3081m9+rpzay2RY/REa+NioTIvbzRMBa7jnwpqWkVy5YiHIgA5fBYoOziprNWOlDelKT/weSQWaN5X4ChJuwvu8n9PAGyUNZwZAzNKD8GV52Q0U9tQNiJUlnsNO0= 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 1684180845162148.38116767963982; Mon, 15 May 2023 13:00:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pyeLH-0002bs-LB; Mon, 15 May 2023 15:58:47 -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 1pyeL4-0001oM-4h for qemu-devel@nongnu.org; Mon, 15 May 2023 15:58:34 -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 1pyeL2-0005aY-06 for qemu-devel@nongnu.org; Mon, 15 May 2023 15:58:33 -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-501-Tu5HA8yyPMy551Q7mUAx1g-1; Mon, 15 May 2023 15:58:28 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2B4FA2999B29; Mon, 15 May 2023 19:58:27 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.171]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B80E492B00; Mon, 15 May 2023 19:58:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684180711; 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=rv0OW6U2taWTBZp3ks0AuejA0Q/nSmNZ/Pvn3eecT5c=; b=S9JMN6LxiW/EuhRSwfzUhrd6YpdpaFBQ526U8Hm4iShuYLGXhnxIolOXYK/1Sz2Ef5yVvM 5QQWq/3J7AS9H0FBzH0scNL7OUB8KV4C58YxoDWpcbQLQK0gyE5h3ZugEWTxAgc2egPl1B dSNHukkEf73g0IAsRmPu39lVT6zRidE= X-MC-Unique: Tu5HA8yyPMy551Q7mUAx1g-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Greg Kurz , qemu-s390x@nongnu.org, Fam Zheng , Ilya Leoshkevich , Halil Pasic , John Snow , qemu-ppc@nongnu.org, Daniel Henrique Barboza , Harsh Prateek Bora , Christian Borntraeger , Richard Henderson , David Gibson , David Hildenbrand , Stefan Hajnoczi , Eric Farman , qemu-block@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Eric Blake , Leonardo Bras , Thomas Huth , Juan Quintela , Vladimir Sementsov-Ogievskiy Subject: [PATCH v2 16/16] migration/multifd: Compute transferred bytes correctly Date: Mon, 15 May 2023 21:57:09 +0200 Message-Id: <20230515195709.63843-17-quintela@redhat.com> In-Reply-To: <20230515195709.63843-1-quintela@redhat.com> References: <20230515195709.63843-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: 1684180845618100001 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: Leonardo Bras --- migration/multifd.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index aabf9b6d98..0bf5958a9c 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 @@ -395,7 +398,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; @@ -430,10 +432,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; @@ -715,6 +714,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; @@ -727,6 +728,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.1