qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] migration/throttle: use the xfer pages as threshold
@ 2020-04-01  1:08 Wang Xin
  0 siblings, 0 replies; only message in thread
From: Wang Xin @ 2020-04-01  1:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: Wang Xin, dgilbert, quintela

If VM migration with lots of zero page or enable data compress, the peroid
tansfer bytes may be much less than the available bandwidth, which trigger
unnecessary guest throttle down. Use the raw transfer pages as the
threshold instead.

Signed-off-by: Wang Xin <wangxinxin.wang@huawei.com>

diff --git a/migration/ram.c b/migration/ram.c
index 04f13feb2e..e53333bc6a 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -323,6 +323,8 @@ struct RAMState {
     int64_t time_last_bitmap_sync;
     /* bytes transferred at start_time */
     uint64_t bytes_xfer_prev;
+    /* pages transferred at start_time */
+    uint64_t pages_xfer_prev;
     /* number of dirty pages since start_time */
     uint64_t num_dirty_pages_period;
     /* xbzrle misses since the beginning of the period */
@@ -901,9 +903,9 @@ static void migration_trigger_throttle(RAMState *rs)
     MigrationState *s = migrate_get_current();
     uint64_t threshold = s->parameters.throttle_trigger_threshold;
 
-    uint64_t bytes_xfer_period = ram_counters.transferred - rs->bytes_xfer_prev;
-    uint64_t bytes_dirty_period = rs->num_dirty_pages_period * TARGET_PAGE_SIZE;
-    uint64_t bytes_dirty_threshold = bytes_xfer_period * threshold / 100;
+    uint64_t pages_xfer_period = ram_get_total_transferred_pages() -
+                                 rs->pages_xfer_prev;
+    uint64_t pages_dirty_threshold = pages_xfer_period * threshold / 100;
 
     /* During block migration the auto-converge logic incorrectly detects
      * that ram migration makes no progress. Avoid this by disabling the
@@ -915,7 +917,7 @@ static void migration_trigger_throttle(RAMState *rs)
            we were in this routine reaches the threshold. If that happens
            twice, start or increase throttling. */
 
-        if ((bytes_dirty_period > bytes_dirty_threshold) &&
+        if ((rs->num_dirty_pages_period > pages_dirty_threshold) &&
             (++rs->dirty_rate_high_cnt >= 2)) {
             trace_migration_throttle();
             rs->dirty_rate_high_cnt = 0;
@@ -964,6 +966,7 @@ static void migration_bitmap_sync(RAMState *rs)
         rs->time_last_bitmap_sync = end_time;
         rs->num_dirty_pages_period = 0;
         rs->bytes_xfer_prev = ram_counters.transferred;
+        rs->pages_xfer_prev = ram_get_total_transferred_pages();
     }
     if (migrate_use_events()) {
         qapi_event_send_migration_pass(ram_counters.dirty_sync_count);
-- 
2.26.0.windows.1




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-04-01  3:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-01  1:08 [PATCH] migration/throttle: use the xfer pages as threshold Wang Xin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).