aboutsummaryrefslogtreecommitdiff
path: root/migration/ram.c
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2017-03-13 21:38:09 +0100
committerJuan Quintela <quintela@redhat.com>2017-04-21 12:25:37 +0200
commit108cfae0195fc51c007017a3a5ab49f4e3c3f781 (patch)
tree46fdd6a3836ea99e2fd054935041f75d621eea3f /migration/ram.c
parentceb4d16898549e5b7d9123b830907de8908fca9d (diff)
downloadqemu-108cfae0195fc51c007017a3a5ab49f4e3c3f781.zip
qemu-108cfae0195fc51c007017a3a5ab49f4e3c3f781.tar.gz
qemu-108cfae0195fc51c007017a3a5ab49f4e3c3f781.tar.bz2
ram: Move migration_bitmap_mutex into RAMState
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
Diffstat (limited to 'migration/ram.c')
-rw-r--r--migration/ram.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/migration/ram.c b/migration/ram.c
index 42bb82f..23819cd 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -185,6 +185,8 @@ struct RAMState {
uint64_t xbzrle_overflows;
/* number of dirty bits in the bitmap */
uint64_t migration_dirty_pages;
+ /* protects modification of the bitmap */
+ QemuMutex bitmap_mutex;
};
typedef struct RAMState RAMState;
@@ -230,8 +232,6 @@ static ram_addr_t ram_save_remaining(void)
return ram_state.migration_dirty_pages;
}
-static QemuMutex migration_bitmap_mutex;
-
/* used by the search for pages to send */
struct PageSearchStatus {
/* Current block being searched */
@@ -653,13 +653,13 @@ static void migration_bitmap_sync(RAMState *rs)
trace_migration_bitmap_sync_start();
memory_global_dirty_log_sync();
- qemu_mutex_lock(&migration_bitmap_mutex);
+ qemu_mutex_lock(&rs->bitmap_mutex);
rcu_read_lock();
QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
migration_bitmap_sync_range(rs, block->offset, block->used_length);
}
rcu_read_unlock();
- qemu_mutex_unlock(&migration_bitmap_mutex);
+ qemu_mutex_unlock(&rs->bitmap_mutex);
trace_migration_bitmap_sync_end(rs->num_dirty_pages_period);
@@ -1526,6 +1526,7 @@ static void ram_state_reset(RAMState *rs)
void migration_bitmap_extend(ram_addr_t old, ram_addr_t new)
{
RAMState *rs = &ram_state;
+
/* called in qemu main thread, so there is
* no writing race against this migration_bitmap
*/
@@ -1539,7 +1540,7 @@ void migration_bitmap_extend(ram_addr_t old, ram_addr_t new)
* it is safe to migration if migration_bitmap is cleared bit
* at the same time.
*/
- qemu_mutex_lock(&migration_bitmap_mutex);
+ qemu_mutex_lock(&rs->bitmap_mutex);
bitmap_copy(bitmap->bmap, old_bitmap->bmap, old);
bitmap_set(bitmap->bmap, old, new - old);
@@ -1550,7 +1551,7 @@ void migration_bitmap_extend(ram_addr_t old, ram_addr_t new)
bitmap->unsentmap = NULL;
atomic_rcu_set(&migration_bitmap_rcu, bitmap);
- qemu_mutex_unlock(&migration_bitmap_mutex);
+ qemu_mutex_unlock(&rs->bitmap_mutex);
rs->migration_dirty_pages += new - old;
call_rcu(old_bitmap, migration_bitmap_free, rcu);
}
@@ -1982,7 +1983,7 @@ static int ram_state_init(RAMState *rs)
int64_t ram_bitmap_pages; /* Size of bitmap in pages, including gaps */
memset(rs, 0, sizeof(*rs));
- qemu_mutex_init(&migration_bitmap_mutex);
+ qemu_mutex_init(&rs->bitmap_mutex);
if (migrate_use_xbzrle()) {
XBZRLE_cache_lock();