[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 08/16] postcopy: Use temporary for placing zero h
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [PATCH v3 08/16] postcopy: Use temporary for placing zero huge pages |
Date: |
Fri, 24 Feb 2017 18:28:36 +0000 |
From: "Dr. David Alan Gilbert" <address@hidden>
The kernel can't do UFFDIO_ZEROPAGE for huge pages, so we have
to allocate a temporary (always zero) page and use UFFDIO_COPYPAGE
on it.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
Reviewed-by: Laurent Vivier <address@hidden>
---
include/migration/migration.h | 1 +
migration/postcopy-ram.c | 23 +++++++++++++++++++++--
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/include/migration/migration.h b/include/migration/migration.h
index e8e2a7f..cbfe79c 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -108,6 +108,7 @@ struct MigrationIncomingState {
QEMUFile *to_src_file;
QemuMutex rp_mutex; /* We send replies from multiple threads */
void *postcopy_tmp_page;
+ void *postcopy_tmp_zero_page;
QEMUBH *bh;
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index a8b7fed..4c736d2 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -324,6 +324,10 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState
*mis)
munmap(mis->postcopy_tmp_page, mis->largest_page_size);
mis->postcopy_tmp_page = NULL;
}
+ if (mis->postcopy_tmp_zero_page) {
+ munmap(mis->postcopy_tmp_zero_page, mis->largest_page_size);
+ mis->postcopy_tmp_zero_page = NULL;
+ }
trace_postcopy_ram_incoming_cleanup_exit();
return 0;
}
@@ -593,8 +597,23 @@ int postcopy_place_page_zero(MigrationIncomingState *mis,
void *host,
return -e;
}
} else {
- /* TODO: The kernel can't use UFFDIO_ZEROPAGE for hugepages */
- assert(0);
+ /* The kernel can't use UFFDIO_ZEROPAGE for hugepages */
+ if (!mis->postcopy_tmp_zero_page) {
+ mis->postcopy_tmp_zero_page = mmap(NULL, mis->largest_page_size,
+ PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS,
+ -1, 0);
+ if (mis->postcopy_tmp_zero_page == MAP_FAILED) {
+ int e = errno;
+ mis->postcopy_tmp_zero_page = NULL;
+ error_report("%s: %s mapping large zero page",
+ __func__, strerror(e));
+ return -e;
+ }
+ memset(mis->postcopy_tmp_zero_page, '\0', mis->largest_page_size);
+ }
+ return postcopy_place_page(mis, host, mis->postcopy_tmp_zero_page,
+ pagesize);
}
return 0;
--
2.9.3
- [Qemu-devel] [PATCH v3 00/16] Postcopy: Hugepage support, Dr. David Alan Gilbert (git), 2017/02/24
- [Qemu-devel] [PATCH v3 02/16] postcopy: Transmit and compare individual page sizes, Dr. David Alan Gilbert (git), 2017/02/24
- [Qemu-devel] [PATCH v3 01/16] postcopy: Transmit ram size summary word, Dr. David Alan Gilbert (git), 2017/02/24
- [Qemu-devel] [PATCH v3 03/16] postcopy: Chunk discards for hugepages, Dr. David Alan Gilbert (git), 2017/02/24
- [Qemu-devel] [PATCH v3 04/16] exec: ram_block_discard_range, Dr. David Alan Gilbert (git), 2017/02/24
- [Qemu-devel] [PATCH v3 06/16] postcopy: Record largest page size, Dr. David Alan Gilbert (git), 2017/02/24
- [Qemu-devel] [PATCH v3 08/16] postcopy: Use temporary for placing zero huge pages,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [PATCH v3 05/16] postcopy: enhance ram_block_discard_range for hugepages, Dr. David Alan Gilbert (git), 2017/02/24
- [Qemu-devel] [PATCH v3 07/16] postcopy: Plumb pagesize down into place helpers, Dr. David Alan Gilbert (git), 2017/02/24
- [Qemu-devel] [PATCH v3 10/16] postcopy: Mask fault addresses to huge page boundary, Dr. David Alan Gilbert (git), 2017/02/24
- [Qemu-devel] [PATCH v3 09/16] postcopy: Load huge pages in one go, Dr. David Alan Gilbert (git), 2017/02/24
- [Qemu-devel] [PATCH v3 12/16] postcopy: Allow hugepages, Dr. David Alan Gilbert (git), 2017/02/24
- [Qemu-devel] [PATCH v3 11/16] postcopy: Send whole huge pages, Dr. David Alan Gilbert (git), 2017/02/24
- [Qemu-devel] [PATCH v3 14/16] postcopy: Check for userfault+hugepage feature, Dr. David Alan Gilbert (git), 2017/02/24
- [Qemu-devel] [PATCH v3 13/16] postcopy: Update userfaultfd.h header, Dr. David Alan Gilbert (git), 2017/02/24
- [Qemu-devel] [PATCH v3 15/16] postcopy: Add doc about hugepages and postcopy, Dr. David Alan Gilbert (git), 2017/02/24
- [Qemu-devel] [PATCH v3 16/16] postcopy: Add extra check for COPY function, Dr. David Alan Gilbert (git), 2017/02/24