From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgnNQ-0004QH-K4 for qemu-devel@nongnu.org; Tue, 29 Sep 2015 01:22:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgnEG-0004gi-2Q for qemu-devel@nongnu.org; Tue, 29 Sep 2015 01:14:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35110) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgnEF-0004ge-QW for qemu-devel@nongnu.org; Tue, 29 Sep 2015 01:13:27 -0400 Date: Tue, 29 Sep 2015 10:43:23 +0530 From: Amit Shah Message-ID: <20150929051323.GA21612@grmbl.mre> References: <1443440518-4384-1-git-send-email-den@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1443440518-4384-1-git-send-email-den@openvz.org> Subject: Re: [Qemu-devel] [PATCH 1/1] migration: fix deadlock List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Denis V. Lunev" Cc: Paolo Bonzini , Juan Quintela , qemu-devel@nongnu.org, Anna Melekhova There have been multiple versions of this patch on the list, can you please annotate that this is v3 so it supersedes the earlier v2? Also, please include a changelog in the description in patch 0 so we know what happened between the various versions. Thanks, On (Mon) 28 Sep 2015 [14:41:58], Denis V. Lunev wrote: > Release qemu global mutex before call synchronize_rcu(). > synchronize_rcu() waiting for all readers to finish their critical > sections. There is at least one critical section in which we try > to get QGM (critical section is in address_space_rw() and > prepare_mmio_access() is trying to aquire QGM). > > Both functions (migration_end() and migration_bitmap_extend()) > are called from main thread which is holding QGM. > > Thus there is a race condition that ends up with deadlock: > main thread working thread > Lock QGA | > | Call KVM_EXIT_IO handler > | | > | Open rcu reader's critical section > Migration cleanup bh | > | | > synchronize_rcu() is | > waiting for readers | > | prepare_mmio_access() is waiting for QGM > \ / > deadlock > > The patch changes bitmap freeing from direct g_free after synchronize_rcu > to free inside call_rcu. > > Signed-off-by: Denis V. Lunev > Reported-by: Igor Redko > Tested-by: Igor Redko > CC: Anna Melekhova > CC: Juan Quintela > CC: Amit Shah > CC: Paolo Bonzini > CC: Wen Congyang > --- > migration/ram.c | 44 +++++++++++++++++++++++++++----------------- > 1 file changed, 27 insertions(+), 17 deletions(-) Amit