[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v8 13/54] Move dirty page search state into separate
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [PATCH v8 13/54] Move dirty page search state into separate structure |
Date: |
Tue, 29 Sep 2015 09:37:37 +0100 |
From: "Dr. David Alan Gilbert" <address@hidden>
Pull the search state for one iteration of the dirty page
search into a structure.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
Reviewed-by: Amit Shah <address@hidden>
---
migration/ram.c | 55 +++++++++++++++++++++++++++++++++++--------------------
1 file changed, 35 insertions(+), 20 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index 1c9d1da..04e895c 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -227,6 +227,17 @@ static uint64_t migration_dirty_pages;
static uint32_t last_version;
static bool ram_bulk_stage;
+/* used by the search for pages to send */
+struct PageSearchStatus {
+ /* Current block being searched */
+ RAMBlock *block;
+ /* Current offset to search from */
+ ram_addr_t offset;
+ /* Set once we wrap around */
+ bool complete_round;
+};
+typedef struct PageSearchStatus PageSearchStatus;
+
struct CompressParam {
bool start;
bool done;
@@ -531,7 +542,6 @@ static void migration_bitmap_sync_range(ram_addr_t start,
ram_addr_t length)
cpu_physical_memory_sync_dirty_bitmap(bitmap, start, length);
}
-
/* Fix me: there are too many global variables used in migration process. */
static int64_t start_time;
static int64_t bytes_xfer_prev;
@@ -923,26 +933,30 @@ static int ram_save_compressed_page(QEMUFile *f, RAMBlock
*block,
static int ram_find_and_save_block(QEMUFile *f, bool last_stage,
uint64_t *bytes_transferred)
{
- RAMBlock *block = last_seen_block;
- ram_addr_t offset = last_offset;
- bool complete_round = false;
+ PageSearchStatus pss;
int pages = 0;
- if (!block)
- block = QLIST_FIRST_RCU(&ram_list.blocks);
+ pss.block = last_seen_block;
+ pss.offset = last_offset;
+ pss.complete_round = false;
+
+ if (!pss.block) {
+ pss.block = QLIST_FIRST_RCU(&ram_list.blocks);
+ }
while (true) {
- offset = migration_bitmap_find_and_reset_dirty(block, offset);
- if (complete_round && block == last_seen_block &&
- offset >= last_offset) {
+ pss.offset = migration_bitmap_find_and_reset_dirty(pss.block,
+ pss.offset);
+ if (pss.complete_round && pss.block == last_seen_block &&
+ pss.offset >= last_offset) {
break;
}
- if (offset >= block->used_length) {
- offset = 0;
- block = QLIST_NEXT_RCU(block, next);
- if (!block) {
- block = QLIST_FIRST_RCU(&ram_list.blocks);
- complete_round = true;
+ if (pss.offset >= pss.block->used_length) {
+ pss.offset = 0;
+ pss.block = QLIST_NEXT_RCU(pss.block, next);
+ if (!pss.block) {
+ pss.block = QLIST_FIRST_RCU(&ram_list.blocks);
+ pss.complete_round = true;
ram_bulk_stage = false;
if (migrate_use_xbzrle()) {
/* If xbzrle is on, stop using the data compression at this
@@ -954,23 +968,24 @@ static int ram_find_and_save_block(QEMUFile *f, bool
last_stage,
}
} else {
if (compression_switch && migrate_use_compression()) {
- pages = ram_save_compressed_page(f, block, offset, last_stage,
+ pages = ram_save_compressed_page(f, pss.block, pss.offset,
+ last_stage,
bytes_transferred);
} else {
- pages = ram_save_page(f, block, offset, last_stage,
+ pages = ram_save_page(f, pss.block, pss.offset, last_stage,
bytes_transferred);
}
/* if page is unmodified, continue to the next */
if (pages > 0) {
- last_sent_block = block;
+ last_sent_block = pss.block;
break;
}
}
}
- last_seen_block = block;
- last_offset = offset;
+ last_seen_block = pss.block;
+ last_offset = pss.offset;
return pages;
}
--
2.5.0
- Re: [Qemu-devel] [PATCH v8 06/54] Rename mis->file to from_src_file, (continued)
- [Qemu-devel] [PATCH v8 05/54] qemu_ram_block_from_host, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 07/54] Add qemu_get_buffer_in_place to avoid copies some of the time, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 08/54] Add wrapper for setting blocking status on a QEMUFile, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 09/54] Add QEMU_MADV_NOHUGEPAGE, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 10/54] migration/ram.c: Use RAMBlock rather than MemoryRegion, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 11/54] ram_debug_dump_bitmap: Dump a migration bitmap as text, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 12/54] migrate_init: Call from savevm, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 13/54] Move dirty page search state into separate structure,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [PATCH v8 14/54] ram_find_and_save_block: Split out the finding, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 15/54] Rename save_live_complete to save_live_complete_precopy, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 17/54] Return path: socket_writev_buffer: Block even on non-blocking fd's, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 16/54] Return path: Open a return path on QEMUFile for sockets, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 18/54] Migration commands, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 19/54] Return path: Control commands, Dr. David Alan Gilbert (git), 2015/10/01