From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNQFU-00014e-HZ for qemu-devel@nongnu.org; Mon, 16 Feb 2015 13:18:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YNQFT-0001Mx-Ov for qemu-devel@nongnu.org; Mon, 16 Feb 2015 13:18:24 -0500 Received: from mail-wg0-x22e.google.com ([2a00:1450:400c:c00::22e]:33051) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNQFT-0001Mo-JF for qemu-devel@nongnu.org; Mon, 16 Feb 2015 13:18:23 -0500 Received: by mail-wg0-f46.google.com with SMTP id a1so30917474wgh.5 for ; Mon, 16 Feb 2015 10:18:23 -0800 (PST) Received: from playground.station (net-93-66-73-217.cust.vodafonedsl.it. [93.66.73.217]) by mx.google.com with ESMTPSA id p6sm20746248wia.14.2015.02.16.10.18.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Feb 2015 10:18:22 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 16 Feb 2015 19:17:48 +0100 Message-Id: <1424110682-14334-8-git-send-email-pbonzini@redhat.com> In-Reply-To: <1424110682-14334-1-git-send-email-pbonzini@redhat.com> References: <1424110682-14334-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 07/21] rcu: do not let RCU callbacks pile up indefinitely List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 Tested-by: Michael Roth Signed-off-by: Paolo Bonzini --- util/rcu.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/util/rcu.c b/util/rcu.c index c9c3e6e..486d7b6 100644 --- a/util/rcu.c +++ b/util/rcu.c @@ -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); -- 2.3.0