[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 55/57] Disable mlock around incoming postcopy
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PULL 55/57] Disable mlock around incoming postcopy |
Date: |
Mon, 9 Nov 2015 18:28:59 +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>
Reviewed-by: Amit Shah <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
Signed-off-by: Juan Quintela <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 05d1982..f992494 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -172,6 +172,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 8e107fe..1a24b09 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -87,6 +87,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();
@@ -115,6 +120,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.
@@ -294,6 +308,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(POSTCOPY_INCOMING_END);
migrate_send_rp_shut(mis, qemu_file_get_error(mis->from_src_file) != 0);
--
2.5.0
- [Qemu-devel] [PULL 41/57] Page request: Process incoming page request, (continued)
- [Qemu-devel] [PULL 41/57] Page request: Process incoming page request, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 47/57] Don't iterate on precopy-only devices during postcopy, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 45/57] postcopy: Check order of received target pages, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 52/57] postcopy: Wire up loadvm_postcopy_handle_ commands, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 54/57] End of migration for postcopy, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 50/57] Postcopy; Handle userfault requests, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 53/57] Postcopy: Mark nohugepage before discard, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 48/57] Host page!=target page: Cleanup bitmaps, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 51/57] Start up a postcopy/listener thread ready for incoming page data, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 57/57] migration: qemu_savevm_state_cleanup becomes mandatory operation, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 55/57] Disable mlock around incoming postcopy,
Juan Quintela <=
- [Qemu-devel] [PULL 56/57] Inhibit ballooning during postcopy, Juan Quintela, 2015/11/09
- Re: [Qemu-devel] [PULL 00/57] Migration pull, Peter Maydell, 2015/11/09
- Re: [Qemu-devel] [PULL 00/57] Migration pull, Peter Maydell, 2015/11/09