[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
- [Qemu-devel] [RFC 00/29] postcopy+vhost-user/shared ram, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 01/29] RAMBlock/migration: Add migration flags, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 02/29] migrate: Update ram_block_discard_range for shared, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 04/29] migration/ram: ramblock_recv_bitmap_test_byte_offset, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 03/29] qemu_ram_block_host_offset, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 05/29] postcopy: use UFFDIO_ZEROPAGE only when available,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [RFC 06/29] postcopy: Add notifier chain, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 07/29] postcopy: Add vhost-user flag for postcopy and check it, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 10/29] vhub: Open userfaultfd, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 09/29] vhub: Support sending fds back to qemu, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 08/29] vhost-user: Add 'VHOST_USER_POSTCOPY_ADVISE' message, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 11/29] postcopy: Allow registering of fd handler, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 12/29] vhost+postcopy: Register shared ufd with postcopy, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 13/29] vhost+postcopy: Transmit 'listen' to client, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 14/29] vhost+postcopy: Register new regions with the ufd, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 15/29] vhost+postcopy: Send address back to qemu, Dr. David Alan Gilbert (git), 2017/06/28