All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] migration/dirtyrate: optimizations for showing of querying dirtyrate
@ 2020-09-29  3:42 Chuan Zheng
  2020-09-29  3:42 ` [PATCH v2 1/2] migration/dirtyrate: record start_time and calc_time while at the measuring state Chuan Zheng
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Chuan Zheng @ 2020-09-29  3:42 UTC (permalink / raw)
  To: quintela, eblake, dgilbert, berrange
  Cc: alex.chen, zhang.zhanghailiang, qemu-devel, xiexiangyou,
	david.edmondson, wanghao232

This series include two optimizations showing of dirtyrate against v1
1) show start_time and calc_time when query while at the measuring state
2) do not show dirtyrate when measuring is not finished

Chuan Zheng (2):
  migration/dirtyrate: record start_time and calc_time while at the
    measuring state
  migration/dirtyrate: present dirty rate only when querying the rate
    has completed

 migration/dirtyrate.c | 16 ++++++++++------
 qapi/migration.json   |  8 +++-----
 2 files changed, 13 insertions(+), 11 deletions(-)

-- 
1.8.3.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/2] migration/dirtyrate: record start_time and calc_time while at the measuring state
  2020-09-29  3:42 [PATCH v2 0/2] migration/dirtyrate: optimizations for showing of querying dirtyrate Chuan Zheng
@ 2020-09-29  3:42 ` Chuan Zheng
  2020-09-29 11:33   ` David Edmondson
  2020-09-29  3:42 ` [PATCH v2 2/2] migration/dirtyrate: present dirty rate only when querying the rate has completed Chuan Zheng
  2020-10-07 11:58 ` [PATCH v2 0/2] migration/dirtyrate: optimizations for showing of querying dirtyrate Dr. David Alan Gilbert
  2 siblings, 1 reply; 6+ messages in thread
From: Chuan Zheng @ 2020-09-29  3:42 UTC (permalink / raw)
  To: quintela, eblake, dgilbert, berrange
  Cc: alex.chen, zhang.zhanghailiang, qemu-devel, xiexiangyou,
	david.edmondson, wanghao232

Querying could include both the start-time and the calc-time while at the measuring
state, allowing a caller to determine when they should expect to come back looking
for a result.

Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>
---
 migration/dirtyrate.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
index 68577ef..40e41e7 100644
--- a/migration/dirtyrate.c
+++ b/migration/dirtyrate.c
@@ -83,14 +83,14 @@ static struct DirtyRateInfo *query_dirty_rate_info(void)
     return info;
 }
 
-static void reset_dirtyrate_stat(void)
+static void init_dirtyrate_stat(int64_t start_time, int64_t calc_time)
 {
     DirtyStat.total_dirty_samples = 0;
     DirtyStat.total_sample_count = 0;
     DirtyStat.total_block_mem_MB = 0;
     DirtyStat.dirty_rate = -1;
-    DirtyStat.start_time = 0;
-    DirtyStat.calc_time = 0;
+    DirtyStat.start_time = start_time;
+    DirtyStat.calc_time = calc_time;
 }
 
 static void update_dirtyrate_stat(struct RamblockDirtyInfo *info)
@@ -335,7 +335,6 @@ static void calculate_dirtyrate(struct DirtyRateConfig config)
     int64_t initial_time;
 
     rcu_register_thread();
-    reset_dirtyrate_stat();
     rcu_read_lock();
     initial_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
     if (!record_ramblock_hash_info(&block_dinfo, config, &block_count)) {
@@ -365,6 +364,8 @@ void *get_dirtyrate_thread(void *arg)
 {
     struct DirtyRateConfig config = *(struct DirtyRateConfig *)arg;
     int ret;
+    int64_t start_time;
+    int64_t calc_time;
 
     ret = dirtyrate_set_state(&CalculatingState, DIRTY_RATE_STATUS_UNSTARTED,
                               DIRTY_RATE_STATUS_MEASURING);
@@ -373,6 +374,10 @@ void *get_dirtyrate_thread(void *arg)
         return NULL;
     }
 
+    start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME) / 1000;
+    calc_time = config.sample_period_seconds;
+    init_dirtyrate_stat(start_time, calc_time);
+
     calculate_dirtyrate(config);
 
     ret = dirtyrate_set_state(&CalculatingState, DIRTY_RATE_STATUS_MEASURING,
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] migration/dirtyrate: present dirty rate only when querying the rate has completed
  2020-09-29  3:42 [PATCH v2 0/2] migration/dirtyrate: optimizations for showing of querying dirtyrate Chuan Zheng
  2020-09-29  3:42 ` [PATCH v2 1/2] migration/dirtyrate: record start_time and calc_time while at the measuring state Chuan Zheng
@ 2020-09-29  3:42 ` Chuan Zheng
  2020-09-29 12:30   ` Eric Blake
  2020-10-07 11:58 ` [PATCH v2 0/2] migration/dirtyrate: optimizations for showing of querying dirtyrate Dr. David Alan Gilbert
  2 siblings, 1 reply; 6+ messages in thread
From: Chuan Zheng @ 2020-09-29  3:42 UTC (permalink / raw)
  To: quintela, eblake, dgilbert, berrange
  Cc: alex.chen, zhang.zhanghailiang, qemu-devel, xiexiangyou,
	david.edmondson, wanghao232

Make dirty_rate field optional, present dirty rate only when querying
the rate has completed.
The qmp results is shown as follow:
@unstarted:
{"return":{"status":"unstarted","start-time":0,"calc-time":0},"id":"libvirt-12"}
@measuring:
{"return":{"status":"measuring","start-time":102931,"calc-time":1},"id":"libvirt-85"}
@measured:
{"return":{"status":"measured","dirty-rate":4,"start-time":150146,"calc-time":1},"id":"libvirt-15"}

Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>
Reviewed-by: David Edmondson <david.edmondson@oracle.com>
---
 migration/dirtyrate.c | 3 +--
 qapi/migration.json   | 8 +++-----
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
index 40e41e7..ab9e130 100644
--- a/migration/dirtyrate.c
+++ b/migration/dirtyrate.c
@@ -69,9 +69,8 @@ static struct DirtyRateInfo *query_dirty_rate_info(void)
     struct DirtyRateInfo *info = g_malloc0(sizeof(DirtyRateInfo));
 
     if (qatomic_read(&CalculatingState) == DIRTY_RATE_STATUS_MEASURED) {
+        info->has_dirty_rate = true;
         info->dirty_rate = dirty_rate;
-    } else {
-        info->dirty_rate = -1;
     }
 
     info->status = CalculatingState;
diff --git a/qapi/migration.json b/qapi/migration.json
index ce2216c..715c210 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -1743,10 +1743,8 @@
 #
 # Information about current dirty page rate of vm.
 #
-# @dirty-rate: @dirtyrate describing the dirty page rate of vm
-#          in units of MB/s.
-#          If this field returns '-1', it means querying has not
-#          yet started or completed.
+# @dirty-rate: an estimate of the dirty page rate of the VM in units of
+#              MB/s, present only when estimating the rate has completed.
 #
 # @status: status containing dirtyrate query status includes
 #          'unstarted' or 'measuring' or 'measured'
@@ -1759,7 +1757,7 @@
 #
 ##
 { 'struct': 'DirtyRateInfo',
-  'data': {'dirty-rate': 'int64',
+  'data': {'*dirty-rate': 'int64',
            'status': 'DirtyRateStatus',
            'start-time': 'int64',
            'calc-time': 'int64'} }
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] migration/dirtyrate: record start_time and calc_time while at the measuring state
  2020-09-29  3:42 ` [PATCH v2 1/2] migration/dirtyrate: record start_time and calc_time while at the measuring state Chuan Zheng
@ 2020-09-29 11:33   ` David Edmondson
  0 siblings, 0 replies; 6+ messages in thread
From: David Edmondson @ 2020-09-29 11:33 UTC (permalink / raw)
  To: Chuan Zheng, quintela, eblake, dgilbert, berrange
  Cc: alex.chen, wanghao232, zhang.zhanghailiang, xiexiangyou, qemu-devel

On Tuesday, 2020-09-29 at 11:42:17 +08, Chuan Zheng wrote:

> Querying could include both the start-time and the calc-time while at the measuring
> state, allowing a caller to determine when they should expect to come back looking
> for a result.
>
> Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>

Reviewed-by: David Edmondson <david.edmondson@oracle.com>

> ---
>  migration/dirtyrate.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
> index 68577ef..40e41e7 100644
> --- a/migration/dirtyrate.c
> +++ b/migration/dirtyrate.c
> @@ -83,14 +83,14 @@ static struct DirtyRateInfo *query_dirty_rate_info(void)
>      return info;
>  }
>  
> -static void reset_dirtyrate_stat(void)
> +static void init_dirtyrate_stat(int64_t start_time, int64_t calc_time)
>  {
>      DirtyStat.total_dirty_samples = 0;
>      DirtyStat.total_sample_count = 0;
>      DirtyStat.total_block_mem_MB = 0;
>      DirtyStat.dirty_rate = -1;
> -    DirtyStat.start_time = 0;
> -    DirtyStat.calc_time = 0;
> +    DirtyStat.start_time = start_time;
> +    DirtyStat.calc_time = calc_time;
>  }
>  
>  static void update_dirtyrate_stat(struct RamblockDirtyInfo *info)
> @@ -335,7 +335,6 @@ static void calculate_dirtyrate(struct DirtyRateConfig config)
>      int64_t initial_time;
>  
>      rcu_register_thread();
> -    reset_dirtyrate_stat();
>      rcu_read_lock();
>      initial_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
>      if (!record_ramblock_hash_info(&block_dinfo, config, &block_count)) {
> @@ -365,6 +364,8 @@ void *get_dirtyrate_thread(void *arg)
>  {
>      struct DirtyRateConfig config = *(struct DirtyRateConfig *)arg;
>      int ret;
> +    int64_t start_time;
> +    int64_t calc_time;
>  
>      ret = dirtyrate_set_state(&CalculatingState, DIRTY_RATE_STATUS_UNSTARTED,
>                                DIRTY_RATE_STATUS_MEASURING);
> @@ -373,6 +374,10 @@ void *get_dirtyrate_thread(void *arg)
>          return NULL;
>      }
>  
> +    start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME) / 1000;
> +    calc_time = config.sample_period_seconds;
> +    init_dirtyrate_stat(start_time, calc_time);
> +
>      calculate_dirtyrate(config);
>  
>      ret = dirtyrate_set_state(&CalculatingState, DIRTY_RATE_STATUS_MEASURING,
> -- 
> 1.8.3.1

dme.
-- 
No proper time of day.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] migration/dirtyrate: present dirty rate only when querying the rate has completed
  2020-09-29  3:42 ` [PATCH v2 2/2] migration/dirtyrate: present dirty rate only when querying the rate has completed Chuan Zheng
@ 2020-09-29 12:30   ` Eric Blake
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Blake @ 2020-09-29 12:30 UTC (permalink / raw)
  To: Chuan Zheng, quintela, dgilbert, berrange
  Cc: alex.chen, zhang.zhanghailiang, qemu-devel, xiexiangyou,
	david.edmondson, wanghao232

On 9/28/20 10:42 PM, Chuan Zheng wrote:
> Make dirty_rate field optional, present dirty rate only when querying
> the rate has completed.
> The qmp results is shown as follow:
> @unstarted:
> {"return":{"status":"unstarted","start-time":0,"calc-time":0},"id":"libvirt-12"}
> @measuring:
> {"return":{"status":"measuring","start-time":102931,"calc-time":1},"id":"libvirt-85"}
> @measured:
> {"return":{"status":"measured","dirty-rate":4,"start-time":150146,"calc-time":1},"id":"libvirt-15"}

The "id":"libvirt-..." obviously come from different libvirt sessions, 
since they are in non-monotonic order.  Not a show-stopper, since it is 
only a commit comment.

> 
> Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>
> Reviewed-by: David Edmondson <david.edmondson@oracle.com>
> ---
>   migration/dirtyrate.c | 3 +--
>   qapi/migration.json   | 8 +++-----
>   2 files changed, 4 insertions(+), 7 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/2] migration/dirtyrate: optimizations for showing of querying dirtyrate
  2020-09-29  3:42 [PATCH v2 0/2] migration/dirtyrate: optimizations for showing of querying dirtyrate Chuan Zheng
  2020-09-29  3:42 ` [PATCH v2 1/2] migration/dirtyrate: record start_time and calc_time while at the measuring state Chuan Zheng
  2020-09-29  3:42 ` [PATCH v2 2/2] migration/dirtyrate: present dirty rate only when querying the rate has completed Chuan Zheng
@ 2020-10-07 11:58 ` Dr. David Alan Gilbert
  2 siblings, 0 replies; 6+ messages in thread
From: Dr. David Alan Gilbert @ 2020-10-07 11:58 UTC (permalink / raw)
  To: Chuan Zheng
  Cc: alex.chen, berrange, zhang.zhanghailiang, quintela, qemu-devel,
	xiexiangyou, david.edmondson, wanghao232

* Chuan Zheng (zhengchuan@huawei.com) wrote:
> This series include two optimizations showing of dirtyrate against v1
> 1) show start_time and calc_time when query while at the measuring state
> 2) do not show dirtyrate when measuring is not finished
> 
> Chuan Zheng (2):
>   migration/dirtyrate: record start_time and calc_time while at the
>     measuring state
>   migration/dirtyrate: present dirty rate only when querying the rate
>     has completed
> 
>  migration/dirtyrate.c | 16 ++++++++++------
>  qapi/migration.json   |  8 +++-----
>  2 files changed, 13 insertions(+), 11 deletions(-)

Queued

> -- 
> 1.8.3.1
> 
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-10-07 12:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29  3:42 [PATCH v2 0/2] migration/dirtyrate: optimizations for showing of querying dirtyrate Chuan Zheng
2020-09-29  3:42 ` [PATCH v2 1/2] migration/dirtyrate: record start_time and calc_time while at the measuring state Chuan Zheng
2020-09-29 11:33   ` David Edmondson
2020-09-29  3:42 ` [PATCH v2 2/2] migration/dirtyrate: present dirty rate only when querying the rate has completed Chuan Zheng
2020-09-29 12:30   ` Eric Blake
2020-10-07 11:58 ` [PATCH v2 0/2] migration/dirtyrate: optimizations for showing of querying dirtyrate Dr. David Alan Gilbert

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.