• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisãodc14a470763c96fd9d360e1028ce38e8c3613a77 (tree)
Hora2020-03-13 18:36:30
AutorKeqian Zhu <zhukeqian1@huaw...>
CommiterDr. David Alan Gilbert

Mensagem de Log

migration/throttle: Add throttle-trig-thres migration parameter

Currently, if the bytes_dirty_period is more than the 50% of
bytes_xfer_period, we start or increase throttling.

If we make this percentage higher, then we can tolerate higher
dirty rate during migration, which means less impact on guest.
The side effect of higher percentage is longer migration time.
We can make this parameter configurable to switch between mig-
ration time first or guest performance first.

The default value is 50 and valid range is 1 to 100.

Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
Message-Id: <20200224023142.39360-1-zhukeqian1@huawei.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

Mudança Sumário

Diff

--- a/migration/migration.c
+++ b/migration/migration.c
@@ -78,6 +78,7 @@
7878 /*0: means nocompress, 1: best speed, ... 9: best compress ratio */
7979 #define DEFAULT_MIGRATE_COMPRESS_LEVEL 1
8080 /* Define default autoconverge cpu throttle migration parameters */
81+#define DEFAULT_MIGRATE_THROTTLE_TRIGGER_THRESHOLD 50
8182 #define DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL 20
8283 #define DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT 10
8384 #define DEFAULT_MIGRATE_MAX_CPU_THROTTLE 99
@@ -778,6 +779,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp)
778779 params->compress_wait_thread = s->parameters.compress_wait_thread;
779780 params->has_decompress_threads = true;
780781 params->decompress_threads = s->parameters.decompress_threads;
782+ params->has_throttle_trigger_threshold = true;
783+ params->throttle_trigger_threshold = s->parameters.throttle_trigger_threshold;
781784 params->has_cpu_throttle_initial = true;
782785 params->cpu_throttle_initial = s->parameters.cpu_throttle_initial;
783786 params->has_cpu_throttle_increment = true;
@@ -1169,6 +1172,15 @@ static bool migrate_params_check(MigrationParameters *params, Error **errp)
11691172 return false;
11701173 }
11711174
1175+ if (params->has_throttle_trigger_threshold &&
1176+ (params->throttle_trigger_threshold < 1 ||
1177+ params->throttle_trigger_threshold > 100)) {
1178+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
1179+ "throttle_trigger_threshold",
1180+ "an integer in the range of 1 to 100");
1181+ return false;
1182+ }
1183+
11721184 if (params->has_cpu_throttle_initial &&
11731185 (params->cpu_throttle_initial < 1 ||
11741186 params->cpu_throttle_initial > 99)) {
@@ -1298,6 +1310,10 @@ static void migrate_params_test_apply(MigrateSetParameters *params,
12981310 dest->decompress_threads = params->decompress_threads;
12991311 }
13001312
1313+ if (params->has_throttle_trigger_threshold) {
1314+ dest->throttle_trigger_threshold = params->throttle_trigger_threshold;
1315+ }
1316+
13011317 if (params->has_cpu_throttle_initial) {
13021318 dest->cpu_throttle_initial = params->cpu_throttle_initial;
13031319 }
@@ -1382,6 +1398,10 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
13821398 s->parameters.decompress_threads = params->decompress_threads;
13831399 }
13841400
1401+ if (params->has_throttle_trigger_threshold) {
1402+ s->parameters.throttle_trigger_threshold = params->throttle_trigger_threshold;
1403+ }
1404+
13851405 if (params->has_cpu_throttle_initial) {
13861406 s->parameters.cpu_throttle_initial = params->cpu_throttle_initial;
13871407 }
@@ -3558,6 +3578,9 @@ static Property migration_properties[] = {
35583578 DEFINE_PROP_UINT8("x-decompress-threads", MigrationState,
35593579 parameters.decompress_threads,
35603580 DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT),
3581+ DEFINE_PROP_UINT8("x-throttle-trigger-threshold", MigrationState,
3582+ parameters.throttle_trigger_threshold,
3583+ DEFAULT_MIGRATE_THROTTLE_TRIGGER_THRESHOLD),
35613584 DEFINE_PROP_UINT8("x-cpu-throttle-initial", MigrationState,
35623585 parameters.cpu_throttle_initial,
35633586 DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL),
@@ -3667,6 +3690,7 @@ static void migration_instance_init(Object *obj)
36673690 params->has_compress_level = true;
36683691 params->has_compress_threads = true;
36693692 params->has_decompress_threads = true;
3693+ params->has_throttle_trigger_threshold = true;
36703694 params->has_cpu_throttle_initial = true;
36713695 params->has_cpu_throttle_increment = true;
36723696 params->has_max_bandwidth = true;
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -896,11 +896,38 @@ static void migration_update_rates(RAMState *rs, int64_t end_time)
896896 }
897897 }
898898
899+static void migration_trigger_throttle(RAMState *rs)
900+{
901+ MigrationState *s = migrate_get_current();
902+ uint64_t threshold = s->parameters.throttle_trigger_threshold;
903+
904+ uint64_t bytes_xfer_period = ram_counters.transferred - rs->bytes_xfer_prev;
905+ uint64_t bytes_dirty_period = rs->num_dirty_pages_period * TARGET_PAGE_SIZE;
906+ uint64_t bytes_dirty_threshold = bytes_xfer_period * threshold / 100;
907+
908+ /* During block migration the auto-converge logic incorrectly detects
909+ * that ram migration makes no progress. Avoid this by disabling the
910+ * throttling logic during the bulk phase of block migration. */
911+ if (migrate_auto_converge() && !blk_mig_bulk_active()) {
912+ /* The following detection logic can be refined later. For now:
913+ Check to see if the ratio between dirtied bytes and the approx.
914+ amount of bytes that just got transferred since the last time
915+ we were in this routine reaches the threshold. If that happens
916+ twice, start or increase throttling. */
917+
918+ if ((bytes_dirty_period > bytes_dirty_threshold) &&
919+ (++rs->dirty_rate_high_cnt >= 2)) {
920+ trace_migration_throttle();
921+ rs->dirty_rate_high_cnt = 0;
922+ mig_throttle_guest_down();
923+ }
924+ }
925+}
926+
899927 static void migration_bitmap_sync(RAMState *rs)
900928 {
901929 RAMBlock *block;
902930 int64_t end_time;
903- uint64_t bytes_xfer_now;
904931
905932 ram_counters.dirty_sync_count++;
906933
@@ -927,26 +954,7 @@ static void migration_bitmap_sync(RAMState *rs)
927954
928955 /* more than 1 second = 1000 millisecons */
929956 if (end_time > rs->time_last_bitmap_sync + 1000) {
930- bytes_xfer_now = ram_counters.transferred;
931-
932- /* During block migration the auto-converge logic incorrectly detects
933- * that ram migration makes no progress. Avoid this by disabling the
934- * throttling logic during the bulk phase of block migration. */
935- if (migrate_auto_converge() && !blk_mig_bulk_active()) {
936- /* The following detection logic can be refined later. For now:
937- Check to see if the dirtied bytes is 50% more than the approx.
938- amount of bytes that just got transferred since the last time we
939- were in this routine. If that happens twice, start or increase
940- throttling */
941-
942- if ((rs->num_dirty_pages_period * TARGET_PAGE_SIZE >
943- (bytes_xfer_now - rs->bytes_xfer_prev) / 2) &&
944- (++rs->dirty_rate_high_cnt >= 2)) {
945- trace_migration_throttle();
946- rs->dirty_rate_high_cnt = 0;
947- mig_throttle_guest_down();
948- }
949- }
957+ migration_trigger_throttle(rs);
950958
951959 migration_update_rates(rs, end_time);
952960
@@ -955,7 +963,7 @@ static void migration_bitmap_sync(RAMState *rs)
955963 /* reset period counters */
956964 rs->time_last_bitmap_sync = end_time;
957965 rs->num_dirty_pages_period = 0;
958- rs->bytes_xfer_prev = bytes_xfer_now;
966+ rs->bytes_xfer_prev = ram_counters.transferred;
959967 }
960968 if (migrate_use_events()) {
961969 qapi_event_send_migration_pass(ram_counters.dirty_sync_count);
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -407,6 +407,10 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
407407 monitor_printf(mon, "%s: %u\n",
408408 MigrationParameter_str(MIGRATION_PARAMETER_DECOMPRESS_THREADS),
409409 params->decompress_threads);
410+ assert(params->has_throttle_trigger_threshold);
411+ monitor_printf(mon, "%s: %u\n",
412+ MigrationParameter_str(MIGRATION_PARAMETER_THROTTLE_TRIGGER_THRESHOLD),
413+ params->throttle_trigger_threshold);
410414 assert(params->has_cpu_throttle_initial);
411415 monitor_printf(mon, "%s: %u\n",
412416 MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL),
@@ -1254,6 +1258,9 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
12541258 p->has_decompress_threads = true;
12551259 visit_type_int(v, param, &p->decompress_threads, &err);
12561260 break;
1261+ case MIGRATION_PARAMETER_THROTTLE_TRIGGER_THRESHOLD:
1262+ p->has_throttle_trigger_threshold = true;
1263+ visit_type_int(v, param, &p->throttle_trigger_threshold, &err);
12571264 case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL:
12581265 p->has_cpu_throttle_initial = true;
12591266 visit_type_int(v, param, &p->cpu_throttle_initial, &err);
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -540,6 +540,10 @@
540540 # compression, so set the decompress-threads to the number about 1/4
541541 # of compress-threads is adequate.
542542 #
543+# @throttle-trigger-threshold: The ratio of bytes_dirty_period and bytes_xfer_period
544+# to trigger throttling. It is expressed as percentage.
545+# The default value is 50. (Since 5.0)
546+#
543547 # @cpu-throttle-initial: Initial percentage of time guest cpus are throttled
544548 # when migration auto-converge is activated. The
545549 # default value is 20. (Since 2.7)
@@ -625,7 +629,7 @@
625629 'data': ['announce-initial', 'announce-max',
626630 'announce-rounds', 'announce-step',
627631 'compress-level', 'compress-threads', 'decompress-threads',
628- 'compress-wait-thread',
632+ 'compress-wait-thread', 'throttle-trigger-threshold',
629633 'cpu-throttle-initial', 'cpu-throttle-increment',
630634 'tls-creds', 'tls-hostname', 'tls-authz', 'max-bandwidth',
631635 'downtime-limit', 'x-checkpoint-delay', 'block-incremental',
@@ -660,6 +664,10 @@
660664 #
661665 # @decompress-threads: decompression thread count
662666 #
667+# @throttle-trigger-threshold: The ratio of bytes_dirty_period and bytes_xfer_period
668+# to trigger throttling. It is expressed as percentage.
669+# The default value is 50. (Since 5.0)
670+#
663671 # @cpu-throttle-initial: Initial percentage of time guest cpus are
664672 # throttled when migration auto-converge is activated.
665673 # The default value is 20. (Since 2.7)
@@ -752,6 +760,7 @@
752760 '*compress-threads': 'int',
753761 '*compress-wait-thread': 'bool',
754762 '*decompress-threads': 'int',
763+ '*throttle-trigger-threshold': 'int',
755764 '*cpu-throttle-initial': 'int',
756765 '*cpu-throttle-increment': 'int',
757766 '*tls-creds': 'StrOrNull',
@@ -813,6 +822,10 @@
813822 #
814823 # @decompress-threads: decompression thread count
815824 #
825+# @throttle-trigger-threshold: The ratio of bytes_dirty_period and bytes_xfer_period
826+# to trigger throttling. It is expressed as percentage.
827+# The default value is 50. (Since 5.0)
828+#
816829 # @cpu-throttle-initial: Initial percentage of time guest cpus are
817830 # throttled when migration auto-converge is activated.
818831 # (Since 2.7)
@@ -905,6 +918,7 @@
905918 '*compress-threads': 'uint8',
906919 '*compress-wait-thread': 'bool',
907920 '*decompress-threads': 'uint8',
921+ '*throttle-trigger-threshold': 'uint8',
908922 '*cpu-throttle-initial': 'uint8',
909923 '*cpu-throttle-increment': 'uint8',
910924 '*tls-creds': 'str',