From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48596) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhK3x-0001vF-HF for qemu-devel@nongnu.org; Wed, 30 Sep 2015 12:17:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZhK3t-0005zu-AO for qemu-devel@nongnu.org; Wed, 30 Sep 2015 12:17:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33348) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhK3t-0005zp-5u for qemu-devel@nongnu.org; Wed, 30 Sep 2015 12:16:57 -0400 From: Juan Quintela In-Reply-To: <1443440518-4384-1-git-send-email-den@openvz.org> (Denis V. Lunev's message of "Mon, 28 Sep 2015 14:41:58 +0300") References: <1443440518-4384-1-git-send-email-den@openvz.org> Date: Wed, 30 Sep 2015 18:16:54 +0200 Message-ID: <87612ryj9l.fsf@neno.neno> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 1/1] migration: fix deadlock Reply-To: quintela@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Denis V. Lunev" Cc: Amit Shah , Paolo Bonzini , qemu-devel@nongnu.org, Anna Melekhova "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 Reviewed-by: Juan Quintela Appliefd to my tree. PD, no I still don't understood how RCU gave us so many corner cases wrong.