rcu: do not let RCU callbacks pile up indefinitely

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>
This commit is contained in:
Paolo Bonzini 2015-02-11 15:51:54 +01:00
parent 444c7e0d92
commit a7d1d63679
1 changed files with 8 additions and 6 deletions

View File

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