From patchwork Tue Feb 3 12:52:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 435893 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B1F37140187 for ; Tue, 3 Feb 2015 23:56:47 +1100 (AEDT) Received: from localhost ([::1]:59100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YId25-0004wi-V7 for incoming@patchwork.ozlabs.org; Tue, 03 Feb 2015 07:56:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIcyQ-0007au-JP for qemu-devel@nongnu.org; Tue, 03 Feb 2015 07:53:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YIcyH-0008C1-AP for qemu-devel@nongnu.org; Tue, 03 Feb 2015 07:52:58 -0500 Received: from mail-we0-x236.google.com ([2a00:1450:400c:c03::236]:53474) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIcyG-0008Bl-LQ for qemu-devel@nongnu.org; Tue, 03 Feb 2015 07:52:49 -0500 Received: by mail-we0-f182.google.com with SMTP id l61so44699638wev.13 for ; Tue, 03 Feb 2015 04:52:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=L5CbdHfQmMBPq93Z8C/wpdVm56jEEtqMWB6l17PwPnw=; b=U1smZHWr8NdQdep0E+f7Aa6Y4kmKb3xtom+VjwUaBtXOEixEDJAepBZHZQA1zrlIzi itymxFLxbBqTP7cZdm1sBk+DN5Neskmbhx7ix1GG9fIqDFOf2uFPX2akwNYIV4p+98CI bbYJlnlZUTXuNYN2Z1HIiL0rpskraGxvkzSns5SuqEEsGcfrkEFUN9G5pMVAM+j5C27v Wyji7iCfiLsqMshqxtpv0zlFuZuJrmQBZycb23qS8PvIUu0Fym3oJNHFNcMkF/7MGpGJ iMqkrZ15nAcNUGdEHTvrTjKtvsM1wQTbdBWcRb7dU0I0a1QgNzvrzrHJVOhxYlM/I1Xs 3rKA== X-Received: by 10.180.23.36 with SMTP id j4mr33591242wif.69.1422967968066; Tue, 03 Feb 2015 04:52:48 -0800 (PST) Received: from playground.station (net-93-66-105-136.cust.vodafonedsl.it. [93.66.105.136]) by mx.google.com with ESMTPSA id n6sm32516460wjy.8.2015.02.03.04.52.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Feb 2015 04:52:47 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 3 Feb 2015 13:52:26 +0100 Message-Id: <1422967948-3261-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1422967948-3261-1-git-send-email-pbonzini@redhat.com> References: <1422967948-3261-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::236 Cc: peter.maydell@linaro.org, famz@redhat.com, fred.konrad@greensocs.com Subject: [Qemu-devel] [PATCH 7/9] rcu: prod call_rcu thread when calling synchronize_rcu X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org call_rcu operates on the principle that either there is a steady stream of incoming RCU callbacks, or it is not worthwhile to wake up and process the few that are there. This however makes it hard to assert in testcases that all RCU callbacks are processed. To avoid this, make call_rcu also process callbacks if there is a steady stream of synchronize_rcu calls. This avoids deadlocks in the upcoming test-rcu-list unit test, which waits for call_rcu to reclaim all nodes that it allocates. Especially with very high load on the host, call_rcu decided to wait for a few more callbacks to pile up, but the test was done and was not going to produce more. Signed-off-by: Paolo Bonzini Reviewed-by: Fam Zheng --- util/rcu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/util/rcu.c b/util/rcu.c index c9c3e6e..aa9f639 100644 --- a/util/rcu.c +++ b/util/rcu.c @@ -48,6 +48,9 @@ unsigned long rcu_gp_ctr = RCU_GP_LOCKED; QemuEvent rcu_gp_event; static QemuMutex rcu_gp_lock; +static int rcu_call_count; +static QemuEvent rcu_call_ready_event; + /* * Check whether a quiescent state was crossed between the beginning of * update_counter_and_wait and now. @@ -149,6 +152,9 @@ void synchronize_rcu(void) } qemu_mutex_unlock(&rcu_gp_lock); + if (atomic_read(&rcu_call_count)) { + qemu_event_set(&rcu_call_ready_event); + } } @@ -159,8 +165,6 @@ void synchronize_rcu(void) */ static struct rcu_head dummy; static struct rcu_head *head = &dummy, **tail = &dummy.next; -static int rcu_call_count; -static QemuEvent rcu_call_ready_event; static void enqueue(struct rcu_head *node) {