[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 39/41] postcopy/outgoing: implement prefault
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH v2 39/41] postcopy/outgoing: implement prefault |
Date: |
Mon, 4 Jun 2012 18:57:41 +0900 |
When page is requested, send surrounding pages are also sent.
Signed-off-by: Isaku Yamahata <address@hidden>
---
migration-postcopy.c | 56 +++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 51 insertions(+), 5 deletions(-)
diff --git a/migration-postcopy.c b/migration-postcopy.c
index eb37094..6165657 100644
--- a/migration-postcopy.c
+++ b/migration-postcopy.c
@@ -353,6 +353,36 @@ int postcopy_outgoing_ram_save_live(QEMUFile *f, int
stage, void *opaque)
return ret;
}
+static void postcopy_outgoing_ram_save_page(PostcopyOutgoingState *s,
+ uint64_t pgoffset, bool *written,
+ bool forward,
+ int prefault_pgoffset)
+{
+ ram_addr_t offset;
+ int ret;
+
+ if (forward) {
+ pgoffset += prefault_pgoffset;
+ } else {
+ if (pgoffset < prefault_pgoffset) {
+ return;
+ }
+ pgoffset -= prefault_pgoffset;
+ }
+
+ offset = pgoffset << TARGET_PAGE_BITS;
+ if (offset >= s->last_block_read->length) {
+ assert(forward);
+ assert(prefault_pgoffset > 0);
+ return;
+ }
+
+ ret = ram_save_page(s->mig_buffered_write, s->last_block_read, offset);
+ if (ret > 0) {
+ *written = true;
+ }
+}
+
/*
* return value
* 0: continue postcopy mode
@@ -364,6 +394,7 @@ static int
postcopy_outgoing_handle_req(PostcopyOutgoingState *s,
bool *written)
{
int i;
+ uint64_t j;
RAMBlock *block;
DPRINTF("cmd %d state %d\n", req->cmd, s->state);
@@ -398,11 +429,26 @@ static int
postcopy_outgoing_handle_req(PostcopyOutgoingState *s,
break;
}
for (i = 0; i < req->nr; i++) {
- DPRINTF("offs[%d] 0x%"PRIx64"\n", i, req->pgoffs[i]);
- int ret = ram_save_page(s->mig_buffered_write, s->last_block_read,
- req->pgoffs[i] << TARGET_PAGE_BITS);
- if (ret > 0) {
- *written = true;
+ DPRINTF("pgoffs[%d] 0x%"PRIx64"\n", i, req->pgoffs[i]);
+ postcopy_outgoing_ram_save_page(s, req->pgoffs[i], written,
+ true, 0);
+ }
+ /* forward prefault */
+ for (j = 1; j <= s->ms->params.prefault_forward; j++) {
+ for (i = 0; i < req->nr; i++) {
+ DPRINTF("pgoffs[%d] + 0x%"PRIx64" 0x%"PRIx64"\n",
+ i, j, req->pgoffs[i] + j);
+ postcopy_outgoing_ram_save_page(s, req->pgoffs[i], written,
+ true, j);
+ }
+ }
+ /* backward prefault */
+ for (j = 1; j <= s->ms->params.prefault_backward; j++) {
+ for (i = 0; i < req->nr; i++) {
+ DPRINTF("pgoffs[%d] - 0x%"PRIx64" 0x%"PRIx64"\n",
+ i, j, req->pgoffs[i] - j);
+ postcopy_outgoing_ram_save_page(s, req->pgoffs[i], written,
+ false, j);
}
}
break;
--
1.7.1.1
- [Qemu-devel] [PATCH v2 23/41] migration.c: remove redundant line in migrate_init(), (continued)
- [Qemu-devel] [PATCH v2 23/41] migration.c: remove redundant line in migrate_init(), Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 29/41] umem.h: import Linux umem.h, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 19/41] savevm/QEMUFile: drop qemu_stdio_fd, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 32/41] savevm: add new section that is used by postcopy, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 15/41] savevm: export qemu_peek_buffer, qemu_peek_byte, qemu_file_skip, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 25/41] migration: factor out parameters into MigrationParams, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 30/41] update-linux-headers.sh: teach umem.h to update-linux-headers.sh, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 38/41] postcopy/outgoing: add forward, backward option to specify the size of prefault, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 10/41] arch_init: simplify a bit by ram_find_block(), Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 34/41] postcopy outgoing: add -p and -n option to migrate command, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 39/41] postcopy/outgoing: implement prefault,
Isaku Yamahata <=
- [Qemu-devel] [PATCH v2 26/41] buffered_file: factor out buffer management logic, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 14/41] exec.c: export last_ram_offset(), Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 08/41] arch_init/ram_load: refactor ram_load, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 28/41] buffered_file: add qemu_file to read/write to buffer in memory, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 33/41] postcopy: introduce -postcopy and -postcopy-flags option, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 12/41] arch_init: factor out setting last_block, last_offset, Isaku Yamahata, 2012/06/04
- [Qemu-devel] [PATCH v2 36/41] postcopy: implement incoming part of postcopy live migration, Isaku Yamahata, 2012/06/04