From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60682) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsdOJ-00062f-Kz for qemu-devel@nongnu.org; Fri, 28 Jun 2013 14:27:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UsdOH-0000Pw-FJ for qemu-devel@nongnu.org; Fri, 28 Jun 2013 14:27:27 -0400 Received: from mail-ee0-x235.google.com ([2a00:1450:4013:c00::235]:62477) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsdOH-0000Pk-88 for qemu-devel@nongnu.org; Fri, 28 Jun 2013 14:27:25 -0400 Received: by mail-ee0-f53.google.com with SMTP id c41so1193934eek.26 for ; Fri, 28 Jun 2013 11:27:24 -0700 (PDT) Received: from playground.lan (net-37-116-217-184.cust.dsl.vodafone.it. [37.116.217.184]) by mx.google.com with ESMTPSA id o5sm12035344eef.5.2013.06.28.11.27.22 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 28 Jun 2013 11:27:23 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 28 Jun 2013 20:26:33 +0200 Message-Id: <1372444009-11544-15-git-send-email-pbonzini@redhat.com> In-Reply-To: <1372444009-11544-1-git-send-email-pbonzini@redhat.com> References: <1372444009-11544-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 14/30] event loop: report RCU quiescent states List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Threads that run event loops also have places that can sleep for an extended time. Place an extended quiescent state there. Signed-off-by: Paolo Bonzini --- aio-posix.c | 8 ++++++++ aio-win32.c | 11 ++++++++++- main-loop.c | 6 ++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/aio-posix.c b/aio-posix.c index b68eccd..a57b276 100644 --- a/aio-posix.c +++ b/aio-posix.c @@ -17,6 +17,7 @@ #include "block/block.h" #include "qemu/queue.h" #include "qemu/sockets.h" +#include "qemu/rcu.h" struct AioHandler { @@ -175,6 +176,7 @@ bool aio_poll(AioContext *ctx, bool blocking) int ret; bool busy, progress; + rcu_quiescent_state(); progress = false; /* @@ -232,9 +234,15 @@ bool aio_poll(AioContext *ctx, bool blocking) } /* wait until next event */ + if (blocking) { + rcu_thread_offline(); + } ret = g_poll((GPollFD *)ctx->pollfds->data, ctx->pollfds->len, blocking ? -1 : 0); + if (blocking) { + rcu_thread_online(); + } /* if we have any readable fds, dispatch event */ if (ret > 0) { diff --git a/aio-win32.c b/aio-win32.c index 38723bf..9652afb 100644 --- a/aio-win32.c +++ b/aio-win32.c @@ -19,6 +19,7 @@ #include "block/block.h" #include "qemu/queue.h" #include "qemu/sockets.h" +#include "qemu/rcu.h" struct AioHandler { EventNotifier *e; @@ -99,6 +100,7 @@ bool aio_poll(AioContext *ctx, bool blocking) bool busy, progress; int count; + rcu_quiescent_state(); progress = false; /* @@ -175,7 +177,14 @@ bool aio_poll(AioContext *ctx, bool blocking) /* wait until next event */ while (count > 0) { int timeout = blocking ? INFINITE : 0; - int ret = WaitForMultipleObjects(count, events, FALSE, timeout); + + if (timeout) { + rcu_thread_offline(); + } + ret = WaitForMultipleObjects(count, events, FALSE, timeout); + if (timeout) { + rcu_thread_online(); + } /* if we have any signaled events, dispatch event */ if ((DWORD) (ret - WAIT_OBJECT_0) >= count) { diff --git a/main-loop.c b/main-loop.c index a44fff6..166357f 100644 --- a/main-loop.c +++ b/main-loop.c @@ -28,6 +28,7 @@ #include "slirp/libslirp.h" #include "qemu/main-loop.h" #include "block/aio.h" +#include "qemu/rcu.h" #ifndef _WIN32 @@ -220,13 +221,16 @@ static int os_host_main_loop_wait(uint32_t timeout) if (timeout > 0) { spin_counter = 0; qemu_mutex_unlock_iothread(); + rcu_thread_offline(); } else { spin_counter++; + rcu_quiescent_state(); } ret = g_poll((GPollFD *)gpollfds->data, gpollfds->len, timeout); if (timeout > 0) { + rcu_thread_online(); qemu_mutex_lock_iothread(); } @@ -424,7 +428,9 @@ static int os_host_main_loop_wait(uint32_t timeout) } qemu_mutex_unlock_iothread(); + rcu_thread_offline(); g_poll_ret = g_poll(poll_fds, n_poll_fds + w->num, poll_timeout); + rcu_thread_online(); qemu_mutex_lock_iothread(); if (g_poll_ret > 0) { for (i = 0; i < w->num; i++) { -- 1.8.1.4