Add a new migrate_set_max_cpu_throttle qmp command
cover Add a new migrate_set_max_cpu_throttle qmp command
Currently, the default maximum CPU throttle for migration is 99(CPU_THROTTLE_PCT_MAX). This is too big and can make a remarkable performance effect for the guest. We see a lot of packets latency exceed 500ms when the CPU_THROTTLE_PCT_MAX reached. This patch set adds a new qmp command to limit the CPU throttle.
Li Qiang (3):
migrate: replace the cpu throttle percentage max with a variable
migration: Add qmp command for migrate_set_max_cpu_throttle
hmp: add hmp for migrate_set_max_cpu_throttle
cpus.c | 9 ++++++++- hmp-commands.hx | 14 ++++++++++++++ hmp.c | 6 ++++++ hmp.h | 1 + include/qom/cpu.h | 8 ++++++++ migration/migration.c | 10 ++++++++++ qapi/migration.json | 13 +++++++++++++ 7 files changed, 60 insertions(+), 1 deletion(-)
Signature · 1 line
2.11.0
PATCH 1/3 migrate: replace the cpu throttle percentage max with a variable
So we can config it using qmp.
--- cpus.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
cpus.c +3 -1
@@ -83,6 +83,8 @@ static unsigned int throttle_percentage;#define CPU_THROTTLE_PCT_MAX 99#define CPU_THROTTLE_TIMESLICE_NS 10000000 +static unsigned int throttle_percentage_max =CPU_THROTTLE_PCT_MAX ; +bool cpu_is_stopped (CPUState *cpu) {return cpu->stopped || !runstate_is_running ();
@@ -754,7 +756,7 @@ static void cpu_throttle_timer_tick(void *opaque)void cpu_throttle_set (int new_throttle_pct) {/* Ensure throttle percentage is within valid range */ - new_throttle_pct =MIN (new_throttle_pct,CPU_THROTTLE_PCT_MAX ); + new_throttle_pct =MIN (new_throttle_pct, throttle_percentage_max); new_throttle_pct =MAX (new_throttle_pct,CPU_THROTTLE_PCT_MIN );atomic_set (&throttle_percentage, new_throttle_pct);
Signature · 1 line
2.11.0
PATCH 2/3 migration: Add qmp command for migrate_set_max_cpu_throttle
In reply to Li QiangThe default max cpu throttle is 99, this is too big that may influence the guest loads. Add a qmp to config it can make it more flexible.
--- cpus.c | 5 +++++ include/qom/cpu.h | 8 ++++++++ migration/migration.c | 10 ++++++++++ qapi/migration.json | 13 +++++++++++++ 4 files changed, 36 insertions(+)
cpus.c +5 -0
@@ -765,6 +765,11 @@ void cpu_throttle_set(int new_throttle_pct) CPU_THROTTLE_TIMESLICE_NS); } +void set_cpu_max_throttle (int64_t max_pct) +{ + throttle_percentage_max = max_pct; +} +void cpu_throttle_stop (void ) {atomic_set (&throttle_percentage,0 );
include/qom/cpu.h +8 -0
@@ -816,6 +816,14 @@ CPUState *cpu_by_arch_id(int64_t id);void cpu_throttle_set (int new_throttle_pct);/** +* set_cpu_max_throttle: +* @max_pct: the max percent of sleep time. Valid range is 1 to 99. +* +* Set the max throttle percentage. +*/ +void set_cpu_max_throttle (int64_t max_pct); + +/** * cpu_throttle_stop: * * Stops the vcpu throttling started by cpu_throttle_set.
migration/migration.c +10 -0
@@ -1774,6 +1774,16 @@ void qmp_migrate_set_speed(int64_t value, Error **errp)qmp_migrate_set_parameters (&p, errp); } +void qmp_migrate_set_max_cpu_throttle (int64_t value,Error **errp) +{ +if (value >99 || value <1 ) { +error_setg (errp,QERR_INVALID_PARAMETER_VALUE ," max cpu throttle" , +"not in 1 between 99" ); +return ; + } +set_cpu_max_throttle (value); +} +void qmp_migrate_set_downtime (double value,Error **errp) {if (value <0 || value >MAX_MIGRATE_DOWNTIME_SECONDS ) {
qapi/migration.json +13 -0
@@ -997,6 +997,19 @@ { 'command': 'migrate_set_speed', 'data': {'value': 'int'} } ## +# @migrate_set_max_cpu_throttle: +# +# Set maximum cpu throttle for migration. +# +# @value: maximum cpu throttle. +# +# Returns: nothing on success +# +# Since: 2.12 +## +{ 'command': 'migrate_set_max_cpu_throttle', 'data': {'value': 'int'} } + +## # @migrate-set-cache-size: # # Set cache size to be used by XBZRLE migration
Signature · 1 line
2.11.0
PATCH 3/3 hmp: add hmp for migrate_set_max_cpu_throttle
In reply to Li Qiang--- hmp-commands.hx | 14 ++++++++++++++ hmp.c | 6 ++++++ hmp.h | 1 + 3 files changed, 21 insertions(+)
hmp-commands.hx +14 -0
@@ -1042,6 +1042,20 @@ Set maximum speed to @var{value} (in bytes) for migrations. ETEXI { + .name = "migrate_set_max_cpu_throttle", + .args_type = "value:i", + .params = "value", + .help = "set maximum cpu throttle for migrations.", + .cmd = hmp_migrate_set_max_cpu_throttle, + }, + +STEXI +@item hmp_migrate_set_max_cpu_throttle @var{value} +@findex migrate_set_max_cpu_throttle +Set maximum cpu throttle to @var{value} for migrations. +ETEXI + + { .name = "migrate_set_downtime", .args_type = "value:T", .params = "value",
hmp.c +6 -0
@@ -1574,6 +1574,12 @@ void hmp_migrate_set_speed(Monitor *mon, const QDict *qdict)qmp_migrate_set_speed (value,NULL ); } +void hmp_migrate_set_max_cpu_throttle (Monitor *mon,const QDict *qdict) +{ +int64_t value =qdict_get_int (qdict,"value" ); +qmp_migrate_set_max_cpu_throttle (value,NULL ); +} +void hmp_migrate_set_capability (Monitor *mon,const QDict *qdict) {const char *cap =qdict_get_str (qdict,"capability" );
hmp.h +1 -0
@@ -73,6 +73,7 @@ void hmp_migrate_recover(Monitor *mon, const QDict *qdict);void hmp_migrate_pause (Monitor *mon,const QDict *qdict);void hmp_migrate_set_downtime (Monitor *mon,const QDict *qdict);void hmp_migrate_set_speed (Monitor *mon,const QDict *qdict); +void hmp_migrate_set_max_cpu_throttle (Monitor *mon,const QDict *qdict);void hmp_migrate_set_capability (Monitor *mon,const QDict *qdict);void hmp_migrate_set_parameter (Monitor *mon,const QDict *qdict);void hmp_migrate_set_cache_size (Monitor *mon,const QDict *qdict);
Signature · 1 line
2.11.0
Re: [Qemu-devel] [PATCH 2/3] migration: Add qmp command for migrate_set_max_cpu_throttle
In reply to Li QiangQuoted 5 lines · * Li Qiang ([email protected]) wrote:
The default max cpu throttle is 99, this is too big that may influence the guest loads. Add a qmp to config it can make it more flexible.
Signed-off-by Li Qiang <[email protected]>
This should be done as a migration parameter rather than a new command. For example, follow the cpu-throttle-increment parameter; and this should work just like it.
Dave
Quoted 90 lines
--- cpus.c | 5 +++++ include/qom/cpu.h | 8 ++++++++ migration/migration.c | 10 ++++++++++ qapi/migration.json | 13 +++++++++++++ 4 files changed, 36 insertions(+)cpus.c +5
-0@@ -765,6 +765,11 @@ void cpu_throttle_set(int new_throttle_pct) CPU_THROTTLE_TIMESLICE_NS); } +void set_cpu_max_throttle (int64_t max_pct) +{ + throttle_percentage_max = max_pct; +} +void cpu_throttle_stop (void ) {atomic_set (&throttle_percentage,0 );include/qom/cpu.h +8
-0@@ -816,6 +816,14 @@ CPUState *cpu_by_arch_id(int64_t id);void cpu_throttle_set (int new_throttle_pct);/** +* set_cpu_max_throttle: +* @max_pct: the max percent of sleep time. Valid range is 1 to 99. +* +* Set the max throttle percentage. +*/ +void set_cpu_max_throttle (int64_t max_pct); + +/** * cpu_throttle_stop: * * Stops the vcpu throttling started by cpu_throttle_set. migration/migration.c +10
-0@@ -1774,6 +1774,16 @@ void qmp_migrate_set_speed(int64_t value, Error **errp)qmp_migrate_set_parameters (&p, errp); } +void qmp_migrate_set_max_cpu_throttle (int64_t value,Error **errp) +{ +if (value >99 || value <1 ) { +error_setg (errp,QERR_INVALID_PARAMETER_VALUE ," max cpu throttle" , +"not in 1 between 99" ); +return ; + } +set_cpu_max_throttle (value); +} +void qmp_migrate_set_downtime (double value,Error **errp) {if (value <0 || value >MAX_MIGRATE_DOWNTIME_SECONDS ) {qapi/migration.json +13
-0@@ -997,6 +997,19 @@ { 'command': 'migrate_set_speed', 'data': {'value': 'int'} } ## +# @migrate_set_max_cpu_throttle: +# +# Set maximum cpu throttle for migration. +# +# @value: maximum cpu throttle. +# +# Returns: nothing on success +# +# Since: 2.12 +## +{ 'command': 'migrate_set_max_cpu_throttle', 'data': {'value': 'int'} } + +## # @migrate-set-cache-size: # # Set cache size to be used by XBZRLE migrationSignature · 1 line
2.11.0
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH 2/3] migration: Add qmp command for migrate_set_max_cpu_throttle
Quoted 10 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Li Qiang ([email protected]) wrote:
The default max cpu throttle is 99, this is too big that may influence the guest loads. Add a qmp to config it can make it more flexible.
Signed-off-by Li Qiang <[email protected]>This should be done as a migration parameter rather than a new command. For example, follow the cpu-throttle-increment parameter; and this should work just like it.
100% agreed - extend existing commands, instead of inventing a new one. But in the future, if you do have a valid reason to add a new command...
Quoted 4 lines
Quoted 4 lines
+++
b/qapi/migration.jsonqapi/migration.json +0
-0@@ -997,6 +997,19 @@ { 'command': 'migrate_set_speed', 'data': {'value': 'int'} }
Quoted 10 lines
qapi/migration.json line 1008
Quoted 10 lines
qapi/migration.json +9
-0## +# @migrate_set_max_cpu_throttle: +# +# Set maximum cpu throttle for migration. +# +# @value: maximum cpu throttle. +# +# Returns: nothing on success +# +# Since: 2.12
You've missed 2.12 by a long shot; you've also missed freeze for 3.0. The earliest you can introduce this is 3.1 (which does need to be documented even if you properly add this as a new parameter to the existing migration parameter commands).
Quoted 2 lines
qapi/migration.json line 1010
Quoted 2 lines
qapi/migration.json +2
-0+## +{ 'command': 'migrate_set_max_cpu_throttle', 'data': {'value': 'int'} }
...new commands should favor '-' rather than '_' for separation between words. And your documentation should mention which unit the throttle is in (bytes per second?)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH 2/3] migration: Add qmp command for migrate_set_max_cpu_throttle
In reply to Dr. David Alan GilbertQuoted 10 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Li Qiang ([email protected]) wrote:
The default max cpu throttle is 99, this is too big that may influence the guest loads. Add a qmp to config it can make it more flexible.
Signed-off-by Li Qiang <[email protected]>This should be done as a migration parameter rather than a new command. For example, follow the cpu-throttle-increment parameter; and this should work just like it.
I was about to comment this one.
migrate_set_downtime, migrate_set_speed, migrate-set-cache-size, query-migrate-cache-size are marked as deprecated. Any way that we could have make more clear that one should use migrate_set/get_parameter/capability?
Thanks, Juan.
Re: [Qemu-devel] [PATCH 2/3] migration: Add qmp command for migrate_set_max_cpu_throttle
Quoted 12 lines · * Juan Quintela ([email protected]) wrote:
Quoted 10 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Li Qiang ([email protected]) wrote:
The default max cpu throttle is 99, this is too big that may influence the guest loads. Add a qmp to config it can make it more flexible.
Signed-off-by Li Qiang <[email protected]>This should be done as a migration parameter rather than a new command. For example, follow the cpu-throttle-increment parameter; and this should work just like it.
Quoted 6 lines
I was about to comment this one.
migrate_set_downtime,migrate_set_speed, migrate-set-cache-size, query-migrate-cache-size are marked as deprecated. Any way that we could have make more clear that one should use migrate_set/get_parameter/capability?
A big hairy comment?
Dave
Quoted 1 line
Thanks, Juan.
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH 2/3] migration: Add qmp command for migrate_set_max_cpu_throttle
In reply to Juan QuintelaQuoted 12 lines · Juan Quintela
Quoted 10 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Li Qiang ([email protected]) wrote:
The default max cpu throttle is 99, this is too big that may influence the guest loads. Add a qmp to config it can make it more flexible.
Signed-off-by Li Qiang <[email protected]>This should be done as a migration parameter rather than a new command. For example, follow the cpu-throttle-increment parameter; and this should work just like it.
Quoted 6 lines
I was about to comment this one.
migrate_set_downtime,migrate_set_speed, migrate-set-cache-size, query-migrate-cache-size are marked as deprecated. Any way that we could have make more clear that one should use migrate_set/get_parameter/capability?
Where are they marked as deprecated ?
They're not included in our official list of deprecated features, so per our deprecation policy, they are still considered supported.
https://qemu.weilnetz.de/doc/qemu-doc.html#Deprecated-features
To deprecate something it needs to be added to qemu-deprecated.texi, and ideally also made to print a message to stderr when triggered.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [Qemu-devel] [PATCH 2/3] migration: Add qmp command for migrate_set_max_cpu_throttle
2018-07-31 23:50 GMT+08:00 Daniel P. Berrangé <[email protected]>:
Quoted 7 lines · Juan Quintela
Quoted 6 lines
Quoted 5 lines · Dr. David Alan Gilbert
Quoted 4 lines · * Li Qiang ([email protected]) wrote:
The default max cpu throttle is 99, this is too big that may influence the guest loads. Add a qmp to config it can make it more flexible.
Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Li Qiang <[email protected]>This should be done as a migration parameter rather than a new command. For example, follow the cpu-throttle-increment parameter; and this should work just like it.
Hello all,
Thanks for your review. I will prepare another migration parameter version patch set
for this.
Thanks,
Li Qiang
Quoted 9 lines
I was about to comment this one.
Quoted 5 lines
migrate_set_downtime,migrate_set_speed, migrate-set-cache-size, query-migrate-cache-size are marked as deprecated. Any way that we could have make more clear that one should use migrate_set/get_parameter/capability?Where are they marked as deprecated ?
They're not included in our official list of deprecated features, so per
Quoted 9 lines
our deprecation policy, they are still considered supported.
https://qemu.weilnetz.de/doc/qemu-doc.html#Deprecated-features
To deprecate something it needs to be added to qemu-deprecated.texi, and ideally also made to print a message to stderr when triggered.
Regards,
Quoted 9 lines
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/
dberrange :|
|: https://libvirt.org -o-
https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/
dberrange :|
Re: [Qemu-devel] [PATCH 2/3] migration: Add qmp command for migrate_set_max_cpu_throttle
In reply to Daniel P. BerrangéQuoted 13 lines · Daniel P. Berrangé
Quoted 12 lines · Juan Quintela
Quoted 10 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Li Qiang ([email protected]) wrote:
The default max cpu throttle is 99, this is too big that may influence the guest loads. Add a qmp to config it can make it more flexible.
Signed-off-by Li Qiang <[email protected]>This should be done as a migration parameter rather than a new command. For example, follow the cpu-throttle-increment parameter; and this should work just like it.
Quoted 8 lines
Quoted 6 lines
I was about to comment this one.
migrate_set_downtime,migrate_set_speed, migrate-set-cache-size, query-migrate-cache-size are marked as deprecated. Any way that we could have make more clear that one should use migrate_set/get_parameter/capability?Where are they marked as deprecated ?
##
# @migrate_set_downtime:
#
# Set maximum tolerated downtime for migration.
#
# @value: maximum downtime in seconds
#
# Returns: nothing on success
#
# Notes: This command is deprecated in favor of 'migrate-set-parameters' #
# Since: 0.14.0
#
# Example:
#
# -> { "execute": "migrate_set_downtime", "arguments": { "value": 0.1 } } # <- { "return": {} }
#
##
{ 'command': 'migrate_set_downtime', 'data': {'value': 'number'} }
Notes: field. Clearly we need to do still more work there. Will change the texi, thanks.
Quoted 8 lines
They're not included in our official list of deprecated features, so per our deprecation policy, they are still considered supported.
https://qemu.weilnetz.de/doc/qemu-doc.html#Deprecated-features
To deprecate something it needs to be added to qemu-deprecated.texi, and ideally also made to print a message to stderr when triggered.
will send a patch to add to the texi and the print to stderr, thanks.