qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 09/12] event loop: report RCU quiescent states


From: Paolo Bonzini
Subject: [Qemu-devel] [PATCH 09/12] event loop: report RCU quiescent states
Date: Wed, 15 May 2013 17:48:54 +0200

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 <address@hidden>
---
 aio-posix.c |  7 +++++++
 aio-win32.c | 10 +++++++++-
 main-loop.c |  5 +++++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/aio-posix.c b/aio-posix.c
index b68eccd..4ab8f4b 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
 {
@@ -232,9 +233,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..f1e3f0c 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;
@@ -175,7 +176,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 f46aece..a048394 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -27,6 +27,7 @@
 #include "slirp/slirp.h"
 #include "qemu/main-loop.h"
 #include "block/aio.h"
+#include "qemu/rcu.h"
 
 #ifndef _WIN32
 
@@ -219,6 +220,7 @@ 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++;
     }
@@ -226,6 +228,7 @@ static int os_host_main_loop_wait(uint32_t timeout)
     ret = g_poll((GPollFD *)gpollfds->data, gpollfds->len, timeout);
 
     if (timeout > 0) {
+        rcu_thread_online();
         qemu_mutex_lock_iothread();
     }
 
@@ -409,7 +412,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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]