diff mbox series

[v1,5/8] migration: Export dirty-limit time info

Message ID 5ca0b4ae2aa787c1547d798521ab0e67867437a8.1662052189.git.huangy81@chinatelecom.cn
State New
Headers show
Series migration: introduce dirtylimit capability | expand

Commit Message

Hyman Huang Sept. 1, 2022, 5:22 p.m. UTC
From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>

Export dirty limit throttle time and estimated ring full
time, through which we can observe the process of dirty
limit during live migration.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
---
 include/sysemu/dirtylimit.h |  2 ++
 migration/migration.c       | 10 ++++++++++
 monitor/hmp-cmds.c          | 10 ++++++++++
 qapi/migration.json         | 10 +++++++++-
 softmmu/dirtylimit.c        | 22 ++++++++++++++++++++++
 5 files changed, 53 insertions(+), 1 deletion(-)

Comments

Markus Armbruster Oct. 1, 2022, 6:31 p.m. UTC | #1
huangy81@chinatelecom.cn writes:

> From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
>
> Export dirty limit throttle time and estimated ring full
> time, through which we can observe the process of dirty
> limit during live migration.
>
> Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>

[...]

> diff --git a/qapi/migration.json b/qapi/migration.json
> index bc4bc96..c263d54 100644
> --- a/qapi/migration.json
> +++ b/qapi/migration.json
> @@ -242,6 +242,12 @@
>  #                   Present and non-empty when migration is blocked.
>  #                   (since 6.0)
>  #
> +# @dirty-limit-throttle-us-per-full: Throttle time (us) during the period of
> +#                                    dirty ring full (since 7.0)
> +#
> +# @dirty-limit-us-ring-full: Estimated periodic time (us) of dirty ring full.
> +#                            (since 7.0)
> +#

Can you explain what is measured here a bit more verbosely?

>  # Since: 0.14
>  ##
>  { 'struct': 'MigrationInfo',
> @@ -259,7 +265,9 @@
>             '*postcopy-blocktime' : 'uint32',
>             '*postcopy-vcpu-blocktime': ['uint32'],
>             '*compression': 'CompressionStats',
> -           '*socket-address': ['SocketAddress'] } }
> +           '*socket-address': ['SocketAddress'],
> +           '*dirty-limit-throttle-us-per-full': 'int64',
> +           '*dirty-limit-us-ring-full': 'int64'} }
>  
>  ##
>  # @query-migrate:

[...]
Hyman Huang Oct. 2, 2022, 1:13 a.m. UTC | #2
在 2022/10/2 2:31, Markus Armbruster 写道:
> huangy81@chinatelecom.cn writes:
> 
>> From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
>>
>> Export dirty limit throttle time and estimated ring full
>> time, through which we can observe the process of dirty
>> limit during live migration.
>>
>> Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
> 
> [...]
> 
>> diff --git a/qapi/migration.json b/qapi/migration.json
>> index bc4bc96..c263d54 100644
>> --- a/qapi/migration.json
>> +++ b/qapi/migration.json
>> @@ -242,6 +242,12 @@
>>   #                   Present and non-empty when migration is blocked.
>>   #                   (since 6.0)
>>   #
>> +# @dirty-limit-throttle-us-per-full: Throttle time (us) during the period of
>> +#                                    dirty ring full (since 7.0)
>> +#
>> +# @dirty-limit-us-ring-full: Estimated periodic time (us) of dirty ring full.
>> +#                            (since 7.0)
>> +#
> 
> Can you explain what is measured here a bit more verbosely?
The two fields of migration info aims to export dirty-limit throttle 
time so that upper apps can check out the process of live migration, 
like 'cpu-throttle-percentage'.

The commit "tests: Add migration dirty-limit capability test" make use 
of the 'dirty-limit-throttle-us-per-full' to checkout if dirty-limit has 
started, the commit "tests/migration: Introduce dirty-limit into 
guestperf" introduce the two field so guestperf tools also show the 
process of dirty-limit migration.

And i also use qmp_query_migrate to observe the migration by checkout 
these two fields.

I'm not sure if above explantation is what you want exactly, please be 
free to start any discussion about this features.

Thank Markus.

Yong
> 
>>   # Since: 0.14
>>   ##
>>   { 'struct': 'MigrationInfo',
>> @@ -259,7 +265,9 @@
>>              '*postcopy-blocktime' : 'uint32',
>>              '*postcopy-vcpu-blocktime': ['uint32'],
>>              '*compression': 'CompressionStats',
>> -           '*socket-address': ['SocketAddress'] } }
>> +           '*socket-address': ['SocketAddress'],
>> +           '*dirty-limit-throttle-us-per-full': 'int64',
>> +           '*dirty-limit-us-ring-full': 'int64'} }
>>   
>>   ##
>>   # @query-migrate:
> 
> [...]
>
Markus Armbruster Oct. 7, 2022, 3:09 p.m. UTC | #3
Hyman Huang <huangy81@chinatelecom.cn> writes:

> 在 2022/10/2 2:31, Markus Armbruster 写道:
>> huangy81@chinatelecom.cn writes:
>> 
>>> From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
>>>
>>> Export dirty limit throttle time and estimated ring full
>>> time, through which we can observe the process of dirty
>>> limit during live migration.
>>>
>>> Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
>> [...]
>> 
>>> diff --git a/qapi/migration.json b/qapi/migration.json
>>> index bc4bc96..c263d54 100644
>>> --- a/qapi/migration.json
>>> +++ b/qapi/migration.json
>>> @@ -242,6 +242,12 @@
>>>   #                   Present and non-empty when migration is blocked.
>>>   #                   (since 6.0)
>>>   #
>>> +# @dirty-limit-throttle-us-per-full: Throttle time (us) during the period of
>>> +#                                    dirty ring full (since 7.0)
>>> +#
>>> +# @dirty-limit-us-ring-full: Estimated periodic time (us) of dirty ring full.
>>> +#                            (since 7.0)
>>> +#
>>
>> Can you explain what is measured here a bit more verbosely?
>
> The two fields of migration info aims to export dirty-limit throttle time so that upper apps can check out the process of live migration, 
> like 'cpu-throttle-percentage'.
>
> The commit "tests: Add migration dirty-limit capability test" make use of the 'dirty-limit-throttle-us-per-full' to checkout if dirty-limit has 
> started, the commit "tests/migration: Introduce dirty-limit into guestperf" introduce the two field so guestperf tools also show the 
> process of dirty-limit migration.
>
> And i also use qmp_query_migrate to observe the migration by checkout these two fields.
>
> I'm not sure if above explantation is what you want exactly, please be free to start any discussion about this features.

You explained use cases, which is always welcome.

I'm trying to understand the two new members' meaning, i.e. what exactly
is being measured.

For existing @cpu-throttle-percentage, the doc comment tells me:
"percentage of time guest cpus are being throttled during
auto-converge."

For the your new members, the doc comment tries to tell me, but it
doesn't succeed.  If you explain what is being measured more verbosely,
we may be able to improve the doc comment.
Hyman Huang Oct. 7, 2022, 4:22 p.m. UTC | #4
在 2022/10/7 23:09, Markus Armbruster 写道:
> Hyman Huang <huangy81@chinatelecom.cn> writes:
> 
>> 在 2022/10/2 2:31, Markus Armbruster 写道:
>>> huangy81@chinatelecom.cn writes:
>>>
>>>> From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
>>>>
>>>> Export dirty limit throttle time and estimated ring full
>>>> time, through which we can observe the process of dirty
>>>> limit during live migration.
>>>>
>>>> Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
>>> [...]
>>>
>>>> diff --git a/qapi/migration.json b/qapi/migration.json
>>>> index bc4bc96..c263d54 100644
>>>> --- a/qapi/migration.json
>>>> +++ b/qapi/migration.json
>>>> @@ -242,6 +242,12 @@
>>>>    #                   Present and non-empty when migration is blocked.
>>>>    #                   (since 6.0)
>>>>    #
>>>> +# @dirty-limit-throttle-us-per-full: Throttle time (us) during the period of
>>>> +#                                    dirty ring full (since 7.0)
>>>> +#
>>>> +# @dirty-limit-us-ring-full: Estimated periodic time (us) of dirty ring full.
>>>> +#                            (since 7.0)
>>>> +#
>>>
>>> Can you explain what is measured here a bit more verbosely?
>>
>> The two fields of migration info aims to export dirty-limit throttle time so that upper apps can check out the process of live migration,
>> like 'cpu-throttle-percentage'.
>>
>> The commit "tests: Add migration dirty-limit capability test" make use of the 'dirty-limit-throttle-us-per-full' to checkout if dirty-limit has
>> started, the commit "tests/migration: Introduce dirty-limit into guestperf" introduce the two field so guestperf tools also show the
>> process of dirty-limit migration.
>>
>> And i also use qmp_query_migrate to observe the migration by checkout these two fields.
>>
>> I'm not sure if above explantation is what you want exactly, please be free to start any discussion about this features.
> 
> You explained use cases, which is always welcome.
> 
> I'm trying to understand the two new members' meaning, i.e. what exactly
> is being measured.

dirty-limit-throttle-us-per-full:
Means the time vCPU should sleep once it's dirty ring get full, since we 
set limit on vCPU every time it returns to Qemu for the 
KVM_EXIT_DIRTY_RING_FULL reason, the sleep time may also changes everty 
time dirty ring get full. 'dirty-limit-throttle-us-per-full' can be 
simplified as 'throttle time(us) every time vCPU's dirty ring full get 
full'. The 'dirty-limit' is just the prefix to mark that parameter is 
dirty-limit-related.

dirty-limit-us-ring-full:
It is an estimated value which means the time a vCPU's dirty ring get 
full. It depends on the vCPU's dirty page rate, the higher the rate is, 
the smaller dirty-limit-us-ring-full is.

dirty-limit-throttle-us-per-full / dirty-limit-us-ring-full * 100 is 
kind of like 'cpu-throttle-percentage'.

Thanks,

Yong

> 
> For existing @cpu-throttle-percentage, the doc comment tells me:
> "percentage of time guest cpus are being throttled during
> auto-converge."
> 
> For the your new members, the doc comment tries to tell me, but it
> doesn't succeed.  If you explain what is being measured more verbosely,
> we may be able to improve the doc comment.
>
diff mbox series

Patch

diff --git a/include/sysemu/dirtylimit.h b/include/sysemu/dirtylimit.h
index 8d2c1f3..98cc4a6 100644
--- a/include/sysemu/dirtylimit.h
+++ b/include/sysemu/dirtylimit.h
@@ -34,4 +34,6 @@  void dirtylimit_set_vcpu(int cpu_index,
 void dirtylimit_set_all(uint64_t quota,
                         bool enable);
 void dirtylimit_vcpu_execute(CPUState *cpu);
+int64_t dirtylimit_throttle_us_per_full(void);
+int64_t dirtylimit_us_ring_full(void);
 #endif
diff --git a/migration/migration.c b/migration/migration.c
index 64696de..22ba197 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -61,6 +61,7 @@ 
 #include "sysemu/cpus.h"
 #include "yank_functions.h"
 #include "sysemu/qtest.h"
+#include "sysemu/dirtylimit.h"
 
 #define MAX_THROTTLE  (128 << 20)      /* Migration transfer speed throttling */
 
@@ -1110,6 +1111,15 @@  static void populate_ram_info(MigrationInfo *info, MigrationState *s)
         info->ram->remaining = ram_bytes_remaining();
         info->ram->dirty_pages_rate = ram_counters.dirty_pages_rate;
     }
+
+    if (migrate_dirty_limit() && dirtylimit_in_service()) {
+        info->has_dirty_limit_throttle_us_per_full = true;
+        info->dirty_limit_throttle_us_per_full =
+                            dirtylimit_throttle_us_per_full();
+
+        info->has_dirty_limit_us_ring_full = true;
+        info->dirty_limit_us_ring_full = dirtylimit_us_ring_full();
+    }
 }
 
 static void populate_disk_info(MigrationInfo *info)
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index b362fae..23c3f48 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -358,6 +358,16 @@  void hmp_info_migrate(Monitor *mon, const QDict *qdict)
                        info->cpu_throttle_percentage);
     }
 
+    if (info->has_dirty_limit_throttle_us_per_full) {
+        monitor_printf(mon, "dirty-limit throttle time: %" PRIu64 " us\n",
+                       info->dirty_limit_throttle_us_per_full);
+    }
+
+    if (info->has_dirty_limit_us_ring_full) {
+        monitor_printf(mon, "dirty-limit ring full time: %" PRIu64 " us\n",
+                       info->dirty_limit_us_ring_full);
+    }
+
     if (info->has_postcopy_blocktime) {
         monitor_printf(mon, "postcopy blocktime: %u\n",
                        info->postcopy_blocktime);
diff --git a/qapi/migration.json b/qapi/migration.json
index bc4bc96..c263d54 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -242,6 +242,12 @@ 
 #                   Present and non-empty when migration is blocked.
 #                   (since 6.0)
 #
+# @dirty-limit-throttle-us-per-full: Throttle time (us) during the period of
+#                                    dirty ring full (since 7.0)
+#
+# @dirty-limit-us-ring-full: Estimated periodic time (us) of dirty ring full.
+#                            (since 7.0)
+#
 # Since: 0.14
 ##
 { 'struct': 'MigrationInfo',
@@ -259,7 +265,9 @@ 
            '*postcopy-blocktime' : 'uint32',
            '*postcopy-vcpu-blocktime': ['uint32'],
            '*compression': 'CompressionStats',
-           '*socket-address': ['SocketAddress'] } }
+           '*socket-address': ['SocketAddress'],
+           '*dirty-limit-throttle-us-per-full': 'int64',
+           '*dirty-limit-us-ring-full': 'int64'} }
 
 ##
 # @query-migrate:
diff --git a/softmmu/dirtylimit.c b/softmmu/dirtylimit.c
index 1fdd8c6..1251b27 100644
--- a/softmmu/dirtylimit.c
+++ b/softmmu/dirtylimit.c
@@ -546,6 +546,28 @@  static struct DirtyLimitInfo *dirtylimit_query_vcpu(int cpu_index)
     return info;
 }
 
+/* Pick up first vcpu throttle time by default */
+int64_t dirtylimit_throttle_us_per_full(void)
+{
+    CPUState *cpu = first_cpu;
+    return cpu->throttle_us_per_full;
+}
+
+/*
+ * Estimate dirty ring full time under current dirty page rate.
+ * Return -1 if guest doesn't dirty memory.
+ */
+int64_t dirtylimit_us_ring_full(void)
+{
+    uint64_t curr_rate = vcpu_dirty_rate_get(0);
+
+    if (!curr_rate) {
+        return -1;
+    }
+
+    return dirtylimit_dirty_ring_full_time(curr_rate);
+}
+
 static struct DirtyLimitInfoList *dirtylimit_query_all(void)
 {
     int i, index;