[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 13/21] migration: Use migration_transferred_bytes() to calculate
From: |
Juan Quintela |
Subject: |
[PATCH 13/21] migration: Use migration_transferred_bytes() to calculate rate_limit |
Date: |
Mon, 8 May 2023 15:09:01 +0200 |
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
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);
--
2.40.0
- Re: [PATCH 10/21] migration: Move rate_limit_max and rate_limit_used to migration_stats, (continued)
[PATCH 11/21] migration: Move migration_total_bytes() to migration-stats.c, Juan Quintela, 2023/05/08
[PATCH 12/21] migration: Add a trace for migration_transferred_bytes, Juan Quintela, 2023/05/08
[PATCH 13/21] migration: Use migration_transferred_bytes() to calculate rate_limit,
Juan Quintela <=
[PATCH 15/21] migration: Don't abuse qemu_file transferred for RDMA, Juan Quintela, 2023/05/08
[PATCH 14/21] migration: We don't need the field rate_limit_used anymore, Juan Quintela, 2023/05/08
[PATCH 18/21] migration/rdma: Don't use imaginary transfers, Juan Quintela, 2023/05/08
[PATCH 19/21] migration: Remove unused qemu_file_credit_transfer(), Juan Quintela, 2023/05/08
[PATCH 16/21] migration/RDMA: It is accounting for zero/normal pages in two places, Juan Quintela, 2023/05/08
[PATCH 17/21] migration/rdma: Remove QEMUFile parameter when not used, Juan Quintela, 2023/05/08
[PATCH 20/21] migration/rdma: Simplify the function that saves a page, Juan Quintela, 2023/05/08
[PATCH 21/21] migration/multifd: Compute transferred bytes correctly, Juan Quintela, 2023/05/08