From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org, borntraeger@de.ibm.com,
quintela@redhat.com, lvivier@redhat.com, peterx@redhat.com
Subject: [Qemu-devel] [PATCH 1/2] Postcopy: Force allocation of all-zero precopy pages
Date: Wed, 26 Apr 2017 19:37:20 +0100 [thread overview]
Message-ID: <20170426183721.7482-2-dgilbert@redhat.com> (raw)
In-Reply-To: <20170426183721.7482-1-dgilbert@redhat.com>
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
When an all-zero page is received during the precopy
phase of a postcopy-enabled migration we must force
allocation otherwise accesses to the page will still
get blocked by userfault.
Symptom:
a) If the page is accessed by a device during device-load
then we get a deadlock as the source finishes sending
all its pages but the destination device-load is still
paused and so doesn't clean up.
b) If the page is accessed later, then the thread will stay
paused until the end of migration rather than carrying on
running, until we release userfault at the end.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
include/migration/migration.h | 3 ++-
migration/ram.c | 12 ++++++++----
migration/rdma.c | 2 +-
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/include/migration/migration.h b/include/migration/migration.h
index ba1a16cbc1..b47904033c 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -265,7 +265,8 @@ uint64_t xbzrle_mig_pages_overflow(void);
uint64_t xbzrle_mig_pages_cache_miss(void);
double xbzrle_mig_cache_miss_rate(void);
-void ram_handle_compressed(void *host, uint8_t ch, uint64_t size);
+void ram_handle_compressed(void *host, uint8_t ch, uint64_t size,
+ bool always_write);
void ram_debug_dump_bitmap(unsigned long *todump, bool expected);
/* For outgoing discard bitmap */
int ram_postcopy_send_discard_bitmap(MigrationState *ms);
diff --git a/migration/ram.c b/migration/ram.c
index f48664ec62..b4ed41c725 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2274,10 +2274,12 @@ static inline void *host_from_ram_block_offset(RAMBlock *block,
* @host: host address for the zero page
* @ch: what the page is filled from. We only support zero
* @size: size of the zero page
+ * @always_write: Always perform the memset even if it's zero
*/
-void ram_handle_compressed(void *host, uint8_t ch, uint64_t size)
+void ram_handle_compressed(void *host, uint8_t ch, uint64_t size,
+ bool always_write)
{
- if (ch != 0 || !is_zero_range(host, size)) {
+ if (ch != 0 || always_write || !is_zero_range(host, size)) {
memset(host, ch, size);
}
}
@@ -2514,7 +2516,8 @@ static int ram_load_postcopy(QEMUFile *f)
switch (flags & ~RAM_SAVE_FLAG_CONTINUE) {
case RAM_SAVE_FLAG_COMPRESS:
ch = qemu_get_byte(f);
- memset(page_buffer, ch, TARGET_PAGE_SIZE);
+ ram_handle_compressed(page_buffer, ch, TARGET_PAGE_SIZE,
+ true);
if (ch) {
all_zero = false;
}
@@ -2664,7 +2667,8 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
case RAM_SAVE_FLAG_COMPRESS:
ch = qemu_get_byte(f);
- ram_handle_compressed(host, ch, TARGET_PAGE_SIZE);
+ ram_handle_compressed(host, ch, TARGET_PAGE_SIZE,
+ postcopy_advised);
break;
case RAM_SAVE_FLAG_PAGE:
diff --git a/migration/rdma.c b/migration/rdma.c
index fe0a4b5a83..07a9bd75d8 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -3164,7 +3164,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f, void *opaque)
host_addr = block->local_host_addr +
(comp->offset - block->offset);
- ram_handle_compressed(host_addr, comp->value, comp->length);
+ ram_handle_compressed(host_addr, comp->value, comp->length, false);
break;
case RDMA_CONTROL_REGISTER_FINISHED:
--
2.12.2
next prev parent reply other threads:[~2017-04-26 18:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-26 18:37 [Qemu-devel] [PATCH 0/2] Postcopy fix and traces Dr. David Alan Gilbert (git)
2017-04-26 18:37 ` Dr. David Alan Gilbert (git) [this message]
2017-04-26 19:00 ` [Qemu-devel] [PATCH 1/2] Postcopy: Force allocation of all-zero precopy pages Christian Borntraeger
2017-04-26 19:04 ` Dr. David Alan Gilbert
2017-04-26 19:37 ` Andrea Arcangeli
2017-04-27 3:20 ` Peter Xu
2017-04-27 6:44 ` Christian Borntraeger
2017-04-27 13:47 ` Andrea Arcangeli
2017-04-28 13:19 ` Christian Borntraeger
2017-04-28 14:24 ` Dr. David Alan Gilbert
2017-04-26 19:52 ` Christian Borntraeger
2017-04-26 19:54 ` Christian Borntraeger
2017-04-26 19:35 ` Juan Quintela
2017-04-27 8:03 ` Dr. David Alan Gilbert
2017-04-26 18:37 ` [Qemu-devel] [PATCH 2/2] migration: Extra tracing Dr. David Alan Gilbert (git)
2017-04-26 18:48 ` Christian Borntraeger
2017-05-02 13:17 ` Philippe Mathieu-Daudé
2017-05-04 8:40 ` Juan Quintela
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=20170426183721.7482-2-dgilbert@redhat.com \
--to=dgilbert@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=lvivier@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.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 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).