qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC 05/29] postcopy: use UFFDIO_ZEROPAGE only when availab


From: Dr. David Alan Gilbert (git)
Subject: [Qemu-devel] [RFC 05/29] postcopy: use UFFDIO_ZEROPAGE only when available
Date: Wed, 28 Jun 2017 20:00:23 +0100

From: "Dr. David Alan Gilbert" <address@hidden>

Use the recently added migration flag to hold whether
each RAMBlock has the UFFDIO_ZEROPAGE capability, use it
when it's available.

This allows the use of postcopy on tmpfs as well as hugepage
backed files.

Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
 migration/migration.h    |  4 ++++
 migration/postcopy-ram.c | 12 +++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/migration/migration.h b/migration/migration.h
index d9a268a3af..d109635d08 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -20,6 +20,10 @@
 #include "exec/cpu-common.h"
 #include "qemu/coroutine_int.h"
 
+/* Migration flags to be set using qemu_ram_set_migration_flags */
+/* Postcopy can atomically zero pages in this RAMBlock */
+#define QEMU_MIGFLAG_POSTCOPY_ZERO   0x00000001
+
 /* State for the incoming migration */
 struct MigrationIncomingState {
     QEMUFile *from_src_file;
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index be2a8f8e02..96338a8070 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -408,6 +408,12 @@ static int ram_block_enable_notify(const char *block_name, 
void *host_addr,
         error_report("%s userfault: Region doesn't support COPY", __func__);
         return -1;
     }
+    if (reg_struct.ioctls & ((__u64)1 << _UFFDIO_ZEROPAGE)) {
+        RAMBlock *rb = qemu_ram_block_by_name(block_name);
+        qemu_ram_set_migration_flags(rb, qemu_ram_get_migration_flags(rb) |
+                                         QEMU_MIGFLAG_POSTCOPY_ZERO);
+    }
+
 
     return 0;
 }
@@ -620,11 +626,11 @@ int postcopy_place_page(MigrationIncomingState *mis, void 
*host, void *from,
 int postcopy_place_page_zero(MigrationIncomingState *mis, void *host,
                              RAMBlock *rb)
 {
+    size_t pagesize = qemu_ram_pagesize(rb);
     trace_postcopy_place_page_zero(host);
 
-    if (qemu_ram_pagesize(rb) == getpagesize()) {
-        if (qemu_ufd_copy_ioctl(mis->userfault_fd, host, NULL, getpagesize(),
-                                rb)) {
+    if (qemu_ram_get_migration_flags(rb) & QEMU_MIGFLAG_POSTCOPY_ZERO) {
+        if (qemu_ufd_copy_ioctl(mis->userfault_fd, host, NULL, pagesize, rb)) {
             int e = errno;
             error_report("%s: %s zero host: %p",
                          __func__, strerror(e), host);
-- 
2.13.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]