From nobody Sun Feb 8 22:14:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534670372476655.7394279983121; Sun, 19 Aug 2018 02:19:32 -0700 (PDT) Received: from localhost ([::1]:42150 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frJrv-0006i9-Au for importer@patchew.org; Sun, 19 Aug 2018 05:19:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frJmS-0002NC-9b for qemu-devel@nongnu.org; Sun, 19 Aug 2018 05:13:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frJmP-0000dg-NV for qemu-devel@nongnu.org; Sun, 19 Aug 2018 05:13:52 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:33277) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1frJmP-0000cN-77; Sun, 19 Aug 2018 05:13:49 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 8993C21B6D; Sun, 19 Aug 2018 05:13:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 19 Aug 2018 05:13:48 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 0F2B11028B; Sun, 19 Aug 2018 05:13:47 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=mesmtp; bh=4IvA+m+UPvTXWN wYYKgKuCSUY6hJ5BbEJ2V6CqtJWA4=; b=NBSfR8Bl5PnGd8ZOp8qJQhDOPooZNQ 8PStgEV5BjyfhzgXQw+QVRSwNZ1p6fcim16Cy1Sr1dIsds5stBwt7Vt5j8Q2GbPF BMD5VMst2pi1LS4GoCGjn8iyXnFy828AFvsLHKlWdSJpnTBSd1djXEZ2vD1yALnR mdOMECDaxaKDs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=4IvA+m+UPvTXWNwYYKgKuCSUY6hJ5BbEJ2V6CqtJWA4=; b=oKRkaHaY tYlJ+D8clz/SpexU8nYAxSOxSKfVYG0NDpTtdD9JO1iFhF722wLmfkBDqsV+o7Ur EFRSfAPZeqFkamPjM7k7PWs89u9/+D0j4Tn2IFpKNGAtEzhTPfvk5Dloo85amG2l SfWG372sFZ9U9U8OfFXv3TuvY+YEDvo55wLKwL8th0/zOLAIvYH449wS79elJkO1 PN/9HYnHJ2ueC3acEnk1UuSCMt/P6/9zb1Q3hllVhNG66ZmMq1ZcyqtW4Whsk1Ae 1tD5O7VK/Fn+NZ6Sx07lls1A7lvMRYOh2WeL1RxY2uDRG5mEv9KcSTKDoay2//zO GcjcVpIdNd09aw== X-ME-Proxy: X-ME-Sender: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 19 Aug 2018 05:13:30 -0400 Message-Id: <20180819091335.22863-7-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180819091335.22863-1-cota@braap.org> References: <20180819091335.22863-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.25 Subject: [Qemu-devel] [PATCH v2 06/11] test-rcu-list: access counters with atomics X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Crosthwaite , Riku Voipio , Alexander Graf , Laurent Vivier , qemu-ppc@nongnu.org, Paolo Bonzini , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Emilio G. Cota --- tests/test-rcu-list.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/test-rcu-list.c b/tests/test-rcu-list.c index b4ed130081..dc58091996 100644 --- a/tests/test-rcu-list.c +++ b/tests/test-rcu-list.c @@ -93,7 +93,7 @@ static void reclaim_list_el(struct rcu_head *prcu) struct list_element *el =3D container_of(prcu, struct list_element, rc= u); g_free(el); /* Accessed only from call_rcu thread. */ - n_reclaims++; + atomic_set(&n_reclaims, n_reclaims + 1); } =20 static QLIST_HEAD(q_list_head, list_element) Q_list_head; @@ -182,7 +182,7 @@ static void *rcu_q_updater(void *arg) qemu_mutex_lock(&counts_mutex); n_nodes +=3D n_nodes_local; n_updates +=3D n_updates_local; - n_nodes_removed +=3D n_removed_local; + atomic_set(&n_nodes_removed, n_nodes_removed + n_removed_local); qemu_mutex_unlock(&counts_mutex); return NULL; } @@ -239,16 +239,18 @@ static void rcu_qtest(const char *test, int duration,= int nreaders) n_nodes_removed +=3D n_removed_local; qemu_mutex_unlock(&counts_mutex); synchronize_rcu(); - while (n_nodes_removed > n_reclaims) { + while (atomic_read(&n_nodes_removed) > atomic_read(&n_reclaims)) { g_usleep(100); synchronize_rcu(); } if (g_test_in_charge) { - g_assert_cmpint(n_nodes_removed, =3D=3D, n_reclaims); + g_assert_cmpint(atomic_read(&n_nodes_removed), =3D=3D, + atomic_read(&n_reclaims)); } else { printf("%s: %d readers; 1 updater; nodes read: " \ "%lld, nodes removed: %lld; nodes reclaimed: %lld\n", - test, nthreadsrunning - 1, n_reads, n_nodes_removed, n_recl= aims); + test, nthreadsrunning - 1, n_reads, + atomic_read(&n_nodes_removed), atomic_read(&n_reclaims)); exit(0); } } --=20 2.17.1