[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 22/42] migration: run setup callbacks out of big loc
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 22/42] migration: run setup callbacks out of big lock |
Date: |
Fri, 22 Feb 2013 17:36:28 +0100 |
Only the migration_bitmap_sync() call needs the iothread lock.
Reviewed-by: Orit Wasserman <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
arch_init.c | 10 ++++++----
block-migration.c | 2 ++
include/migration/vmstate.h | 2 +-
migration.c | 2 --
savevm.c | 3 +++
5 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/arch_init.c b/arch_init.c
index 32b4378..6089c53 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -570,10 +570,6 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
bitmap_set(migration_bitmap, 0, ram_pages);
migration_dirty_pages = ram_pages;
- qemu_mutex_lock_ramlist();
- bytes_transferred = 0;
- reset_ram_globals();
-
if (migrate_use_xbzrle()) {
XBZRLE.cache = cache_init(migrate_xbzrle_cache_size() /
TARGET_PAGE_SIZE,
@@ -587,8 +583,14 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
acct_clear();
}
+ qemu_mutex_lock_iothread();
+ qemu_mutex_lock_ramlist();
+ bytes_transferred = 0;
+ reset_ram_globals();
+
memory_global_dirty_log_start();
migration_bitmap_sync();
+ qemu_mutex_unlock_iothread();
qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE);
diff --git a/block-migration.c b/block-migration.c
index 8da5f86..2fd7699 100644
--- a/block-migration.c
+++ b/block-migration.c
@@ -583,10 +583,12 @@ static int block_save_setup(QEMUFile *f, void *opaque)
DPRINTF("Enter save live setup submitted %d transferred %d\n",
block_mig_state.submitted, block_mig_state.transferred);
+ qemu_mutex_lock_iothread();
init_blk_migration(f);
/* start track dirty blocks */
set_dirty_tracking(1);
+ qemu_mutex_unlock_iothread();
ret = flush_blks(f);
blk_mig_reset_dirty_cursor();
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 5f803f5..abc3b47 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -34,7 +34,6 @@ typedef struct SaveVMHandlers {
void (*set_params)(const MigrationParams *params, void * opaque);
SaveStateHandler *save_state;
- int (*save_live_setup)(QEMUFile *f, void *opaque);
void (*cancel)(void *opaque);
int (*save_live_complete)(QEMUFile *f, void *opaque);
@@ -49,6 +48,7 @@ typedef struct SaveVMHandlers {
int (*save_live_iterate)(QEMUFile *f, void *opaque);
/* This runs outside the iothread lock! */
+ int (*save_live_setup)(QEMUFile *f, void *opaque);
uint64_t (*save_live_pending)(QEMUFile *f, void *opaque, uint64_t
max_size);
LoadStateHandler *load_state;
diff --git a/migration.c b/migration.c
index 92a7152..e64c92d 100644
--- a/migration.c
+++ b/migration.c
@@ -660,10 +660,8 @@ static void *buffered_file_thread(void *opaque)
bool old_vm_running = false;
bool last_round = false;
- qemu_mutex_lock_iothread();
DPRINTF("beginning savevm\n");
qemu_savevm_state_begin(s->file, &s->params);
- qemu_mutex_unlock_iothread();
while (s->state == MIG_STATE_ACTIVE) {
int64_t current_time;
diff --git a/savevm.c b/savevm.c
index e10a045..7c7774e 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1768,7 +1768,10 @@ static int qemu_savevm_state(QEMUFile *f)
return -EINVAL;
}
+ qemu_mutex_unlock_iothread();
qemu_savevm_state_begin(f, ¶ms);
+ qemu_mutex_lock_iothread();
+
while (qemu_file_get_error(f) == 0) {
if (qemu_savevm_state_iterate(f) > 0) {
break;
--
1.8.1.2
- [Qemu-devel] [PATCH v2 00/42] Migration cleanups and latency improvements, Paolo Bonzini, 2013/02/22
- [Qemu-devel] [PATCH 01/42] migration: simplify while loop, Paolo Bonzini, 2013/02/22
- [Qemu-devel] [PATCH 04/42] migration: push qemu_savevm_state_cancel out of qemu_savevm_state_*, Paolo Bonzini, 2013/02/22
- [Qemu-devel] [PATCH 02/42] migration: always use vm_stop_force_state, Paolo Bonzini, 2013/02/22
- [Qemu-devel] [PATCH 08/42] qemu-file: temporarily expose qemu_file_set_error and qemu_fflush, Paolo Bonzini, 2013/02/22
- [Qemu-devel] [PATCH 03/42] migration: move more error handling to migrate_fd_cleanup, Paolo Bonzini, 2013/02/22
- [Qemu-devel] [PATCH 11/42] migration: simplify error handling, Paolo Bonzini, 2013/02/22
- [Qemu-devel] [PATCH 09/42] migration: flush all data to fd when buffered_flush is called, Paolo Bonzini, 2013/02/22
- [Qemu-devel] [PATCH 18/42] block-migration: document usage of state across threads, Paolo Bonzini, 2013/02/22
- [Qemu-devel] [PATCH 20/42] migration: reorder SaveVMHandlers members, Paolo Bonzini, 2013/02/22
- [Qemu-devel] [PATCH 22/42] migration: run setup callbacks out of big lock,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 21/42] migration: run pending/iterate callbacks out of big lock, Paolo Bonzini, 2013/02/22
- [Qemu-devel] [PATCH 24/42] Rename buffered_ to migration_, Paolo Bonzini, 2013/02/22
- [Qemu-devel] [PATCH 23/42] migration: yay, buffering is gone, Paolo Bonzini, 2013/02/22
- [Qemu-devel] [PATCH 25/42] qemu-file: make qemu_fflush and qemu_file_set_error private again, Paolo Bonzini, 2013/02/22
- [Qemu-devel] [PATCH 27/42] migration: detect error before sleeping, Paolo Bonzini, 2013/02/22
- [Qemu-devel] [PATCH 28/42] migration: remove useless qemu_file_get_error check, Paolo Bonzini, 2013/02/22
- [Qemu-devel] [PATCH 26/42] migration: eliminate last_round, Paolo Bonzini, 2013/02/22
- [Qemu-devel] [PATCH 39/42] migration: move rate limiting to QEMUFile, Paolo Bonzini, 2013/02/22
- [Qemu-devel] [PATCH 40/42] migration: move contents of migration_close to migrate_fd_cleanup, Paolo Bonzini, 2013/02/22
- [Qemu-devel] [PATCH 42/42] migration: inline migrate_fd_close, Paolo Bonzini, 2013/02/22