From nobody Wed Nov 5 10:10:30 2025 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 1534670369965163.2424705470561; Sun, 19 Aug 2018 02:19:29 -0700 (PDT) Received: from localhost ([::1]:42148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frJrt-0006gP-0b for importer@patchew.org; Sun, 19 Aug 2018 05:19:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57181) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frJmS-0002NB-9M 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 1frJmO-0000cS-Rx for qemu-devel@nongnu.org; Sun, 19 Aug 2018 05:13:52 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:36889) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1frJmO-0000by-KO; Sun, 19 Aug 2018 05:13:48 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 2E68921B0B; 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 D9E2F1028A; Sun, 19 Aug 2018 05:13:46 -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=UWe7gbeHKPA7MQ OWnP7ye1WOnLzOpDb9QT2SVmI0Ruc=; b=DifJwtzVpRv8gBUL5entOZGYc8y0Um XM81FLBP7f45LY5yuyU9D1Kb+qDJTL4tj1bCC4qycrXECTfomwk1PwqvvQheyc1b QUhh3Yjx4PTt9IzH9r7JCjYIlbrkMEhzjvDL3pSohTGRUP0nA8ltmjhb8G1NxvZL ziglLn2Jx140M= 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=UWe7gbeHKPA7MQOWnP7ye1WOnLzOpDb9QT2SVmI0Ruc=; b=YF4+zsfL vNHvAMvTs/8bifCFpbNWyxl0aW1DMi0lT4F4pPqz5F0M2IVCU8toQwlRh+YYTSuM YFq8n+JBK8bNAAoWBzHRQoZgvQ1tb36FXm+RqzeVUbGhGuBGIkfPFC/2ilmPed31 McUYSvmpFvfQhSdq7Ne6q3xkIXIDbvRmtDP3sl2anmWbq9rZKtVAED1eX7Ezfg16 K2DaVfJvuHBnOuGnJITlvriqAVaRwW0KOUZGgCt/3+BLlPn2XiGt3R8nlegBqp+2 ++ERZbi/ibPy3ARKDA9M4WOshjA3guak2YdB3tCWDkiUA5czupNzxb3+eWX8K+Vb Fq/gtLm6xdc/9A== X-ME-Proxy: X-ME-Sender: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 19 Aug 2018 05:13:29 -0400 Message-Id: <20180819091335.22863-6-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 05/11] test-rcu-list: access goflag 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" Instead of declaring it volatile. Signed-off-by: Emilio G. Cota --- tests/test-rcu-list.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test-rcu-list.c b/tests/test-rcu-list.c index 1514d7ec97..b4ed130081 100644 --- a/tests/test-rcu-list.c +++ b/tests/test-rcu-list.c @@ -44,7 +44,7 @@ static int nthreadsrunning; #define GOFLAG_RUN 1 #define GOFLAG_STOP 2 =20 -static volatile int goflag =3D GOFLAG_INIT; +static int goflag =3D GOFLAG_INIT; =20 #define RCU_READ_RUN 1000 #define RCU_UPDATE_RUN 10 @@ -107,15 +107,15 @@ static void *rcu_q_reader(void *arg) =20 *(struct rcu_reader_data **)arg =3D &rcu_reader; atomic_inc(&nthreadsrunning); - while (goflag =3D=3D GOFLAG_INIT) { + while (atomic_read(&goflag) =3D=3D GOFLAG_INIT) { g_usleep(1000); } =20 - while (goflag =3D=3D GOFLAG_RUN) { + while (atomic_read(&goflag) =3D=3D GOFLAG_RUN) { rcu_read_lock(); QLIST_FOREACH_RCU(el, &Q_list_head, entry) { n_reads_local++; - if (goflag =3D=3D GOFLAG_STOP) { + if (atomic_read(&goflag) =3D=3D GOFLAG_STOP) { break; } } @@ -142,11 +142,11 @@ static void *rcu_q_updater(void *arg) =20 *(struct rcu_reader_data **)arg =3D &rcu_reader; atomic_inc(&nthreadsrunning); - while (goflag =3D=3D GOFLAG_INIT) { + while (atomic_read(&goflag) =3D=3D GOFLAG_INIT) { g_usleep(1000); } =20 - while (goflag =3D=3D GOFLAG_RUN) { + while (atomic_read(&goflag) =3D=3D GOFLAG_RUN) { target_el =3D select_random_el(RCU_Q_LEN); j =3D 0; /* FOREACH_RCU could work here but let's use both macros */ @@ -160,7 +160,7 @@ static void *rcu_q_updater(void *arg) break; } } - if (goflag =3D=3D GOFLAG_STOP) { + if (atomic_read(&goflag) =3D=3D GOFLAG_STOP) { break; } target_el =3D select_random_el(RCU_Q_LEN); @@ -209,9 +209,9 @@ static void rcu_qtest_run(int duration, int nreaders) g_usleep(1000); } =20 - goflag =3D GOFLAG_RUN; + atomic_set(&goflag, GOFLAG_RUN); sleep(duration); - goflag =3D GOFLAG_STOP; + atomic_set(&goflag, GOFLAG_STOP); wait_all_threads(); } =20 --=20 2.17.1