From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhU5V-0000bt-Sm for qemu-devel@nongnu.org; Wed, 07 Sep 2016 00:03:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhU5R-0004K8-MQ for qemu-devel@nongnu.org; Wed, 07 Sep 2016 00:03:48 -0400 Received: from mail-pa0-x235.google.com ([2607:f8b0:400e:c03::235]:35246) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhU5R-0004K2-FF for qemu-devel@nongnu.org; Wed, 07 Sep 2016 00:03:45 -0400 Received: by mail-pa0-x235.google.com with SMTP id b2so1762830pat.2 for ; Tue, 06 Sep 2016 21:03:45 -0700 (PDT) Sender: Richard Henderson References: <1470929064-4092-1-git-send-email-alex.bennee@linaro.org> <1470929064-4092-17-git-send-email-alex.bennee@linaro.org> From: Richard Henderson Message-ID: Date: Tue, 6 Sep 2016 21:03:42 -0700 MIME-Version: 1.0 In-Reply-To: <1470929064-4092-17-git-send-email-alex.bennee@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed 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: =?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, claudio.fontana@huawei.com, Peter Crosthwaite , jan.kiszka@siemens.com, "Michael S. Tsirkin" , mark.burton@greensocs.com, Eduardo Habkost , serge.fdrv@gmail.com, pbonzini@redhat.com On 08/11/2016 08:24 AM, Alex Bennée 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? (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; } is a better pattern to use. r~