Received: from eggs.gnu.org ([2001:4830:134:3::10]:46765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhVeS-00007t-SG for qemu-devel@nongnu.org; Wed, 07 Sep 2016 01:44:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhVeO-0005Se-MK for qemu-devel@nongnu.org; Wed, 07 Sep 2016 01:43:59 -0400 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:35226) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhVeO-0005Sa-FB for qemu-devel@nongnu.org; Wed, 07 Sep 2016 01:43:56 -0400 Received: by mail-wm0-x229.google.com with SMTP id i204so67146920wma.0 for ; Tue, 06 Sep 2016 22:43:56 -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: Date: Wed, 7 Sep 2016 07:43:53 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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 , "Michael S. Tsirkin" , claudio.fontana@huawei.com, Peter Crosthwaite , mark.burton@greensocs.com, jan.kiszka@siemens.com, serge.fdrv@gmail.com 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? > (2) If there's a good reason why not, then perhaps > > if (mr->global_locking) { > qemu_mutex_lock_iothread(); > do_something; > qemu_mutex_unlock_iothread(); > } else { > do_something; > } I went with the other one because the arguments to memory_region_dispatch_read are relatively many, but this can work too if Alex prefers it. Paolo