• 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ão61c265f0660ee476985808c8aa7915617c44fd53 (tree)
Hora2020-03-13 19:33:04
AutorPeter Maydell <peter.maydell@lina...>
CommiterPeter Maydell

Mensagem de Log

Migration pull 2020-03-13

zstd build fix
A new auto-converge parameter
Some COLO improvements
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEERfXHG0oMt/uXep+pBRYzHrxb/ecFAl5rYI4ACgkQBRYzHrxb
/efy3A/8CY4NTy7AH+wJITLvCNi5hQA/T/yqfau/PFI817xgpHEZG+m/y4DFYbfZ
NKgQomEdGyP40iTKL3zFTEipAZ6IaZtVK6XkCsFPxjEV/G0DzSGagpXkxOb4ODOa
B59Wg+yFnvh/8CaPPKfY5tqVAlhzUjfu1vqfDDr08xcwazcjGdhQNe+w6iljGkSI
QPAl1p+rmFXt1r7AnsprBIkGcTBCzLaxcsUHkYXTZwwnS9QWtpbhk+n1OpUI7KGJ
NNxZ06TiN6vG+togcVR8AlKe1BJUEAqbU7oi4ds0zYLU7cwbxRKNh9Jxwm13OmFh
rQMTtYwx354WQGtLMNZGgZV+jm3fAJeorZSDQCiWEIqFOrvysWaL13RHbJxMCoxr
V0MpY9ba+bJr2o0W90qvGOzzizNlG86NIbnYEr4j9zUlIq52RY8vLDVwncP9eCg5
1SLPEDES8cjPEfWDBNQzL6ZtW2P/3USfr0YSF4TdvF7w+Y1pn2v0KOOyqDWavWsh
4HML9zObg42B7tr82YChhzMIyW5EBw13fwSWp7KsZBxzGEHpQWjtr96XxeEQVUvK
Qeh90wxyHiVLxATBJyWNXz2rsuxSahjhP23SxwmKhB5Awu/ojjSo2vPf2L2aR9eg
ivusFjZHTinNa64CyS4ZOnol3nJpWsvdHPiXpicjtrLM70ljmSU=
=/Uri
-----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20200313a' into staging

Migration pull 2020-03-13

zstd build fix
A new auto-converge parameter
Some COLO improvements

# gpg: Signature made Fri 13 Mar 2020 10:29:34 GMT
# gpg: using RSA key 45F5C71B4A0CB7FB977A9FA90516331EBC5BFDE7
# gpg: Good signature from "Dr. David Alan Gilbert (RH2) <dgilbert@redhat.com>" [full]
# Primary key fingerprint: 45F5 C71B 4A0C B7FB 977A 9FA9 0516 331E BC5B FDE7

* remotes/dgilbert/tags/pull-migration-20200313a:

migration: recognize COLO as part of activating process
ram/colo: only record bitmap of dirty pages in COLO stage
COLO: Optimize memory back-up process
migration/throttle: Add throttle-trig-thres migration parameter
configure: Improve zstd test

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Mudança Sumário

Diff

--- a/configure
+++ b/configure
@@ -2475,7 +2475,8 @@ fi
24752475 # zstd check
24762476
24772477 if test "$zstd" != "no" ; then
2478- if $pkg_config --exist libzstd ; then
2478+ libzstd_minver="1.4.0"
2479+ if $pkg_config --atleast-version=$libzstd_minver libzstd ; then
24792480 zstd_cflags="$($pkg_config --cflags libzstd)"
24802481 zstd_libs="$($pkg_config --libs libzstd)"
24812482 LIBS="$zstd_libs $LIBS"
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -26,6 +26,7 @@
2626 #include "qemu/main-loop.h"
2727 #include "qemu/rcu.h"
2828 #include "migration/failover.h"
29+#include "migration/ram.h"
2930 #ifdef CONFIG_REPLICATION
3031 #include "replication.h"
3132 #endif
@@ -845,6 +846,8 @@ void *colo_process_incoming_thread(void *opaque)
845846 */
846847 qemu_file_set_blocking(mis->from_src_file, true);
847848
849+ colo_incoming_start_dirty_log();
850+
848851 bioc = qio_channel_buffer_new(COLO_BUFFER_BASE_SIZE);
849852 fb = qemu_fopen_channel_input(QIO_CHANNEL(bioc));
850853 object_unref(OBJECT(bioc));
--- 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;
@@ -851,6 +854,7 @@ bool migration_is_setup_or_active(int state)
851854 case MIGRATION_STATUS_PRE_SWITCHOVER:
852855 case MIGRATION_STATUS_DEVICE:
853856 case MIGRATION_STATUS_WAIT_UNPLUG:
857+ case MIGRATION_STATUS_COLO:
854858 return true;
855859
856860 default:
@@ -1169,6 +1173,15 @@ static bool migrate_params_check(MigrationParameters *params, Error **errp)
11691173 return false;
11701174 }
11711175
1176+ if (params->has_throttle_trigger_threshold &&
1177+ (params->throttle_trigger_threshold < 1 ||
1178+ params->throttle_trigger_threshold > 100)) {
1179+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
1180+ "throttle_trigger_threshold",
1181+ "an integer in the range of 1 to 100");
1182+ return false;
1183+ }
1184+
11721185 if (params->has_cpu_throttle_initial &&
11731186 (params->cpu_throttle_initial < 1 ||
11741187 params->cpu_throttle_initial > 99)) {
@@ -1298,6 +1311,10 @@ static void migrate_params_test_apply(MigrateSetParameters *params,
12981311 dest->decompress_threads = params->decompress_threads;
12991312 }
13001313
1314+ if (params->has_throttle_trigger_threshold) {
1315+ dest->throttle_trigger_threshold = params->throttle_trigger_threshold;
1316+ }
1317+
13011318 if (params->has_cpu_throttle_initial) {
13021319 dest->cpu_throttle_initial = params->cpu_throttle_initial;
13031320 }
@@ -1382,6 +1399,10 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
13821399 s->parameters.decompress_threads = params->decompress_threads;
13831400 }
13841401
1402+ if (params->has_throttle_trigger_threshold) {
1403+ s->parameters.throttle_trigger_threshold = params->throttle_trigger_threshold;
1404+ }
1405+
13851406 if (params->has_cpu_throttle_initial) {
13861407 s->parameters.cpu_throttle_initial = params->cpu_throttle_initial;
13871408 }
@@ -3558,6 +3579,9 @@ static Property migration_properties[] = {
35583579 DEFINE_PROP_UINT8("x-decompress-threads", MigrationState,
35593580 parameters.decompress_threads,
35603581 DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT),
3582+ DEFINE_PROP_UINT8("x-throttle-trigger-threshold", MigrationState,
3583+ parameters.throttle_trigger_threshold,
3584+ DEFAULT_MIGRATE_THROTTLE_TRIGGER_THRESHOLD),
35613585 DEFINE_PROP_UINT8("x-cpu-throttle-initial", MigrationState,
35623586 parameters.cpu_throttle_initial,
35633587 DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL),
@@ -3667,6 +3691,7 @@ static void migration_instance_init(Object *obj)
36673691 params->has_compress_level = true;
36683692 params->has_compress_threads = true;
36693693 params->has_decompress_threads = true;
3694+ params->has_throttle_trigger_threshold = true;
36703695 params->has_cpu_throttle_initial = true;
36713696 params->has_cpu_throttle_increment = true;
36723697 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);
@@ -2734,7 +2742,7 @@ static inline void *host_from_ram_block_offset(RAMBlock *block,
27342742 }
27352743
27362744 static inline void *colo_cache_from_block_offset(RAMBlock *block,
2737- ram_addr_t offset)
2745+ ram_addr_t offset, bool record_bitmap)
27382746 {
27392747 if (!offset_in_ramblock(block, offset)) {
27402748 return NULL;
@@ -2750,7 +2758,8 @@ static inline void *colo_cache_from_block_offset(RAMBlock *block,
27502758 * It help us to decide which pages in ram cache should be flushed
27512759 * into VM's RAM later.
27522760 */
2753- if (!test_and_set_bit(offset >> TARGET_PAGE_BITS, block->bmap)) {
2761+ if (record_bitmap &&
2762+ !test_and_set_bit(offset >> TARGET_PAGE_BITS, block->bmap)) {
27542763 ram_state->migration_dirty_pages++;
27552764 }
27562765 return block->colo_cache + offset;
@@ -2986,7 +2995,6 @@ int colo_init_ram_cache(void)
29862995 }
29872996 return -errno;
29882997 }
2989- memcpy(block->colo_cache, block->host, block->used_length);
29902998 }
29912999 }
29923000
@@ -3000,19 +3008,36 @@ int colo_init_ram_cache(void)
30003008
30013009 RAMBLOCK_FOREACH_NOT_IGNORED(block) {
30023010 unsigned long pages = block->max_length >> TARGET_PAGE_BITS;
3003-
30043011 block->bmap = bitmap_new(pages);
3005- bitmap_set(block->bmap, 0, pages);
30063012 }
30073013 }
3008- ram_state = g_new0(RAMState, 1);
3009- ram_state->migration_dirty_pages = 0;
3010- qemu_mutex_init(&ram_state->bitmap_mutex);
3011- memory_global_dirty_log_start();
30123014
3015+ ram_state_init(&ram_state);
30133016 return 0;
30143017 }
30153018
3019+/* TODO: duplicated with ram_init_bitmaps */
3020+void colo_incoming_start_dirty_log(void)
3021+{
3022+ RAMBlock *block = NULL;
3023+ /* For memory_global_dirty_log_start below. */
3024+ qemu_mutex_lock_iothread();
3025+ qemu_mutex_lock_ramlist();
3026+
3027+ memory_global_dirty_log_sync();
3028+ WITH_RCU_READ_LOCK_GUARD() {
3029+ RAMBLOCK_FOREACH_NOT_IGNORED(block) {
3030+ ramblock_sync_dirty_bitmap(ram_state, block);
3031+ /* Discard this dirty bitmap record */
3032+ bitmap_zero(block->bmap, block->max_length >> TARGET_PAGE_BITS);
3033+ }
3034+ memory_global_dirty_log_start();
3035+ }
3036+ ram_state->migration_dirty_pages = 0;
3037+ qemu_mutex_unlock_ramlist();
3038+ qemu_mutex_unlock_iothread();
3039+}
3040+
30163041 /* It is need to hold the global lock to call this helper */
30173042 void colo_release_ram_cache(void)
30183043 {
@@ -3032,9 +3057,7 @@ void colo_release_ram_cache(void)
30323057 }
30333058 }
30343059 }
3035- qemu_mutex_destroy(&ram_state->bitmap_mutex);
3036- g_free(ram_state);
3037- ram_state = NULL;
3060+ ram_state_cleanup(&ram_state);
30383061 }
30393062
30403063 /**
@@ -3348,7 +3371,7 @@ static int ram_load_precopy(QEMUFile *f)
33483371
33493372 while (!ret && !(flags & RAM_SAVE_FLAG_EOS)) {
33503373 ram_addr_t addr, total_ram_bytes;
3351- void *host = NULL;
3374+ void *host = NULL, *host_bak = NULL;
33523375 uint8_t ch;
33533376
33543377 /*
@@ -3379,20 +3402,35 @@ static int ram_load_precopy(QEMUFile *f)
33793402 RAM_SAVE_FLAG_COMPRESS_PAGE | RAM_SAVE_FLAG_XBZRLE)) {
33803403 RAMBlock *block = ram_block_from_stream(f, flags);
33813404
3405+ host = host_from_ram_block_offset(block, addr);
33823406 /*
3383- * After going into COLO, we should load the Page into colo_cache.
3407+ * After going into COLO stage, we should not load the page
3408+ * into SVM's memory directly, we put them into colo_cache firstly.
3409+ * NOTE: We need to keep a copy of SVM's ram in colo_cache.
3410+ * Previously, we copied all these memory in preparing stage of COLO
3411+ * while we need to stop VM, which is a time-consuming process.
3412+ * Here we optimize it by a trick, back-up every page while in
3413+ * migration process while COLO is enabled, though it affects the
3414+ * speed of the migration, but it obviously reduce the downtime of
3415+ * back-up all SVM'S memory in COLO preparing stage.
33843416 */
3385- if (migration_incoming_in_colo_state()) {
3386- host = colo_cache_from_block_offset(block, addr);
3387- } else {
3388- host = host_from_ram_block_offset(block, addr);
3417+ if (migration_incoming_colo_enabled()) {
3418+ if (migration_incoming_in_colo_state()) {
3419+ /* In COLO stage, put all pages into cache temporarily */
3420+ host = colo_cache_from_block_offset(block, addr, true);
3421+ } else {
3422+ /*
3423+ * In migration stage but before COLO stage,
3424+ * Put all pages into both cache and SVM's memory.
3425+ */
3426+ host_bak = colo_cache_from_block_offset(block, addr, false);
3427+ }
33893428 }
33903429 if (!host) {
33913430 error_report("Illegal RAM offset " RAM_ADDR_FMT, addr);
33923431 ret = -EINVAL;
33933432 break;
33943433 }
3395-
33963434 if (!migration_incoming_in_colo_state()) {
33973435 ramblock_recv_bitmap_set(block, host);
33983436 }
@@ -3506,6 +3544,9 @@ static int ram_load_precopy(QEMUFile *f)
35063544 if (!ret) {
35073545 ret = qemu_file_get_error(f);
35083546 }
3547+ if (!ret && host_bak) {
3548+ memcpy(host_bak, host, TARGET_PAGE_SIZE);
3549+ }
35093550 }
35103551
35113552 ret |= wait_for_decompress_done();
--- a/migration/ram.h
+++ b/migration/ram.h
@@ -66,5 +66,6 @@ int ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *rb);
6666 /* ram cache */
6767 int colo_init_ram_cache(void);
6868 void colo_release_ram_cache(void);
69+void colo_incoming_start_dirty_log(void);
6970
7071 #endif
--- 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',