From nobody Mon Feb 9 20:34:35 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=1684154283; cv=none; d=zohomail.com; s=zohoarc; b=ApAbk9TfAV2ql+oqAcFD9il1tgbFns2Lo1quJQOERfk8oEvRhS/KQOQAWTydeBvkAXCb23UxyEgaQjCHrcX3L+7KGQ4SiTG1BLPEWZ8hBpFahrzpiSuoH68OnfrzXhNWJq66uAwrEtzRbifPO5uHa/ZV1WxXRCLtUIFxgs6zFSk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684154283; 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=8PlvK0jZEypQL5Au5TZqNRqloEjsCBWZio4hIgCCZls=; b=augT7gjJZrJ4mL0i9ntngSNfZC++447P7TSSM2tz7czJKsp7i6VGEgfip+JU6C9UVTd0TvflpSjNggNOS8i3u7NLrrN4fU9Dympch7tDL+lroqNMDgA4vPOUuiZ10nx0Av2n4JF+5+xmVxf+45fib9bTJo+JkU+ziZLkGoNZybw= 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 1684154283696757.8335161667176; Mon, 15 May 2023 05:38:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pyXPh-0006qo-Li; Mon, 15 May 2023 08:34:53 -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 1pyXPA-0006Up-3s for qemu-devel@nongnu.org; Mon, 15 May 2023 08:34:25 -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 1pyXOs-0003Lr-DO for qemu-devel@nongnu.org; Mon, 15 May 2023 08:34:18 -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-668-jgZ8rO_EPriEu1Wo0fYpZg-1; Mon, 15 May 2023 08:33:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C70B738123AD; Mon, 15 May 2023 12:33:54 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.171]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9A4D35453; Mon, 15 May 2023 12:33:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684154038; 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=8PlvK0jZEypQL5Au5TZqNRqloEjsCBWZio4hIgCCZls=; b=M4tqc+Z6pN3v/PeLDZds9hwM2wAqglsWwgOs69p+v1oWnGKt8PyxMmqrMdOTi4FNtfk+Iu B5sHnKjXxI+zVfLSRJXXvorzSg0CHvlrwK2yse1FYKl0QfuKnjPJM0DNgTKz6NxcdLdD7k htMAvGQFRO8g5R24FgiYzSVnkl34C2I= X-MC-Unique: jgZ8rO_EPriEu1Wo0fYpZg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: David Hildenbrand , qemu-block@nongnu.org, Juan Quintela , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Leonardo Bras , Peter Xu , Stefan Hajnoczi , Fam Zheng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PULL 08/11] migration: We set the rate_limit by a second Date: Mon, 15 May 2023 14:33:31 +0200 Message-Id: <20230515123334.58995-9-quintela@redhat.com> In-Reply-To: <20230515123334.58995-1-quintela@redhat.com> References: <20230515123334.58995-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.5 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, 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: 1684154284330100001 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 Message-Id: <20230508130909.65420-4-quintela@redhat.com> --- 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 5636119e8e..73ac63746b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2140,7 +2140,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); @@ -3231,11 +3231,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 7ed88b7b32..c2a278ee2d 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 @@ -1273,7 +1273,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 61fb580342..60f6345033 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 @@ -744,7 +745,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.1