From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1agS-0006Ju-22 for qemu-devel@nongnu.org; Wed, 25 Nov 2015 09:04:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1agO-0001la-QC for qemu-devel@nongnu.org; Wed, 25 Nov 2015 09:04:31 -0500 Received: from mail.sysgo.com ([176.9.12.79]:45192) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1agO-0001lS-Km for qemu-devel@nongnu.org; Wed, 25 Nov 2015 09:04:28 -0500 References: <565485A0.5090902@sysgo.com> <5654883F.9050509@redhat.com> <56557AA2.9080100@sysgo.com> <5655AA1F.8060906@sysgo.com> <5655B706.6060306@redhat.com> From: David Engraf Message-ID: <5655BFEA.50407@sysgo.com> Date: Wed, 25 Nov 2015 15:04:26 +0100 MIME-Version: 1.0 In-Reply-To: <5655B706.6060306@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] qemu_mutex_iothread_locked not correctly synchronized List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Cc: Fam Zheng Am 25.11.2015 um 14:26 schrieb Paolo Bonzini: > > > On 25/11/2015 13:31, David Engraf wrote: >> Hi Paolo, >> >> please check the new version. I removed changing the iothread_locked >> variable. But I still need to set the correct value of iothread_locked >> when using qemu_cond_wait. > > No, you don't. Who is reading iothread_locked during > qemu_cond_wait_iothread? No one, because it is a thread-local variable > whose address is never taken. prepare_mmio_access is reading iothread_locked by using qemu_mutex_iothread_locked after qemu_tcg_wait_io_event calls qemu_cond_wait. All one the same thread. qemu_tcg_cpu_thread_fn -> qemu_tcg_wait_io_event -> qemu_cond_wait acquires the mutex qemu_tcg_cpu_thread_fn -> tcg_exec_all -> tcg_cpu_exec -> cpu_exec -> cpu_exec ends up in calling prepare_mmio_access David