All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org
Cc: aarcange@redhat.com, yamahata@private.email.ne.jp,
	quintela@redhat.com, amit.shah@redhat.com, pbonzini@redhat.com,
	david@gibson.dropbear.id.au, yayanghy@cn.fujitsu.com
Subject: [Qemu-devel] [PATCH v6 24/47] Modify save_live_pending for postcopy
Date: Tue, 14 Apr 2015 18:03:50 +0100	[thread overview]
Message-ID: <1429031053-4454-25-git-send-email-dgilbert@redhat.com> (raw)
In-Reply-To: <1429031053-4454-1-git-send-email-dgilbert@redhat.com>

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Modify save_live_pending to return separate postcopiable and
non-postcopiable counts.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 arch_init.c                 |  8 ++++++--
 include/migration/vmstate.h |  5 +++--
 include/sysemu/sysemu.h     |  4 +++-
 migration/block.c           |  7 +++++--
 migration/migration.c       |  9 +++++++--
 savevm.c                    | 21 +++++++++++++++++----
 trace-events                |  2 +-
 7 files changed, 42 insertions(+), 14 deletions(-)

diff --git a/arch_init.c b/arch_init.c
index 2b0cd18..977e98b 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -1053,7 +1053,9 @@ static int ram_save_complete(QEMUFile *f, void *opaque)
     return 0;
 }
 
-static uint64_t ram_save_pending(QEMUFile *f, void *opaque, uint64_t max_size)
+static void ram_save_pending(QEMUFile *f, void *opaque, uint64_t max_size,
+                             uint64_t *non_postcopiable_pending,
+                             uint64_t *postcopiable_pending)
 {
     uint64_t remaining_size;
 
@@ -1067,7 +1069,9 @@ static uint64_t ram_save_pending(QEMUFile *f, void *opaque, uint64_t max_size)
         qemu_mutex_unlock_iothread();
         remaining_size = ram_save_remaining() * TARGET_PAGE_SIZE;
     }
-    return remaining_size;
+
+    *non_postcopiable_pending = 0;
+    *postcopiable_pending = remaining_size;
 }
 
 static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host)
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index b86b3d9..50efb09 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -54,8 +54,9 @@ typedef struct SaveVMHandlers {
 
     /* This runs outside the iothread lock!  */
     int (*save_live_setup)(QEMUFile *f, void *opaque);
-    uint64_t (*save_live_pending)(QEMUFile *f, void *opaque, uint64_t max_size);
-
+    void (*save_live_pending)(QEMUFile *f, void *opaque, uint64_t max_size,
+                              uint64_t *non_postcopiable_pending,
+                              uint64_t *postcopiable_pending);
     LoadStateHandler *load_state;
 } SaveVMHandlers;
 
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 0e3bf1e..e45ef62 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -110,7 +110,9 @@ void qemu_savevm_state_header(QEMUFile *f);
 int qemu_savevm_state_iterate(QEMUFile *f);
 void qemu_savevm_state_complete_precopy(QEMUFile *f);
 void qemu_savevm_state_cancel(void);
-uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size);
+void qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size,
+                               uint64_t *res_non_postcopiable,
+                               uint64_t *res_postcopiable);
 void qemu_savevm_command_send(QEMUFile *f, enum qemu_vm_cmd command,
                               uint16_t len, uint8_t *data);
 void qemu_savevm_send_ping(QEMUFile *f, uint32_t value);
diff --git a/migration/block.c b/migration/block.c
index 00f4998..802dbfa 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -755,7 +755,9 @@ static int block_save_complete(QEMUFile *f, void *opaque)
     return 0;
 }
 
-static uint64_t block_save_pending(QEMUFile *f, void *opaque, uint64_t max_size)
+static void block_save_pending(QEMUFile *f, void *opaque, uint64_t max_size,
+                               uint64_t *non_postcopiable_pending,
+                               uint64_t *postcopiable_pending)
 {
     /* Estimate pending number of bytes to send */
     uint64_t pending;
@@ -774,7 +776,8 @@ static uint64_t block_save_pending(QEMUFile *f, void *opaque, uint64_t max_size)
     qemu_mutex_unlock_iothread();
 
     DPRINTF("Enter save live pending  %" PRIu64 "\n", pending);
-    return pending;
+    *non_postcopiable_pending = pending;
+    *postcopiable_pending = 0;
 }
 
 static int block_load(QEMUFile *f, void *opaque, int version_id)
diff --git a/migration/migration.c b/migration/migration.c
index 45284b2..ae737d1 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -889,8 +889,13 @@ static void *migration_thread(void *opaque)
         uint64_t pending_size;
 
         if (!qemu_file_rate_limit(s->file)) {
-            pending_size = qemu_savevm_state_pending(s->file, max_size);
-            trace_migrate_pending(pending_size, max_size);
+            uint64_t pend_post, pend_nonpost;
+
+            qemu_savevm_state_pending(s->file, max_size, &pend_nonpost,
+                                      &pend_post);
+            pending_size = pend_nonpost + pend_post;
+            trace_migrate_pending(pending_size, max_size,
+                                  pend_post, pend_nonpost);
             if (pending_size && pending_size >= max_size) {
                 qemu_savevm_state_iterate(s->file);
             } else {
diff --git a/savevm.c b/savevm.c
index c281d1b..79bbded 100644
--- a/savevm.c
+++ b/savevm.c
@@ -950,10 +950,20 @@ void qemu_savevm_state_complete_precopy(QEMUFile *f)
     qemu_fflush(f);
 }
 
-uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size)
+/* Give an estimate of the amount left to be transferred,
+ * the result is split into the amount for units that can and
+ * for units that can't do postcopy.
+ */
+void qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size,
+                               uint64_t *res_non_postcopiable,
+                               uint64_t *res_postcopiable)
 {
     SaveStateEntry *se;
-    uint64_t ret = 0;
+    uint64_t tmp_non_postcopiable, tmp_postcopiable;
+
+    *res_non_postcopiable = 0;
+    *res_postcopiable = 0;
+
 
     QTAILQ_FOREACH(se, &savevm_handlers, entry) {
         if (!se->ops || !se->ops->save_live_pending) {
@@ -964,9 +974,12 @@ uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size)
                 continue;
             }
         }
-        ret += se->ops->save_live_pending(f, se->opaque, max_size);
+        se->ops->save_live_pending(f, se->opaque, max_size,
+                                   &tmp_non_postcopiable, &tmp_postcopiable);
+
+        *res_postcopiable += tmp_postcopiable;
+        *res_non_postcopiable += tmp_non_postcopiable;
     }
-    return ret;
 }
 
 void qemu_savevm_state_cancel(void)
diff --git a/trace-events b/trace-events
index 4e53ad8..4f94cf4 100644
--- a/trace-events
+++ b/trace-events
@@ -1403,7 +1403,7 @@ migrate_fd_cleanup(void) ""
 migrate_fd_cleanup_src_rp(void) ""
 migrate_fd_error(void) ""
 migrate_fd_cancel(void) ""
-migrate_pending(uint64_t size, uint64_t max) "pending size %" PRIu64 " max %" PRIu64
+migrate_pending(uint64_t size, uint64_t max, uint64_t post, uint64_t nonpost) "pending size %" PRIu64 " max %" PRIu64 " (post=%" PRIu64 " nonpost=%" PRIu64 ")"
 migrate_send_rp_message(int msg_type, uint16_t len) "%d: len %d"
 open_return_path_on_source(void) ""
 open_return_path_on_source_continue(void) ""
-- 
2.1.0

  parent reply	other threads:[~2015-04-14 17:05 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-14 17:03 [Qemu-devel] [PATCH v6 00/47] Postcopy implementation Dr. David Alan Gilbert (git)
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 01/47] Start documenting how postcopy works Dr. David Alan Gilbert (git)
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 02/47] Split header writing out of qemu_savevm_state_begin Dr. David Alan Gilbert (git)
2015-05-11 11:16   ` Amit Shah
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 03/47] qemu_ram_foreach_block: pass up error value, and down the ramblock name Dr. David Alan Gilbert (git)
2015-05-15 10:38   ` Amit Shah
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 04/47] Add qemu_get_counted_string to read a string prefixed by a count byte Dr. David Alan Gilbert (git)
2015-05-15 13:50   ` Amit Shah
2015-05-15 14:06     ` Dr. David Alan Gilbert
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 05/47] Create MigrationIncomingState Dr. David Alan Gilbert (git)
2015-05-18  6:58   ` Amit Shah
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 06/47] Provide runtime Target page information Dr. David Alan Gilbert (git)
2015-05-18  7:06   ` Amit Shah
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 07/47] Move copy out of qemu_peek_buffer Dr. David Alan Gilbert (git)
2015-05-21  6:47   ` Amit Shah
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 08/47] Add qemu_get_buffer_less_copy to avoid copies some of the time Dr. David Alan Gilbert (git)
2015-05-21  7:09   ` Amit Shah
2015-05-21  8:45     ` Dr. David Alan Gilbert
2015-05-21  8:58       ` Amit Shah
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 09/47] Add wrapper for setting blocking status on a QEMUFile Dr. David Alan Gilbert (git)
2015-05-18  7:35   ` Amit Shah
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 10/47] Rename save_live_complete to save_live_complete_precopy Dr. David Alan Gilbert (git)
2015-05-18  7:35   ` Amit Shah
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 11/47] Return path: Open a return path on QEMUFile for sockets Dr. David Alan Gilbert (git)
2015-06-10  9:00   ` Amit Shah
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 12/47] Return path: socket_writev_buffer: Block even on non-blocking fd's Dr. David Alan Gilbert (git)
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 13/47] Migration commands Dr. David Alan Gilbert (git)
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 14/47] Return path: Control commands Dr. David Alan Gilbert (git)
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 15/47] Return path: Send responses from destination to source Dr. David Alan Gilbert (git)
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 16/47] Return path: Source handling of return path Dr. David Alan Gilbert (git)
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 17/47] ram_debug_dump_bitmap: Dump a migration bitmap as text Dr. David Alan Gilbert (git)
2015-05-21  9:21   ` Amit Shah
2015-05-21 10:10     ` Dr. David Alan Gilbert
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 18/47] Move loadvm_handlers into MigrationIncomingState Dr. David Alan Gilbert (git)
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 19/47] Rework loadvm path for subloops Dr. David Alan Gilbert (git)
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 20/47] Add migration-capability boolean for postcopy-ram Dr. David Alan Gilbert (git)
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 21/47] Add wrappers and handlers for sending/receiving the postcopy-ram migration messages Dr. David Alan Gilbert (git)
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 22/47] MIG_CMD_PACKAGED: Send a packaged chunk of migration stream Dr. David Alan Gilbert (git)
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 23/47] migrate_init: Call from savevm Dr. David Alan Gilbert (git)
2015-04-14 17:03 ` Dr. David Alan Gilbert (git) [this message]
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 25/47] postcopy: OS support test Dr. David Alan Gilbert (git)
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 26/47] migrate_start_postcopy: Command to trigger transition to postcopy Dr. David Alan Gilbert (git)
2015-04-14 17:38   ` Eric Blake
2015-04-14 17:40     ` Dr. David Alan Gilbert
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 27/47] MIGRATION_STATUS_POSTCOPY_ACTIVE: Add new migration state Dr. David Alan Gilbert (git)
2015-04-14 17:40   ` Eric Blake
2015-04-14 18:00     ` Dr. David Alan Gilbert
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 28/47] Add qemu_savevm_state_complete_postcopy Dr. David Alan Gilbert (git)
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 29/47] Postcopy: Maintain sentmap and calculate discard Dr. David Alan Gilbert (git)
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 30/47] postcopy: Incoming initialisation Dr. David Alan Gilbert (git)
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 31/47] postcopy: ram_enable_notify to switch on userfault Dr. David Alan Gilbert (git)
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 32/47] Postcopy: Postcopy startup in migration thread Dr. David Alan Gilbert (git)
2015-04-14 17:03 ` [Qemu-devel] [PATCH v6 33/47] Postcopy end in migration_thread Dr. David Alan Gilbert (git)
2015-04-14 17:04 ` [Qemu-devel] [PATCH v6 34/47] Page request: Add MIG_RP_MSG_REQ_PAGES reverse command Dr. David Alan Gilbert (git)
2015-04-14 17:04 ` [Qemu-devel] [PATCH v6 35/47] Page request: Process incoming page request Dr. David Alan Gilbert (git)
2015-04-14 17:04 ` [Qemu-devel] [PATCH v6 36/47] Page request: Consume pages off the post-copy queue Dr. David Alan Gilbert (git)
2015-04-14 17:04 ` [Qemu-devel] [PATCH v6 37/47] postcopy_ram.c: place_page and helpers Dr. David Alan Gilbert (git)
2015-04-14 17:04 ` [Qemu-devel] [PATCH v6 38/47] Postcopy: Use helpers to map pages during migration Dr. David Alan Gilbert (git)
2015-04-14 17:04 ` [Qemu-devel] [PATCH v6 39/47] qemu_ram_block_from_host Dr. David Alan Gilbert (git)
2015-04-14 17:04 ` [Qemu-devel] [PATCH v6 40/47] Don't sync dirty bitmaps in postcopy Dr. David Alan Gilbert (git)
2015-04-14 17:04 ` [Qemu-devel] [PATCH v6 41/47] Host page!=target page: Cleanup bitmaps Dr. David Alan Gilbert (git)
2015-04-14 17:04 ` [Qemu-devel] [PATCH v6 42/47] Postcopy; Handle userfault requests Dr. David Alan Gilbert (git)
2015-05-25  9:18   ` zhanghailiang
2015-05-26  9:50     ` Dr. David Alan Gilbert
2015-04-14 17:04 ` [Qemu-devel] [PATCH v6 43/47] Start up a postcopy/listener thread ready for incoming page data Dr. David Alan Gilbert (git)
2015-04-14 17:04 ` [Qemu-devel] [PATCH v6 44/47] postcopy: Wire up loadvm_postcopy_handle_ commands Dr. David Alan Gilbert (git)
2015-04-14 17:04 ` [Qemu-devel] [PATCH v6 45/47] End of migration for postcopy Dr. David Alan Gilbert (git)
2015-04-14 17:04 ` [Qemu-devel] [PATCH v6 46/47] Disable mlock around incoming postcopy Dr. David Alan Gilbert (git)
2015-04-14 17:04 ` [Qemu-devel] [PATCH v6 47/47] Inhibit ballooning during postcopy Dr. David Alan Gilbert (git)
2015-04-27  8:04 ` [Qemu-devel] [PATCH v6 00/47] Postcopy implementation Li, Liang Z
2015-04-29 17:23   ` Dr. David Alan Gilbert
2015-04-30  1:09     ` Li, Liang Z
     [not found]       ` <20150505150112.GM2126@work-vm>
     [not found]         ` <F2CBF3009FA73547804AE4C663CAB28E50F0E1@shsmsx102.ccr.corp.intel.com>
     [not found]           ` <20150506083056.GB2204@work-vm>
2015-05-07  1:21             ` Li, Liang Z
2015-05-07  8:01               ` Dr. David Alan Gilbert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1429031053-4454-25-git-send-email-dgilbert@redhat.com \
    --to=dgilbert@redhat.com \
    --cc=aarcange@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=yamahata@private.email.ne.jp \
    --cc=yayanghy@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.