From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9223EC77B75 for ; Mon, 15 May 2023 13:12:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pyXsW-0008Ld-Fu; Mon, 15 May 2023 09:04:40 -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 1pyXr5-0004iT-Of; Mon, 15 May 2023 09:03:11 -0400 Received: from smtpout2.mo529.mail-out.ovh.net ([79.137.123.220]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pyXqx-00014L-TB; Mon, 15 May 2023 09:03:07 -0400 Received: from mxplan5.mail.ovh.net (unknown [10.108.4.108]) by mo529.mail-out.ovh.net (Postfix) with ESMTPS id 23BD420B93; Mon, 15 May 2023 13:03:00 +0000 (UTC) Received: from kaod.org (37.59.142.101) by DAG4EX2.mxp5.local (172.16.2.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 15 May 2023 15:02:58 +0200 Authentication-Results: garm.ovh; auth=pass (GARM-101G0042bf98b37-5662-4180-b36d-273fe31ae05b, C2820DDF228AE5DDDBFD944B87CC7F3B41DD1A91) smtp.auth=clg@kaod.org X-OVh-ClientIp: 82.64.250.170 Message-ID: <01a6a3c4-ac59-4fe5-4f0e-32ec7787a488@kaod.org> Date: Mon, 15 May 2023 15:02:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= Subject: Re: [PATCH 13/21] migration: Use migration_transferred_bytes() to calculate rate_limit To: Juan Quintela , CC: Daniel Henrique Barboza , Christian Borntraeger , David Hildenbrand , Stefan Hajnoczi , , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Halil Pasic , Peter Xu , Richard Henderson , David Gibson , Harsh Prateek Bora , Eric Farman , Greg Kurz , , , Fam Zheng , Thomas Huth , Leonardo Bras , Ilya Leoshkevich References: <20230508130909.65420-1-quintela@redhat.com> <20230508130909.65420-14-quintela@redhat.com> Content-Language: en-US In-Reply-To: <20230508130909.65420-14-quintela@redhat.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [37.59.142.101] X-ClientProxiedBy: DAG7EX1.mxp5.local (172.16.2.61) To DAG4EX2.mxp5.local (172.16.2.32) X-Ovh-Tracer-GUID: 180b0d1c-5df3-44af-8b41-7d51f1ab75cb X-Ovh-Tracer-Id: 3279464955124616089 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrfeehjedgieduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepkfffgggfhffuvfevfhgjtgfgihesthekredttdefjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucggtffrrghtthgvrhhnpeeivefgteeltdefleeiiedutdfhledvhedutdeuteetvdejkeejgeeigfeileffgeenucfkphepuddvjedrtddrtddruddpfeejrdehledrudegvddruddtuddpkedvrdeigedrvdehtddrudejtdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepoegtlhhgsehkrghougdrohhrgheqpdhnsggprhgtphhtthhopedupdhrtghpthhtohepqhhuihhnthgvlhgrsehrvgguhhgrthdrtghomhdpthhhuhhthhesrhgvughhrghtrdgtohhmpdhfrghmsegvuhhphhhonhdrnhgvthdpqhgvmhhuqdhsfeeltdigsehnohhnghhnuhdrohhrghdpqhgvmhhuqdhpphgtsehnohhnghhnuhdrohhrghdpfhgrrhhmrghnsehlihhnuhigrdhisghmrdgtohhmpdhhrghrshhhphgssehlihhnuhigrdhisghmrdgtohhmpdgurghvihgusehgihgsshhonhdrughrohhpsggvrghrrdhiugdrrghupdhrih gthhgrrhgurdhhvghnuggvrhhsohhnsehlihhnrghrohdrohhrghdplhgvohgsrhgrshesrhgvughhrghtrdgtohhmpdhpvghtvghrgiesrhgvughhrghtrdgtohhmpdhjshhnohifsehrvgguhhgrthdrtghomhdpvhhsvghmvghnthhsohhvseihrghnuggvgidqthgvrghmrdhruhdpvggslhgrkhgvsehrvgguhhgrthdrtghomhdpqhgvmhhuqdgslhhotghksehnohhnghhnuhdrohhrghdpshhtvghfrghnhhgrsehrvgguhhgrthdrtghomhdpuggrvhhiugesrhgvughhrghtrdgtohhmpdgsohhrnhhtrhgrvghgvghrsehlihhnuhigrdhisghmrdgtohhmpdgurghnihgvlhhhsgegudefsehgmhgrihhlrdgtohhmpdhqvghmuhdquggvvhgvlhesnhhonhhgnhhurdhorhhgpdhprghsihgtsehlihhnuhigrdhisghmrdgtohhmpdhiihhisehlihhnuhigrdhisghmrdgtohhmpdhgrhhouhhgsehkrghougdrohhrghdpoffvtefjohhsthepmhhohedvledpmhhouggvpehsmhhtphhouhht Received-SPF: pass client-ip=79.137.123.220; envelope-from=clg@kaod.org; helo=smtpout2.mo529.mail-out.ovh.net X-Spam_score_int: -56 X-Spam_score: -5.7 X-Spam_bar: ----- X-Spam_report: (-5.7 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-3.811, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On 5/8/23 15:09, Juan Quintela wrote: > Signed-off-by: Juan Quintela Reviewed-by: Cédric Le Goater C. > --- > 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; > } > > - uint64_t rate_limit_used = stat64_get(&mig_stats.rate_limit_used); > + uint64_t rate_limit_start = stat64_get(&mig_stats.rate_limit_start); > + uint64_t rate_limit_current = migration_transferred_bytes(f); > + uint64_t rate_limit_used = rate_limit_current - rate_limit_start; > uint64_t rate_limit_max = stat64_get(&mig_stats.rate_limit_max); > /* > * rate_limit_max == 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); > } > > -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)); > } > > 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); > > /** > * migration_rate_limit_set: Set the maximum amount that can be transferred. > 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; > } > > - migration_rate_limit_reset(); > + migration_rate_limit_reset(s->to_dst_file); > > update_iteration_initial_status(s); >