All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Straub <lukasstraub2@web.de>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org, Peter Xu <peterx@redhat.com>,
	Leonardo Bras <leobras@redhat.com>
Subject: Re: [PATCH 03/19] migration: Rename ram_counters to mig_stats
Date: Thu, 27 Apr 2023 20:31:24 +0200	[thread overview]
Message-ID: <20230427183124.77bd476a@gecko.fritz.box> (raw)
In-Reply-To: <20230427163449.27473-4-quintela@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 14461 bytes --]

On Thu, 27 Apr 2023 18:34:33 +0200
Juan Quintela <quintela@redhat.com> wrote:

> migration_stats is just too long, and it is going to have more than
> ram counters in the near future.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Lukas Straub <lukasstraub2@web.de>

> ---
>  migration/migration-stats.c |  2 +-
>  migration/migration-stats.h |  2 +-
>  migration/migration.c       | 32 ++++++++++++-------------
>  migration/multifd.c         |  6 ++---
>  migration/ram.c             | 48 ++++++++++++++++++-------------------
>  migration/savevm.c          |  2 +-
>  6 files changed, 46 insertions(+), 46 deletions(-)
> 
> diff --git a/migration/migration-stats.c b/migration/migration-stats.c
> index b0eb5ae73c..8c0af9b80a 100644
> --- a/migration/migration-stats.c
> +++ b/migration/migration-stats.c
> @@ -14,4 +14,4 @@
>  #include "qemu/stats64.h"
>  #include "migration-stats.h"
>  
> -RAMStats ram_counters;
> +RAMStats mig_stats;
> diff --git a/migration/migration-stats.h b/migration/migration-stats.h
> index 2edea0c779..197374b4f6 100644
> --- a/migration/migration-stats.h
> +++ b/migration/migration-stats.h
> @@ -36,6 +36,6 @@ typedef struct {
>      Stat64 transferred;
>  } RAMStats;
>  
> -extern RAMStats ram_counters;
> +extern RAMStats mig_stats;
>  
>  #endif
> diff --git a/migration/migration.c b/migration/migration.c
> index 5ecf3dc381..feb5ab7493 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -909,26 +909,26 @@ static void populate_ram_info(MigrationInfo *info, MigrationState *s)
>      size_t page_size = qemu_target_page_size();
>  
>      info->ram = g_malloc0(sizeof(*info->ram));
> -    info->ram->transferred = stat64_get(&ram_counters.transferred);
> +    info->ram->transferred = stat64_get(&mig_stats.transferred);
>      info->ram->total = ram_bytes_total();
> -    info->ram->duplicate = stat64_get(&ram_counters.zero_pages);
> +    info->ram->duplicate = stat64_get(&mig_stats.zero_pages);
>      /* legacy value.  It is not used anymore */
>      info->ram->skipped = 0;
> -    info->ram->normal = stat64_get(&ram_counters.normal_pages);
> +    info->ram->normal = stat64_get(&mig_stats.normal_pages);
>      info->ram->normal_bytes = info->ram->normal * page_size;
>      info->ram->mbps = s->mbps;
>      info->ram->dirty_sync_count =
> -        stat64_get(&ram_counters.dirty_sync_count);
> +        stat64_get(&mig_stats.dirty_sync_count);
>      info->ram->dirty_sync_missed_zero_copy =
> -        stat64_get(&ram_counters.dirty_sync_missed_zero_copy);
> +        stat64_get(&mig_stats.dirty_sync_missed_zero_copy);
>      info->ram->postcopy_requests =
> -        stat64_get(&ram_counters.postcopy_requests);
> +        stat64_get(&mig_stats.postcopy_requests);
>      info->ram->page_size = page_size;
> -    info->ram->multifd_bytes = stat64_get(&ram_counters.multifd_bytes);
> +    info->ram->multifd_bytes = stat64_get(&mig_stats.multifd_bytes);
>      info->ram->pages_per_second = s->pages_per_second;
> -    info->ram->precopy_bytes = stat64_get(&ram_counters.precopy_bytes);
> -    info->ram->downtime_bytes = stat64_get(&ram_counters.downtime_bytes);
> -    info->ram->postcopy_bytes = stat64_get(&ram_counters.postcopy_bytes);
> +    info->ram->precopy_bytes = stat64_get(&mig_stats.precopy_bytes);
> +    info->ram->downtime_bytes = stat64_get(&mig_stats.downtime_bytes);
> +    info->ram->postcopy_bytes = stat64_get(&mig_stats.postcopy_bytes);
>  
>      if (migrate_xbzrle()) {
>          info->xbzrle_cache = g_malloc0(sizeof(*info->xbzrle_cache));
> @@ -960,7 +960,7 @@ static void populate_ram_info(MigrationInfo *info, MigrationState *s)
>      if (s->state != MIGRATION_STATUS_COMPLETED) {
>          info->ram->remaining = ram_bytes_remaining();
>          info->ram->dirty_pages_rate =
> -           stat64_get(&ram_counters.dirty_pages_rate);
> +           stat64_get(&mig_stats.dirty_pages_rate);
>      }
>  }
>  
> @@ -1613,10 +1613,10 @@ static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc,
>  
>      migrate_init(s);
>      /*
> -     * set ram_counters compression_counters memory to zero for a
> +     * set mig_stats compression_counters memory to zero for a
>       * new migration
>       */
> -    memset(&ram_counters, 0, sizeof(ram_counters));
> +    memset(&mig_stats, 0, sizeof(mig_stats));
>      memset(&compression_counters, 0, sizeof(compression_counters));
>  
>      return true;
> @@ -2627,7 +2627,7 @@ static MigThrError migration_detect_error(MigrationState *s)
>  static uint64_t migration_total_bytes(MigrationState *s)
>  {
>      return qemu_file_total_transferred(s->to_dst_file) +
> -        stat64_get(&ram_counters.multifd_bytes);
> +        stat64_get(&mig_stats.multifd_bytes);
>  }
>  
>  static void migration_calculate_complete(MigrationState *s)
> @@ -2691,10 +2691,10 @@ static void migration_update_counters(MigrationState *s,
>       * if we haven't sent anything, we don't want to
>       * recalculate. 10000 is a small enough number for our purposes
>       */
> -    if (stat64_get(&ram_counters.dirty_pages_rate) &&
> +    if (stat64_get(&mig_stats.dirty_pages_rate) &&
>          transferred > 10000) {
>          s->expected_downtime =
> -            stat64_get(&ram_counters.dirty_bytes_last_sync) / bandwidth;
> +            stat64_get(&mig_stats.dirty_bytes_last_sync) / bandwidth;
>      }
>  
>      qemu_file_reset_rate_limit(s->to_dst_file);
> diff --git a/migration/multifd.c b/migration/multifd.c
> index 347999f84a..4a2e1a47ce 100644
> --- a/migration/multifd.c
> +++ b/migration/multifd.c
> @@ -434,8 +434,8 @@ static int multifd_send_pages(QEMUFile *f)
>      transferred = ((uint64_t) pages->num) * p->page_size + p->packet_len;
>      qemu_file_acct_rate_limit(f, transferred);
>      qemu_mutex_unlock(&p->mutex);
> -    stat64_add(&ram_counters.transferred, transferred);
> -    stat64_add(&ram_counters.multifd_bytes, transferred);
> +    stat64_add(&mig_stats.transferred, transferred);
> +    stat64_add(&mig_stats.multifd_bytes, transferred);
>      qemu_sem_post(&p->sem);
>  
>      return 1;
> @@ -577,7 +577,7 @@ static int multifd_zero_copy_flush(QIOChannel *c)
>          return -1;
>      }
>      if (ret == 1) {
> -        stat64_add(&ram_counters.dirty_sync_missed_zero_copy, 1);
> +        stat64_add(&mig_stats.dirty_sync_missed_zero_copy, 1);
>      }
>  
>      return ret;
> diff --git a/migration/ram.c b/migration/ram.c
> index a6d5478ef8..c3981f64e4 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -464,13 +464,13 @@ uint64_t ram_bytes_remaining(void)
>  void ram_transferred_add(uint64_t bytes)
>  {
>      if (runstate_is_running()) {
> -        stat64_add(&ram_counters.precopy_bytes, bytes);
> +        stat64_add(&mig_stats.precopy_bytes, bytes);
>      } else if (migration_in_postcopy()) {
> -        stat64_add(&ram_counters.postcopy_bytes, bytes);
> +        stat64_add(&mig_stats.postcopy_bytes, bytes);
>      } else {
> -        stat64_add(&ram_counters.downtime_bytes, bytes);
> +        stat64_add(&mig_stats.downtime_bytes, bytes);
>      }
> -    stat64_add(&ram_counters.transferred, bytes);
> +    stat64_add(&mig_stats.transferred, bytes);
>  }
>  
>  struct MigrationOps {
> @@ -744,7 +744,7 @@ void mig_throttle_counter_reset(void)
>  
>      rs->time_last_bitmap_sync = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
>      rs->num_dirty_pages_period = 0;
> -    rs->bytes_xfer_prev = stat64_get(&ram_counters.transferred);
> +    rs->bytes_xfer_prev = stat64_get(&mig_stats.transferred);
>  }
>  
>  /**
> @@ -764,7 +764,7 @@ static void xbzrle_cache_zero_page(RAMState *rs, ram_addr_t current_addr)
>      /* We don't care if this fails to allocate a new cache page
>       * as long as it updated an old one */
>      cache_insert(XBZRLE.cache, current_addr, XBZRLE.zero_target_page,
> -                 stat64_get(&ram_counters.dirty_sync_count));
> +                 stat64_get(&mig_stats.dirty_sync_count));
>  }
>  
>  #define ENCODING_FLAG_XBZRLE 0x1
> @@ -790,7 +790,7 @@ static int save_xbzrle_page(RAMState *rs, PageSearchStatus *pss,
>      int encoded_len = 0, bytes_xbzrle;
>      uint8_t *prev_cached_page;
>      QEMUFile *file = pss->pss_channel;
> -    uint64_t generation = stat64_get(&ram_counters.dirty_sync_count);
> +    uint64_t generation = stat64_get(&mig_stats.dirty_sync_count);
>  
>      if (!cache_is_cached(XBZRLE.cache, current_addr, generation)) {
>          xbzrle_counters.cache_miss++;
> @@ -1118,8 +1118,8 @@ uint64_t ram_pagesize_summary(void)
>  
>  uint64_t ram_get_total_transferred_pages(void)
>  {
> -    return stat64_get(&ram_counters.normal_pages) +
> -        stat64_get(&ram_counters.zero_pages) +
> +    return stat64_get(&mig_stats.normal_pages) +
> +        stat64_get(&mig_stats.zero_pages) +
>          compression_counters.pages + xbzrle_counters.pages;
>  }
>  
> @@ -1129,7 +1129,7 @@ static void migration_update_rates(RAMState *rs, int64_t end_time)
>      double compressed_size;
>  
>      /* calculate period counters */
> -    stat64_set(&ram_counters.dirty_pages_rate,
> +    stat64_set(&mig_stats.dirty_pages_rate,
>                 rs->num_dirty_pages_period * 1000 /
>                 (end_time - rs->time_last_bitmap_sync));
>  
> @@ -1180,7 +1180,7 @@ static void migration_trigger_throttle(RAMState *rs)
>  {
>      uint64_t threshold = migrate_throttle_trigger_threshold();
>      uint64_t bytes_xfer_period =
> -        stat64_get(&ram_counters.transferred) - rs->bytes_xfer_prev;
> +        stat64_get(&mig_stats.transferred) - rs->bytes_xfer_prev;
>      uint64_t bytes_dirty_period = rs->num_dirty_pages_period * TARGET_PAGE_SIZE;
>      uint64_t bytes_dirty_threshold = bytes_xfer_period * threshold / 100;
>  
> @@ -1209,7 +1209,7 @@ static void migration_bitmap_sync(RAMState *rs)
>      RAMBlock *block;
>      int64_t end_time;
>  
> -    stat64_add(&ram_counters.dirty_sync_count, 1);
> +    stat64_add(&mig_stats.dirty_sync_count, 1);
>  
>      if (!rs->time_last_bitmap_sync) {
>          rs->time_last_bitmap_sync = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
> @@ -1223,7 +1223,7 @@ static void migration_bitmap_sync(RAMState *rs)
>          RAMBLOCK_FOREACH_NOT_IGNORED(block) {
>              ramblock_sync_dirty_bitmap(rs, block);
>          }
> -        stat64_set(&ram_counters.dirty_bytes_last_sync, ram_bytes_remaining());
> +        stat64_set(&mig_stats.dirty_bytes_last_sync, ram_bytes_remaining());
>      }
>      qemu_mutex_unlock(&rs->bitmap_mutex);
>  
> @@ -1243,10 +1243,10 @@ static void migration_bitmap_sync(RAMState *rs)
>          /* reset period counters */
>          rs->time_last_bitmap_sync = end_time;
>          rs->num_dirty_pages_period = 0;
> -        rs->bytes_xfer_prev = stat64_get(&ram_counters.transferred);
> +        rs->bytes_xfer_prev = stat64_get(&mig_stats.transferred);
>      }
>      if (migrate_events()) {
> -        uint64_t generation = stat64_get(&ram_counters.dirty_sync_count);
> +        uint64_t generation = stat64_get(&mig_stats.dirty_sync_count);
>          qapi_event_send_migration_pass(generation);
>      }
>  }
> @@ -1320,7 +1320,7 @@ static int save_zero_page(PageSearchStatus *pss, QEMUFile *f, RAMBlock *block,
>      int len = save_zero_page_to_file(pss, f, block, offset);
>  
>      if (len) {
> -        stat64_add(&ram_counters.zero_pages, 1);
> +        stat64_add(&mig_stats.zero_pages, 1);
>          ram_transferred_add(len);
>          return 1;
>      }
> @@ -1357,9 +1357,9 @@ static bool control_save_page(PageSearchStatus *pss, RAMBlock *block,
>      }
>  
>      if (bytes_xmit > 0) {
> -        stat64_add(&ram_counters.normal_pages, 1);
> +        stat64_add(&mig_stats.normal_pages, 1);
>      } else if (bytes_xmit == 0) {
> -        stat64_add(&ram_counters.zero_pages, 1);
> +        stat64_add(&mig_stats.zero_pages, 1);
>      }
>  
>      return true;
> @@ -1391,7 +1391,7 @@ static int save_normal_page(PageSearchStatus *pss, RAMBlock *block,
>          qemu_put_buffer(file, buf, TARGET_PAGE_SIZE);
>      }
>      ram_transferred_add(TARGET_PAGE_SIZE);
> -    stat64_add(&ram_counters.normal_pages, 1);
> +    stat64_add(&mig_stats.normal_pages, 1);
>      return 1;
>  }
>  
> @@ -1447,7 +1447,7 @@ static int ram_save_multifd_page(QEMUFile *file, RAMBlock *block,
>      if (multifd_queue_page(file, block, offset) < 0) {
>          return -1;
>      }
> -    stat64_add(&ram_counters.normal_pages, 1);
> +    stat64_add(&mig_stats.normal_pages, 1);
>  
>      return 1;
>  }
> @@ -1486,7 +1486,7 @@ update_compress_thread_counts(const CompressParam *param, int bytes_xmit)
>      ram_transferred_add(bytes_xmit);
>  
>      if (param->zero_page) {
> -        stat64_add(&ram_counters.zero_pages, 1);
> +        stat64_add(&mig_stats.zero_pages, 1);
>          return;
>      }
>  
> @@ -2179,7 +2179,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len)
>      RAMBlock *ramblock;
>      RAMState *rs = ram_state;
>  
> -    stat64_add(&ram_counters.postcopy_requests, 1);
> +    stat64_add(&mig_stats.postcopy_requests, 1);
>      RCU_READ_LOCK_GUARD();
>  
>      if (!rbname) {
> @@ -2634,9 +2634,9 @@ void acct_update_position(QEMUFile *f, size_t size, bool zero)
>      uint64_t pages = size / TARGET_PAGE_SIZE;
>  
>      if (zero) {
> -        stat64_add(&ram_counters.zero_pages, pages);
> +        stat64_add(&mig_stats.zero_pages, pages);
>      } else {
> -        stat64_add(&ram_counters.normal_pages, pages);
> +        stat64_add(&mig_stats.normal_pages, pages);
>          ram_transferred_add(size);
>          qemu_file_credit_transfer(f, size);
>      }
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 8e2efb1a19..a9d0a88e62 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -1622,7 +1622,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
>      }
>  
>      migrate_init(ms);
> -    memset(&ram_counters, 0, sizeof(ram_counters));
> +    memset(&mig_stats, 0, sizeof(mig_stats));
>      memset(&compression_counters, 0, sizeof(compression_counters));
>      ms->to_dst_file = f;
>  



-- 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2023-04-27 18:32 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-27 16:34 [PATCH 00/19] migration: Remove QEMUFileHooks Juan Quintela
2023-04-27 16:34 ` [PATCH 01/19] multifd: We already account for this packet on the multifd thread Juan Quintela
2023-04-27 18:23   ` Lukas Straub
2023-04-27 16:34 ` [PATCH 02/19] migration: Move ram_stats to its own file migration-stats.[ch] Juan Quintela
2023-04-27 18:30   ` Lukas Straub
2023-04-27 16:34 ` [PATCH 03/19] migration: Rename ram_counters to mig_stats Juan Quintela
2023-04-27 18:31   ` Lukas Straub [this message]
2023-04-27 16:34 ` [PATCH 04/19] migration: Rename RAMStats to MigrationAtomicStats Juan Quintela
2023-04-27 18:58   ` Lukas Straub
2023-04-27 16:34 ` [PATCH 05/19] migration/rdma: Split the zero page case from acct_update_position Juan Quintela
2023-04-27 18:59   ` Lukas Straub
2023-04-27 16:34 ` [PATCH 06/19] migration/rdma: Unfold last user of acct_update_position() Juan Quintela
2023-04-27 19:01   ` Lukas Straub
2023-04-27 16:34 ` [PATCH 07/19] migration/rdma: Unflod ram_control_before_iterate() Juan Quintela
2023-04-28  9:06   ` Juan Quintela
2023-04-27 16:34 ` [PATCH 08/19] migration/rdma: Unflod ram_control_after_iterate() Juan Quintela
2023-04-27 16:34 ` [PATCH 09/19] migration/rdma: simplify ram_control_load_hook() Juan Quintela
2023-04-27 16:34 ` [PATCH 10/19] migration/rdma: Don't pass the QIOChannelRDMA as an opaque Juan Quintela
2023-04-27 16:34 ` [PATCH 11/19] migration/rdma: We can calculate the rioc from the QEMUFile Juan Quintela
2023-04-27 16:34 ` [PATCH 12/19] migration/rdma: It makes no sense to recive that flag without RDMA Juan Quintela
2023-04-27 16:34 ` [PATCH 13/19] migration: Make RAM_SAVE_FLAG_HOOK a normal case entry Juan Quintela
2023-04-27 16:34 ` [PATCH 14/19] migration/rdma: Remove all uses of RAM_CONTROL_HOOK Juan Quintela
2023-04-27 16:34 ` [PATCH 15/19] migration/rdma: Unfold hook_ram_load() Juan Quintela
2023-04-27 16:34 ` [PATCH 16/19] migration/rdma: Make ram_control_save_page() use exported interfaces Juan Quintela
2023-04-27 16:34 ` [PATCH 17/19] migration/rdma: Create rdma_control_save_page() Juan Quintela
2023-04-27 16:34 ` [PATCH 18/19] qemu-file: Remove QEMUFileHooks Juan Quintela
2023-04-27 16:34 ` [PATCH 19/19] migration/rdma: Move rdma constants from qemu-file.h to rdma.h Juan Quintela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230427183124.77bd476a@gecko.fritz.box \
    --to=lukasstraub2@web.de \
    --cc=leobras@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.