From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfPix-0004Gs-32 for qemu-devel@nongnu.org; Fri, 25 Sep 2015 05:55:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfPis-0001oR-Sb for qemu-devel@nongnu.org; Fri, 25 Sep 2015 05:55:26 -0400 Received: from [59.151.112.132] (port=8736 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfPan-0007rI-Nd for qemu-devel@nongnu.org; Fri, 25 Sep 2015 05:47:02 -0400 References: <56050489.9010306@cn.fujitsu.com> <1443172180-1005-1-git-send-email-den@openvz.org> From: Wen Congyang Message-ID: <560517FB.9080909@cn.fujitsu.com> Date: Fri, 25 Sep 2015 17:46:35 +0800 MIME-Version: 1.0 In-Reply-To: <1443172180-1005-1-git-send-email-den@openvz.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 0/2] migration: fix deadlock List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Denis V. Lunev" Cc: Igor Redko , Juan Quintela , qemu-devel@nongnu.org, Anna Melekhova , Amit Shah , Paolo Bonzini On 09/25/2015 05:09 PM, 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 > > Patches here are quick and dirty, compile-tested only to validate the > architectual approach. > > Igor, Anna, can you pls start your tests with these patches instead of your > original one. Thank you. Can you give me the backtrace of the working thread? I think it is very bad to wait some lock in rcu reader's cirtical section. To Paolo: Do we allow this in rcu critical section? Thanks Wen Congyang > > Signed-off-by: Denis V. Lunev > CC: Igor Redko > CC: Anna Melekhova > CC: Juan Quintela > CC: Amit Shah > > Denis V. Lunev (2): > migration: bitmap_set is unnecessary as bitmap_new uses g_try_malloc0 > migration: fix deadlock > > migration/ram.c | 45 ++++++++++++++++++++++++++++----------------- > 1 file changed, 28 insertions(+), 17 deletions(-) >