From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 11/15] lock: introduce global lock for device tree Date: Thu, 09 Aug 2012 09:41:26 +0200 Message-ID: <502369A6.9070600@redhat.com> References: <1344407156-25562-1-git-send-email-qemulist@gmail.com> <1344407156-25562-12-git-send-email-qemulist@gmail.com> <5022345A.5090805@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Anthony Liguori , Avi Kivity , Jan Kiszka , Marcelo Tosatti , Stefan Hajnoczi , Blue Swirl , =?ISO-8859-1?Q?Andreas_F=E4rber?= To: liu ping fan Return-path: Received: from mail-pb0-f46.google.com ([209.85.160.46]:40840 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755651Ab2HIHld (ORCPT ); Thu, 9 Aug 2012 03:41:33 -0400 Received: by pbbrr13 with SMTP id rr13so484240pbb.19 for ; Thu, 09 Aug 2012 00:41:33 -0700 (PDT) In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: Il 09/08/2012 09:28, liu ping fan ha scritto: > On Wed, Aug 8, 2012 at 5:41 PM, Paolo Bonzini wrote: >> Il 08/08/2012 08:25, Liu Ping Fan ha scritto: >>> From: Liu Ping Fan >>> >>> Signed-off-by: Liu Ping Fan >>> --- >>> cpus.c | 12 ++++++++++++ >>> main-loop.h | 3 +++ >>> 2 files changed, 15 insertions(+), 0 deletions(-) >>> >>> diff --git a/cpus.c b/cpus.c >>> index b182b3d..a734b36 100644 >>> --- a/cpus.c >>> +++ b/cpus.c >>> @@ -611,6 +611,7 @@ static void qemu_tcg_init_cpu_signals(void) >>> } >>> #endif /* _WIN32 */ >>> >>> +QemuMutex qemu_device_tree_mutex; >>> QemuMutex qemu_global_mutex; >>> static QemuCond qemu_io_proceeded_cond; >>> static bool iothread_requesting_mutex; >>> @@ -634,6 +635,7 @@ void qemu_init_cpu_loop(void) >>> qemu_cond_init(&qemu_work_cond); >>> qemu_cond_init(&qemu_io_proceeded_cond); >>> qemu_mutex_init(&qemu_global_mutex); >>> + qemu_mutex_init(&qemu_device_tree_mutex); >>> >>> qemu_thread_get_self(&io_thread); >>> } >>> @@ -911,6 +913,16 @@ void qemu_mutex_unlock_iothread(void) >>> qemu_mutex_unlock(&qemu_global_mutex); >>> } >>> >>> +void qemu_lock_devtree(void) >>> +{ >>> + qemu_mutex_lock(&qemu_device_tree_mutex); >>> +} >>> + >>> +void qemu_unlock_devtree(void) >>> +{ >>> + qemu_mutex_unlock(&qemu_device_tree_mutex); >>> +} >> >> We don't need the wrappers. They are there for the big lock just >> because TCG needs extra work for iothread_requesting_mutex. >> > Sorry, could you give more detail about TCG, what is extra work. void qemu_mutex_lock_iothread(void) { if (!tcg_enabled()) { qemu_mutex_lock(&qemu_global_mutex); } else { iothread_requesting_mutex = true; if (qemu_mutex_trylock(&qemu_global_mutex)) { qemu_cpu_kick_thread(first_cpu); qemu_mutex_lock(&qemu_global_mutex); } iothread_requesting_mutex = false; qemu_cond_broadcast(&qemu_io_proceeded_cond); } } You do not need any of the code in the "else" branch for the device tree mutex, so you do not need wrappers. From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzNN9-0002NL-58 for qemu-devel@nongnu.org; Thu, 09 Aug 2012 03:41:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzNN8-0004VQ-4L for qemu-devel@nongnu.org; Thu, 09 Aug 2012 03:41:35 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:54079) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzNN7-0004VJ-UH for qemu-devel@nongnu.org; Thu, 09 Aug 2012 03:41:34 -0400 Received: by pbbrp12 with SMTP id rp12so453272pbb.4 for ; Thu, 09 Aug 2012 00:41:33 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <502369A6.9070600@redhat.com> Date: Thu, 09 Aug 2012 09:41:26 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1344407156-25562-1-git-send-email-qemulist@gmail.com> <1344407156-25562-12-git-send-email-qemulist@gmail.com> <5022345A.5090805@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 11/15] lock: introduce global lock for device tree List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: liu ping fan Cc: kvm@vger.kernel.org, Jan Kiszka , Marcelo Tosatti , qemu-devel@nongnu.org, Blue Swirl , Avi Kivity , Anthony Liguori , Stefan Hajnoczi , =?ISO-8859-1?Q?Andreas_F=E4rber?= Il 09/08/2012 09:28, liu ping fan ha scritto: > On Wed, Aug 8, 2012 at 5:41 PM, Paolo Bonzini wrote: >> Il 08/08/2012 08:25, Liu Ping Fan ha scritto: >>> From: Liu Ping Fan >>> >>> Signed-off-by: Liu Ping Fan >>> --- >>> cpus.c | 12 ++++++++++++ >>> main-loop.h | 3 +++ >>> 2 files changed, 15 insertions(+), 0 deletions(-) >>> >>> diff --git a/cpus.c b/cpus.c >>> index b182b3d..a734b36 100644 >>> --- a/cpus.c >>> +++ b/cpus.c >>> @@ -611,6 +611,7 @@ static void qemu_tcg_init_cpu_signals(void) >>> } >>> #endif /* _WIN32 */ >>> >>> +QemuMutex qemu_device_tree_mutex; >>> QemuMutex qemu_global_mutex; >>> static QemuCond qemu_io_proceeded_cond; >>> static bool iothread_requesting_mutex; >>> @@ -634,6 +635,7 @@ void qemu_init_cpu_loop(void) >>> qemu_cond_init(&qemu_work_cond); >>> qemu_cond_init(&qemu_io_proceeded_cond); >>> qemu_mutex_init(&qemu_global_mutex); >>> + qemu_mutex_init(&qemu_device_tree_mutex); >>> >>> qemu_thread_get_self(&io_thread); >>> } >>> @@ -911,6 +913,16 @@ void qemu_mutex_unlock_iothread(void) >>> qemu_mutex_unlock(&qemu_global_mutex); >>> } >>> >>> +void qemu_lock_devtree(void) >>> +{ >>> + qemu_mutex_lock(&qemu_device_tree_mutex); >>> +} >>> + >>> +void qemu_unlock_devtree(void) >>> +{ >>> + qemu_mutex_unlock(&qemu_device_tree_mutex); >>> +} >> >> We don't need the wrappers. They are there for the big lock just >> because TCG needs extra work for iothread_requesting_mutex. >> > Sorry, could you give more detail about TCG, what is extra work. void qemu_mutex_lock_iothread(void) { if (!tcg_enabled()) { qemu_mutex_lock(&qemu_global_mutex); } else { iothread_requesting_mutex = true; if (qemu_mutex_trylock(&qemu_global_mutex)) { qemu_cpu_kick_thread(first_cpu); qemu_mutex_lock(&qemu_global_mutex); } iothread_requesting_mutex = false; qemu_cond_broadcast(&qemu_io_proceeded_cond); } } You do not need any of the code in the "else" branch for the device tree mutex, so you do not need wrappers.