diff mbox

[2/7] migration: Add counters of updating the dirty bitmap

Message ID 33183CC9F5247A488A2544077AF19020815D2278@SZXEMA503-MBS.china.huawei.com
State New
Headers show

Commit Message

Gonglei (Arei) Feb. 28, 2014, 4:08 a.m. UTC
Add counters to log the times of updating the dirty bitmap.

Signed-off-by: ChenLiang <chenliang88@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 arch_init.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Dr. David Alan Gilbert Feb. 28, 2014, 9:37 a.m. UTC | #1
* Gonglei (Arei) (arei.gonglei@huawei.com) wrote:
> Add counters to log the times of updating the dirty bitmap.

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> Signed-off-by: ChenLiang <chenliang88@huawei.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
>  arch_init.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/arch_init.c b/arch_init.c
> index bc8d0eb..6823c5a 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -110,6 +110,23 @@ static bool mig_throttle_on;
>  static int dirty_rate_high_cnt;
>  static void check_guest_throttling(void);
>  
> +static uint64_t bitmap_sync_cnt;
> +/* the functions *_bitmap_sync_cnt only run in migrate thread */
> +static inline void reset_bitmap_sync_cnt(void)
> +{
> +    bitmap_sync_cnt = 0;
> +}
> +
> +static inline void increase_bitmap_sync_cnt(void)
> +{
> +    bitmap_sync_cnt++;
> +}
> +
> +static inline uint64_t get_bitmap_sync_cnt(void)
> +{
> +    return bitmap_sync_cnt;
> +}
> +
>  /***********************************************************/
>  /* ram save/restore */
>  
> @@ -450,6 +467,8 @@ static void migration_bitmap_sync(void)
>      int64_t end_time;
>      int64_t bytes_xfer_now;
>  
> +    increase_bitmap_sync_cnt();
> +
>      if (!bytes_xfer_prev) {
>          bytes_xfer_prev = ram_bytes_transferred();
>      }
> @@ -692,6 +711,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
>      migration_dirty_pages = ram_pages;
>      mig_throttle_on = false;
>      dirty_rate_high_cnt = 0;
> +    reset_bitmap_sync_cnt();
>  
>      if (migrate_use_xbzrle()) {
>          XBZRLE.cache = cache_init(migrate_xbzrle_cache_size() /
> -- 
> 1.7.12.4
> 
> 
> Best regards,
> -Gonglei
> 
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Eric Blake Feb. 28, 2014, 1:11 p.m. UTC | #2
On 02/27/2014 09:08 PM, Gonglei (Arei) wrote:
> Add counters to log the times of updating the dirty bitmap.
> 
> Signed-off-by: ChenLiang <chenliang88@huawei.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
>  arch_init.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)

Is it also worth updating MigrationStats in qapi-schema.json to expose
these counts to the end user, to help benchmarking decide how often your
optimizations hit for a given workload?
陈梁 Feb. 28, 2014, 1:26 p.m. UTC | #3
> On 02/27/2014 09:08 PM, Gonglei (Arei) wrote:
>> Add counters to log the times of updating the dirty bitmap.
>> 
>> Signed-off-by: ChenLiang <chenliang88@huawei.com>
>> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
>> ---
>> arch_init.c | 20 ++++++++++++++++++++
>> 1 file changed, 20 insertions(+)
> 
> Is it also worth updating MigrationStats in qapi-schema.json to expose
> these counts to the end user, to help benchmarking decide how often your
> optimizations hit for a given workload?
> 
> 
> -- 
> Eric Blake   eblake redhat com    +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
> 
good idea,  I will think about it.
Juan Quintela March 5, 2014, 4:18 p.m. UTC | #4
"Gonglei (Arei)" <arei.gonglei@huawei.com> wrote:
> Add counters to log the times of updating the dirty bitmap.
>
> Signed-off-by: ChenLiang <chenliang88@huawei.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>

As told by Eric, I am with this change, but can we move the code to the
same place that the rest of the statistics?

Thanks, Juan.
Gonglei (Arei) March 6, 2014, 10:50 a.m. UTC | #5
On 2014/3/6 0:18, Juan Quintela wrote:

> "Gonglei (Arei)" <arei.gonglei@huawei.com> wrote:
>> Add counters to log the times of updating the dirty bitmap.
>>
>> Signed-off-by: ChenLiang <chenliang88@huawei.com>
>> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> 
> As told by Eric, I am with this change, but can we move the code to the
> same place that the rest of the statistics?
> 
> Thanks, Juan.

OK, I'm pleasure to do it. What's your plan?

Best regards,
-Gonglei
Juan Quintela March 6, 2014, 1:19 p.m. UTC | #6
Gonglei <arei.gonglei@huawei.com> wrote:
> On 2014/3/6 0:18, Juan Quintela wrote:
>
>> "Gonglei (Arei)" <arei.gonglei@huawei.com> wrote:
>>> Add counters to log the times of updating the dirty bitmap.
>>>
>>> Signed-off-by: ChenLiang <chenliang88@huawei.com>
>>> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
>> 
>> As told by Eric, I am with this change, but can we move the code to the
>> same place that the rest of the statistics?
>> 
>> Thanks, Juan.
>
> OK, I'm pleasure to do it. What's your plan?

Instead of a local variable, look at includemigration/state/migration.h

inside MigrationState there are variables like setup_time.

You can add your variable there.  Interesting bits is that you need to
add it also to:

qapi-schema.json: MigrationInfo (looks for @setup-time),
qmp-commands.hx: look for setup-time
hmp.c: look again for setup_time
migration.c: look for setup_time inside qemu_qeery_migrate()

That are the places to add something to migration stats and that appears
everywhere.

Thanks, Juan.
diff mbox

Patch

diff --git a/arch_init.c b/arch_init.c
index bc8d0eb..6823c5a 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -110,6 +110,23 @@  static bool mig_throttle_on;
 static int dirty_rate_high_cnt;
 static void check_guest_throttling(void);
 
+static uint64_t bitmap_sync_cnt;
+/* the functions *_bitmap_sync_cnt only run in migrate thread */
+static inline void reset_bitmap_sync_cnt(void)
+{
+    bitmap_sync_cnt = 0;
+}
+
+static inline void increase_bitmap_sync_cnt(void)
+{
+    bitmap_sync_cnt++;
+}
+
+static inline uint64_t get_bitmap_sync_cnt(void)
+{
+    return bitmap_sync_cnt;
+}
+
 /***********************************************************/
 /* ram save/restore */
 
@@ -450,6 +467,8 @@  static void migration_bitmap_sync(void)
     int64_t end_time;
     int64_t bytes_xfer_now;
 
+    increase_bitmap_sync_cnt();
+
     if (!bytes_xfer_prev) {
         bytes_xfer_prev = ram_bytes_transferred();
     }
@@ -692,6 +711,7 @@  static int ram_save_setup(QEMUFile *f, void *opaque)
     migration_dirty_pages = ram_pages;
     mig_throttle_on = false;
     dirty_rate_high_cnt = 0;
+    reset_bitmap_sync_cnt();
 
     if (migrate_use_xbzrle()) {
         XBZRLE.cache = cache_init(migrate_xbzrle_cache_size() /