[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 06/16] migration: Move migration_total_bytes() to migratio
From: |
Leonardo Brás |
Subject: |
Re: [PATCH v2 06/16] migration: Move migration_total_bytes() to migration-stats.c |
Date: |
Thu, 25 May 2023 00:09:55 -0300 |
User-agent: |
Evolution 3.48.1 |
On Mon, 2023-05-15 at 21:56 +0200, Juan Quintela wrote:
> Once there rename it to migration_transferred_bytes() and pass a
> QEMUFile instead of a migration object.
>
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> Reviewed-by: Cédric Le Goater <clg@kaod.org>
> ---
> migration/migration-stats.h | 11 +++++++++++
> migration/migration-stats.c | 6 ++++++
> migration/migration.c | 13 +++----------
> 3 files changed, 20 insertions(+), 10 deletions(-)
>
> diff --git a/migration/migration-stats.h b/migration/migration-stats.h
> index e39c083245..91fda378d3 100644
> --- a/migration/migration-stats.h
> +++ b/migration/migration-stats.h
> @@ -147,4 +147,15 @@ void migration_rate_reset(void);
> * @new_rate: new maximum amount
> */
> void migration_rate_set(uint64_t new_rate);
> +
> +/**
> + * migration_transferred_bytes: Return number of bytes transferred
> + *
> + * @f: QEMUFile used for main migration channel
> + *
> + * Returns how many bytes have we transferred since the beginning of
> + * the migration. It accounts for bytes sent through any migration
> + * channel, multifd, qemu_file, rdma, ....
> + */
> +uint64_t migration_transferred_bytes(QEMUFile *f);
> #endif
> diff --git a/migration/migration-stats.c b/migration/migration-stats.c
> index 1b16edae7d..9bd97caa23 100644
> --- a/migration/migration-stats.c
> +++ b/migration/migration-stats.c
> @@ -66,3 +66,9 @@ void migration_rate_account(uint64_t len)
> {
> stat64_add(&mig_stats.rate_limit_used, len);
> }
> +
> +uint64_t migration_transferred_bytes(QEMUFile *f)
> +{
> + return qemu_file_transferred(f) + stat64_get(&mig_stats.multifd_bytes);
> +}
> +
> diff --git a/migration/migration.c b/migration/migration.c
> index 594709dbbc..39ff538046 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -2624,16 +2624,9 @@ static MigThrError
> migration_detect_error(MigrationState *s)
> }
> }
>
> -/* How many bytes have we transferred since the beginning of the migration */
> -static uint64_t migration_total_bytes(MigrationState *s)
> -{
> - return qemu_file_transferred(s->to_dst_file) +
> - stat64_get(&mig_stats.multifd_bytes);
> -}
> -
> static void migration_calculate_complete(MigrationState *s)
> {
> - uint64_t bytes = migration_total_bytes(s);
> + uint64_t bytes = migration_transferred_bytes(s->to_dst_file);
> int64_t end_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
> int64_t transfer_time;
>
> @@ -2659,7 +2652,7 @@ static void
> update_iteration_initial_status(MigrationState *s)
> * wrong speed calculation.
> */
> s->iteration_start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
> - s->iteration_initial_bytes = migration_total_bytes(s);
> + s->iteration_initial_bytes = migration_transferred_bytes(s->to_dst_file);
> s->iteration_initial_pages = ram_get_total_transferred_pages();
> }
>
> @@ -2674,7 +2667,7 @@ static void migration_update_counters(MigrationState *s,
> return;
> }
>
> - current_bytes = migration_total_bytes(s);
> + current_bytes = migration_transferred_bytes(s->to_dst_file);
> transferred = current_bytes - s->iteration_initial_bytes;
> time_spent = current_time - s->iteration_start_time;
> bandwidth = (double)transferred / time_spent;
LGTM
Reviewed-by: Leonardo Bras <leobras@redhat.com>
- Re: [PATCH v2 03/16] migration: Move setup_time to mig_stats, (continued)
Re: [PATCH v2 03/16] migration: Move setup_time to mig_stats, Leonardo Brás, 2023/05/24
[PATCH v2 04/16] qemu-file: Account for rate_limit usage on qemu_fflush(), Juan Quintela, 2023/05/15
[PATCH v2 06/16] migration: Move migration_total_bytes() to migration-stats.c, Juan Quintela, 2023/05/15
- Re: [PATCH v2 06/16] migration: Move migration_total_bytes() to migration-stats.c,
Leonardo Brás <=
[PATCH v2 05/16] migration: Move rate_limit_max and rate_limit_used to migration_stats, Juan Quintela, 2023/05/15
[PATCH v2 07/16] migration: Add a trace for migration_transferred_bytes, Juan Quintela, 2023/05/15
[PATCH v2 08/16] migration: Use migration_transferred_bytes() to calculate rate_limit, Juan Quintela, 2023/05/15
[PATCH v2 09/16] migration: We don't need the field rate_limit_used anymore, Juan Quintela, 2023/05/15