[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 46/47] Disable mlock around incoming postcopy
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [PATCH v6 46/47] Disable mlock around incoming postcopy |
Date: |
Tue, 14 Apr 2015 18:04:12 +0100 |
From: "Dr. David Alan Gilbert" <address@hidden>
Userfault doesn't work with mlock; mlock is designed to nail down pages
so they don't move, userfault is designed to tell you when they're not
there.
munlock the pages we userfault protect before postcopy.
mlock everything again at the end if mlock is enabled.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
Reviewed-by: David Gibson <address@hidden>
---
include/sysemu/sysemu.h | 1 +
migration/postcopy-ram.c | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 248f0d6..d6fca99 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -171,6 +171,7 @@ extern int boot_menu;
extern bool boot_strict;
extern uint8_t *boot_splash_filedata;
extern size_t boot_splash_filedata_size;
+extern bool enable_mlock;
extern uint8_t qemu_extra_params_fw[2];
extern QEMUClockType rtc_clock;
extern const char *mem_path;
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index b2dc3b7..ddf0841 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -84,6 +84,11 @@ static bool ufd_version_check(int ufd)
return true;
}
+/*
+ * Note: This has the side effect of munlock'ing all of RAM, that's
+ * normally fine since if the postcopy succeeds it gets turned back on at the
+ * end.
+ */
bool postcopy_ram_supported_by_host(void)
{
long pagesize = getpagesize();
@@ -112,6 +117,15 @@ bool postcopy_ram_supported_by_host(void)
}
/*
+ * userfault and mlock don't go together; we'll put it back later if
+ * it was enabled.
+ */
+ if (munlockall()) {
+ error_report("%s: munlockall: %s", __func__, strerror(errno));
+ return -1;
+ }
+
+ /*
* We need to check that the ops we need are supported on anon memory
* To do that we need to register a chunk and see the flags that
* are returned.
@@ -302,6 +316,16 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState
*mis)
mis->have_fault_thread = false;
}
+ if (enable_mlock) {
+ if (os_mlock() < 0) {
+ error_report("mlock: %s", strerror(errno));
+ /*
+ * It doesn't feel right to fail at this point, we have a valid
+ * VM state.
+ */
+ }
+ }
+
postcopy_state_set(mis, POSTCOPY_INCOMING_END);
migrate_send_rp_shut(mis, qemu_file_get_error(mis->file) != 0);
--
2.1.0
- [Qemu-devel] [PATCH v6 36/47] Page request: Consume pages off the post-copy queue, (continued)
- [Qemu-devel] [PATCH v6 36/47] Page request: Consume pages off the post-copy queue, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 34/47] Page request: Add MIG_RP_MSG_REQ_PAGES reverse command, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 38/47] Postcopy: Use helpers to map pages during migration, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 40/47] Don't sync dirty bitmaps in postcopy, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 39/47] qemu_ram_block_from_host, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 37/47] postcopy_ram.c: place_page and helpers, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 41/47] Host page!=target page: Cleanup bitmaps, Dr. David Alan Gilbert (git), 2015/04/14
- [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
- [Qemu-devel] [PATCH v6 31/47] postcopy: ram_enable_notify to switch on userfault, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 42/47] Postcopy; Handle userfault requests, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 46/47] Disable mlock around incoming postcopy,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [PATCH v6 45/47] End of migration for postcopy, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 44/47] postcopy: Wire up loadvm_postcopy_handle_ commands, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 47/47] Inhibit ballooning during postcopy, Dr. David Alan Gilbert (git), 2015/04/14
- Re: [Qemu-devel] [PATCH v6 00/47] Postcopy implementation, Li, Liang Z, 2015/04/27