Received: from eggs.gnu.org ([2001:4830:134:3::10]:43113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bheZw-00076b-Ue for qemu-devel@nongnu.org; Wed, 07 Sep 2016 11:15:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bheZs-0002ZL-M5 for qemu-devel@nongnu.org; Wed, 07 Sep 2016 11:15:55 -0400 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:36136) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bheZs-0002ZG-Fp for qemu-devel@nongnu.org; Wed, 07 Sep 2016 11:15:52 -0400 Received: by mail-wm0-x229.google.com with SMTP id b187so121547614wme.1 for ; Wed, 07 Sep 2016 08:15:52 -0700 (PDT) Sender: Paolo Bonzini References: <1470929064-4092-1-git-send-email-alex.bennee@linaro.org> <1470929064-4092-17-git-send-email-alex.bennee@linaro.org> From: Paolo Bonzini Message-ID: <40ba34f1-17e2-5590-fd0f-49b3b14d8919@redhat.com> Date: Wed, 7 Sep 2016 17:15:48 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC v4 16/28] tcg: drop global lock during TCG code execution List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson , =?UTF-8?Q?Alex_Benn=c3=a9e?= , mttcg@greensocs.com, qemu-devel@nongnu.org, fred.konrad@greensocs.com, a.rigo@virtualopensystems.com, cota@braap.org, bobby.prani@gmail.com, nikunj@linux.vnet.ibm.com Cc: peter.maydell@linaro.org, Eduardo Habkost , Peter Crosthwaite , claudio.fontana@huawei.com, "Michael S. Tsirkin" , mark.burton@greensocs.com, jan.kiszka@siemens.com, serge.fdrv@gmail.com On 07/09/2016 08:43, Richard Henderson wrote: > On 09/06/2016 10:43 PM, Paolo Bonzini wrote: >> >> >> On 07/09/2016 06:03, Richard Henderson wrote: >>> >>>> + if (mr->global_locking) { >>>> + qemu_mutex_lock_iothread(); >>>> + locked = true; >>>> + } >>>> memory_region_dispatch_read(mr, physaddr, &val, 1 << SHIFT, >>>> iotlbentry->attrs); >>>> + if (locked) { >>>> + qemu_mutex_unlock_iothread(); >>>> + } >>> >>> I'm not keen on this pattern. >>> >>> (1) Why not use recursive locks? >> >> Probably I'm biased by looking at this code too long, but... how would >> they help? > > You wouldn't check to see if the lock is already taken. But it's only using qemu_mutex_iothread_locked() at unlock time, when we exit from longjmp. Here it's looking at a MemoryRegion to see if the MMIO callbacks need the lock or not (since most of them do). Paolo