]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
rcu: do not let RCU callbacks pile up indefinitely
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 11 Feb 2015 14:51:54 +0000 (15:51 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 11 Feb 2015 20:48:37 +0000 (21:48 +0100)
Always process them within a short time.  Even though waiting a little
is useful, it is not okay to delay e.g. qemu_opts_del forever.

Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Tested-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
util/rcu.c

index c9c3e6e4abe9153c8d8bff15f5ec287cea9d43ee..486d7b6cc2ee2f741c9d2761a77097bc95c7d95d 100644 (file)
@@ -223,14 +223,16 @@ static void *call_rcu_thread(void *opaque)
          * Fetch rcu_call_count now, we only must process elements that were
          * added before synchronize_rcu() starts.
          */
-        while (n < RCU_CALL_MIN_SIZE && ++tries <= 5) {
-            g_usleep(100000);
-            qemu_event_reset(&rcu_call_ready_event);
-            n = atomic_read(&rcu_call_count);
-            if (n < RCU_CALL_MIN_SIZE) {
-                qemu_event_wait(&rcu_call_ready_event);
+        while (n == 0 || (n < RCU_CALL_MIN_SIZE && ++tries <= 5)) {
+            g_usleep(10000);
+            if (n == 0) {
+                qemu_event_reset(&rcu_call_ready_event);
                 n = atomic_read(&rcu_call_count);
+                if (n == 0) {
+                    qemu_event_wait(&rcu_call_ready_event);
+                }
             }
+            n = atomic_read(&rcu_call_count);
         }
 
         atomic_sub(&rcu_call_count, n);