qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Mike Day <ncmike@ncultra.org>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [RFC PATCH 09/14] event loop: report RCU quiescent states
Date: Wed, 14 Aug 2013 11:50:45 -0400	[thread overview]
Message-ID: <1376495450-5133-10-git-send-email-ncmike@ncultra.org> (raw)
In-Reply-To: <1376495450-5133-1-git-send-email-ncmike@ncultra.org>

From: Paolo Bonzini <pbonzini@redhat.com>

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 <pbonzini@redhat.com>
Reviewed-by: Mike Day <ncmike@ncultra.org>
---
 aio-posix.c | 9 ++++++++-
 aio-win32.c | 7 +++++++
 main-loop.c | 7 ++++++-
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/aio-posix.c b/aio-posix.c
index b68eccd..562add6 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,10 +233,16 @@ 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) {
         QLIST_FOREACH(node, &ctx->aio_handlers, node) {
diff --git a/aio-win32.c b/aio-win32.c
index 38723bf..8a6abb0 100644
--- a/aio-win32.c
+++ b/aio-win32.c
@@ -175,7 +175,14 @@ bool aio_poll(AioContext *ctx, bool blocking)
     /* wait until next event */
     while (count > 0) {
         int timeout = blocking ? INFINITE : 0;
+        
+        if (timeout) {
+            rcu_thread_offline();
+        }
         int 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..79f43da 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -27,6 +27,7 @@
 #include "qemu/sockets.h"	// struct in_addr needed for libslirp.h
 #include "slirp/libslirp.h"
 #include "qemu/main-loop.h"
+#include "qemu/rcu.h"
 #include "block/aio.h"
 
 #ifndef _WIN32
@@ -220,6 +221,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++;
     }
@@ -227,7 +229,8 @@ static int os_host_main_loop_wait(uint32_t timeout)
     ret = g_poll((GPollFD *)gpollfds->data, gpollfds->len, timeout);
 
     if (timeout > 0) {
-        qemu_mutex_lock_iothread();
+        rcu_thread_online();
+	qemu_mutex_lock_iothread();
     }
 
     glib_pollfds_poll();
@@ -424,7 +427,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.3.1

  parent reply	other threads:[~2013-08-14 15:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-14 15:50 [Qemu-devel] [RFC PATCH 00/14] RCU Implementation for Qemu Mike Day
2013-08-14 15:50 ` [Qemu-devel] [RFC PATCH 01/14] qemu-thread: add QemuEvent Mike Day
2013-08-14 15:50 ` [Qemu-devel] [RFC PATCH 02/14] rcu: add rcu library Mike Day
2013-08-14 15:50 ` [Qemu-devel] [RFC PATCH 03/14] fix #include directive for rcu header Mike Day
2013-08-14 15:50 ` [Qemu-devel] [RFC PATCH 04/14] qemu-thread: register threads with RCU Mike Day
2013-08-14 15:50 ` [Qemu-devel] [RFC PATCH 05/14] rcu: add call_rcu Mike Day
2013-08-14 15:50 ` [Qemu-devel] [RFC PATCH 06/14] rcu: add rcutorture Mike Day
2013-08-14 15:50 ` [Qemu-devel] [RFC PATCH 07/14] rcu: allow nested calls to rcu_thread_offline/rcu_thread_online Mike Day
2013-08-14 15:50 ` [Qemu-devel] [RFC PATCH 08/14] qemu-thread: report RCU quiescent states Mike Day
2013-08-14 15:50 ` Mike Day [this message]
2013-08-14 15:50 ` [Qemu-devel] [RFC PATCH 10/14] cpus: " Mike Day
2013-08-14 15:50 ` [Qemu-devel] [RFC PATCH 11/14] block: " Mike Day
2013-08-14 15:50 ` [Qemu-devel] [RFC PATCH 12/14] migration: " Mike Day
2013-08-14 15:50 ` [Qemu-devel] [PATCH 13/14] include osdep.h for definition of glue(a, b) Mike Day
2013-08-14 15:50 ` [Qemu-devel] [PATCH 14/14] fix pointer reference to rcu_assign_pointer Mike Day

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1376495450-5133-10-git-send-email-ncmike@ncultra.org \
    --to=ncmike@ncultra.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).