From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45022) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctVm5-0003R5-OG for qemu-devel@nongnu.org; Thu, 30 Mar 2017 04:49:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctVm2-0006KL-JE for qemu-devel@nongnu.org; Thu, 30 Mar 2017 04:49:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43466) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ctVm2-0006KE-AH for qemu-devel@nongnu.org; Thu, 30 Mar 2017 04:49:42 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EB0CB80478 for ; Thu, 30 Mar 2017 08:49:40 +0000 (UTC) Date: Thu, 30 Mar 2017 09:49:37 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20170330084936.GA2800@work-vm> References: <20170323204544.12015-1-quintela@redhat.com> <20170323204544.12015-25-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170323204544.12015-25-quintela@redhat.com> Subject: Re: [Qemu-devel] [PATCH 24/51] ram: Move migration_bitmap_mutex into RAMState List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: qemu-devel@nongnu.org * Juan Quintela (quintela@redhat.com) wrote: > Signed-off-by: Juan Quintela I'm still pretty convinced that there's an existing problem with this mutex can get init'd twice with no destroy on a second migration, however you're not changing that (and it's not actually failed as far as I can tell): Reviewed-by: Dr. David Alan Gilbert > --- > migration/ram.c | 15 ++++++++------- > 1 file changed, 8 insertions(+), 7 deletions(-) > > diff --git a/migration/ram.c b/migration/ram.c > index a890179..ae2b89f 100644 > --- a/migration/ram.c > +++ b/migration/ram.c > @@ -184,6 +184,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; > > @@ -229,8 +231,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 */ > @@ -652,13 +652,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); > > @@ -1524,6 +1524,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 > */ > @@ -1537,7 +1538,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); > > @@ -1548,7 +1549,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); > } > @@ -1980,7 +1981,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(); > -- > 2.9.3 > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK