mirror of
https://github.com/Motorhead1991/qemu.git
synced 2026-03-04 17:14:40 -07:00
migrate/cpu-throttle: Add max-cpu-throttle migration parameter
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 max-cpu-throttle parameter to limit the CPU throttle. Signed-off-by: Li Qiang <liq3ea@gmail.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
3eb21fe9e5
commit
4cbc9c7ffd
5 changed files with 52 additions and 5 deletions
|
|
@ -71,6 +71,7 @@
|
|||
/* Define default autoconverge cpu throttle migration parameters */
|
||||
#define DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL 20
|
||||
#define DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT 10
|
||||
#define DEFAULT_MIGRATE_MAX_CPU_THROTTLE 99
|
||||
|
||||
/* Migration XBZRLE default cache size */
|
||||
#define DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE (64 * 1024 * 1024)
|
||||
|
|
@ -697,6 +698,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp)
|
|||
params->xbzrle_cache_size = s->parameters.xbzrle_cache_size;
|
||||
params->has_max_postcopy_bandwidth = true;
|
||||
params->max_postcopy_bandwidth = s->parameters.max_postcopy_bandwidth;
|
||||
params->has_max_cpu_throttle = true;
|
||||
params->max_cpu_throttle = s->parameters.max_cpu_throttle;
|
||||
|
||||
return params;
|
||||
}
|
||||
|
|
@ -1043,6 +1046,15 @@ static bool migrate_params_check(MigrationParameters *params, Error **errp)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (params->has_max_cpu_throttle &&
|
||||
(params->max_cpu_throttle < params->cpu_throttle_initial ||
|
||||
params->max_cpu_throttle > 99)) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
|
||||
"max_cpu_throttle",
|
||||
"an integer in the range of cpu_throttle_initial to 99");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1110,6 +1122,9 @@ static void migrate_params_test_apply(MigrateSetParameters *params,
|
|||
if (params->has_max_postcopy_bandwidth) {
|
||||
dest->max_postcopy_bandwidth = params->max_postcopy_bandwidth;
|
||||
}
|
||||
if (params->has_max_cpu_throttle) {
|
||||
dest->max_cpu_throttle = params->max_cpu_throttle;
|
||||
}
|
||||
}
|
||||
|
||||
static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
|
||||
|
|
@ -1185,6 +1200,9 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
|
|||
if (params->has_max_postcopy_bandwidth) {
|
||||
s->parameters.max_postcopy_bandwidth = params->max_postcopy_bandwidth;
|
||||
}
|
||||
if (params->has_max_cpu_throttle) {
|
||||
s->parameters.max_cpu_throttle = params->max_cpu_throttle;
|
||||
}
|
||||
}
|
||||
|
||||
void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp)
|
||||
|
|
@ -1962,7 +1980,6 @@ static int64_t migrate_max_postcopy_bandwidth(void)
|
|||
return s->parameters.max_postcopy_bandwidth;
|
||||
}
|
||||
|
||||
|
||||
bool migrate_use_block(void)
|
||||
{
|
||||
MigrationState *s;
|
||||
|
|
@ -3160,6 +3177,9 @@ static Property migration_properties[] = {
|
|||
DEFINE_PROP_SIZE("max-postcopy-bandwidth", MigrationState,
|
||||
parameters.max_postcopy_bandwidth,
|
||||
DEFAULT_MIGRATE_MAX_POSTCOPY_BANDWIDTH),
|
||||
DEFINE_PROP_UINT8("max-cpu-throttle", MigrationState,
|
||||
parameters.max_cpu_throttle,
|
||||
DEFAULT_MIGRATE_MAX_CPU_THROTTLE),
|
||||
|
||||
/* Migration capabilities */
|
||||
DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE),
|
||||
|
|
@ -3230,6 +3250,7 @@ static void migration_instance_init(Object *obj)
|
|||
params->has_x_multifd_page_count = true;
|
||||
params->has_xbzrle_cache_size = true;
|
||||
params->has_max_postcopy_bandwidth = true;
|
||||
params->has_max_cpu_throttle = true;
|
||||
|
||||
qemu_sem_init(&ms->postcopy_pause_sem, 0);
|
||||
qemu_sem_init(&ms->postcopy_pause_rp_sem, 0);
|
||||
|
|
|
|||
|
|
@ -266,6 +266,7 @@ bool migrate_colo_enabled(void);
|
|||
|
||||
bool migrate_use_block(void);
|
||||
bool migrate_use_block_incremental(void);
|
||||
int migrate_max_cpu_throttle(void);
|
||||
bool migrate_use_return_path(void);
|
||||
|
||||
bool migrate_use_compression(void);
|
||||
|
|
|
|||
|
|
@ -1391,13 +1391,15 @@ static void mig_throttle_guest_down(void)
|
|||
MigrationState *s = migrate_get_current();
|
||||
uint64_t pct_initial = s->parameters.cpu_throttle_initial;
|
||||
uint64_t pct_icrement = s->parameters.cpu_throttle_increment;
|
||||
int pct_max = s->parameters.max_cpu_throttle;
|
||||
|
||||
/* We have not started throttling yet. Let's start it. */
|
||||
if (!cpu_throttle_active()) {
|
||||
cpu_throttle_set(pct_initial);
|
||||
} else {
|
||||
/* Throttling already on, just increase the rate */
|
||||
cpu_throttle_set(cpu_throttle_get_percentage() + pct_icrement);
|
||||
cpu_throttle_set(MIN(cpu_throttle_get_percentage() + pct_icrement,
|
||||
pct_max));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue