[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/12] migration: Use migration_transferred_bytes() to calculate r
From: |
Juan Quintela |
Subject: |
[PULL 09/12] migration: Use migration_transferred_bytes() to calculate rate_limit |
Date: |
Thu, 18 May 2023 19:13:01 +0200 |
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20230515195709.63843-9-quintela@redhat.com>
---
migration/migration-stats.h | 8 +++++++-
migration/migration-stats.c | 7 +++++--
migration/migration.c | 2 +-
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/migration/migration-stats.h b/migration/migration-stats.h
index 827ea80c9b..4c4daa2e97 100644
--- a/migration/migration-stats.h
+++ b/migration/migration-stats.h
@@ -81,6 +81,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.
*/
@@ -122,8 +126,10 @@ uint64_t migration_rate_get(void);
* migration_rate_reset: Reset the rate limit counter.
*
* This is called when we know we start a new transfer cycle.
+ *
+ * @f: QEMUFile used for main migration channel
*/
-void migration_rate_reset(void);
+void migration_rate_reset(QEMUFile *f);
/**
* migration_rate_set: Set the maximum amount that can be transferred.
diff --git a/migration/migration-stats.c b/migration/migration-stats.c
index feec7d7369..97759a45f3 100644
--- a/migration/migration-stats.c
+++ b/migration/migration-stats.c
@@ -24,7 +24,9 @@ bool migration_rate_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);
if (rate_limit_max == RATE_LIMIT_DISABLED) {
@@ -51,9 +53,10 @@ void migration_rate_set(uint64_t limit)
stat64_set(&mig_stats.rate_limit_max, limit / XFER_LIMIT_RATIO);
}
-void migration_rate_reset(void)
+void migration_rate_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_account(uint64_t len)
diff --git a/migration/migration.c b/migration/migration.c
index 952100c8d7..5de7f734b9 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2692,7 +2692,7 @@ static void migration_update_counters(MigrationState *s,
stat64_get(&mig_stats.dirty_bytes_last_sync) / bandwidth;
}
- migration_rate_reset();
+ migration_rate_reset(s->to_dst_file);
update_iteration_initial_status(s);
--
2.40.1
- [PULL 00/12] Migration 20230518 patches, Juan Quintela, 2023/05/18
- [PULL 01/12] configure: add --disable-colo-proxy option, Juan Quintela, 2023/05/18
- [PULL 02/12] migration: split migration_incoming_co, Juan Quintela, 2023/05/18
- [PULL 03/12] migration: process_incoming_migration_co(): move colo part to colo, Juan Quintela, 2023/05/18
- [PULL 04/12] migration: Don't use INT64_MAX for unlimited rate, Juan Quintela, 2023/05/18
- [PULL 05/12] qemu-file: Account for rate_limit usage on qemu_fflush(), Juan Quintela, 2023/05/18
- [PULL 06/12] migration: Move rate_limit_max and rate_limit_used to migration_stats, Juan Quintela, 2023/05/18
- [PULL 07/12] migration: Move migration_total_bytes() to migration-stats.c, Juan Quintela, 2023/05/18
- [PULL 08/12] migration: Add a trace for migration_transferred_bytes, Juan Quintela, 2023/05/18
- [PULL 09/12] migration: Use migration_transferred_bytes() to calculate rate_limit,
Juan Quintela <=
- [PULL 11/12] migration/multifd: Compute transferred bytes correctly, Juan Quintela, 2023/05/18
- [PULL 12/12] migration: Fix duplicated included in meson.build, Juan Quintela, 2023/05/18
- [PULL 10/12] migration: We don't need the field rate_limit_used anymore, Juan Quintela, 2023/05/18