From 5b82b703b69acc67b78b98a5efc897a3912719eb Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Mon, 25 Jan 2016 13:33:20 +0000 Subject: memory: RCU ram_list.dirty_memory[] for safe RAM hotplug Although accesses to ram_list.dirty_memory[] use atomics so multiple threads can safely dirty the bitmap, the data structure is not fully thread-safe yet. This patch handles the RAM hotplug case where ram_list.dirty_memory[] is grown. ram_list.dirty_memory[] is change from a regular bitmap to an RCU array of pointers to fixed-size bitmap blocks. Threads can continue accessing bitmap blocks while the array is being extended. See the comments in the code for an in-depth explanation of struct DirtyMemoryBlocks. I have tested that live migration with virtio-blk dataplane works. Signed-off-by: Stefan Hajnoczi Message-Id: <1453728801-5398-2-git-send-email-stefanha@redhat.com> Signed-off-by: Paolo Bonzini --- migration/ram.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'migration/ram.c') diff --git a/migration/ram.c b/migration/ram.c index 3cdfea4..96c749f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -609,7 +609,6 @@ static void migration_bitmap_sync_init(void) iterations_prev = 0; } -/* Called with iothread lock held, to protect ram_list.dirty_memory[] */ static void migration_bitmap_sync(void) { RAMBlock *block; @@ -1921,8 +1920,6 @@ static int ram_save_setup(QEMUFile *f, void *opaque) acct_clear(); } - /* iothread lock needed for ram_list.dirty_memory[] */ - qemu_mutex_lock_iothread(); qemu_mutex_lock_ramlist(); rcu_read_lock(); bytes_transferred = 0; @@ -1947,7 +1944,6 @@ static int ram_save_setup(QEMUFile *f, void *opaque) memory_global_dirty_log_start(); migration_bitmap_sync(); qemu_mutex_unlock_ramlist(); - qemu_mutex_unlock_iothread(); qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE); -- cgit v1.1