From nobody Wed Nov 5 14:26:06 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534874515112224.64077954435015; Tue, 21 Aug 2018 11:01:55 -0700 (PDT) Received: from localhost ([::1]:55257 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsAyX-0002z4-TU for importer@patchew.org; Tue, 21 Aug 2018 14:01:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsA4n-0002IP-Vb for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:04:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fsA4X-0006r5-Qo for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:04:11 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:45269) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fsA4W-0006Uw-RB for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:04:01 -0400 Received: by mail-wr1-x442.google.com with SMTP id 20-v6so10507592wrb.12 for ; Tue, 21 Aug 2018 10:03:48 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-184-244.clienti.tiscali.it. [78.12.184.244]) by smtp.gmail.com with ESMTPSA id v6-v6sm2608955wmc.43.2018.08.21.10.03.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 10:03:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=0PMTAJ1qNT+Z0P5oJp8NdnRMsB51w3CiYtw4bOM2zzs=; b=HBbrPdRym29AILcIl39ErgvFytYtiFekemk8jGu3jGHos8z40Sy4G5z7WCw8nEH1nl WVjg0X3ubaDiPnUDwjKG1qdfv71EJi6DfJFOn+OWP/LFxh77stFTaUqs3gq9JhOflSZ4 Br7yLORZm9IXqaTdaxhXjrGP6YFQTuX/nU/94ML4NgFXtYmUp/lkajd35CQswXGGcPsx 7mzHh7RdaB+KH4qOk3Z3KmATI3KLw8ymhHALVaRuV3ATw7vocx/vX/DZ1uycJvcp1i87 hai2t7NmK6lqi+XOSr4SPV7cYl3e7u1OtOMoNZwvLz0xP1txiBFMvEcOX5mbApQ840l+ q+rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=0PMTAJ1qNT+Z0P5oJp8NdnRMsB51w3CiYtw4bOM2zzs=; b=CnfkjVfqvRBfc2qCDgYlhKHDp/x5NMkRpEcO6BL8pSlHT6CjgthwaB33lJIMQ2oVJo 7hXAnN6hmEln6/FYHbs0t7ihxVybet6JckqNhhdrSU2eFVOU7LqiAxgPHIGNt5JtL8at g5NWhMmv3VGOuMs61QWqjCLqWimVu1f74vVdTvqbrhNathRE6pUjPrfSWbcgZCUpwWd2 0HQD0ypxFUQs3HWXgF0dxry83FmiafZz7XcdPB1d+RifYVjk5fjvUyXYvdxI6WiBchco 73cbdc3XJ6/XSLtyMkMO4rsPkBtYJo6VEkDgwB3icaGsP6ZJU3vuBmPuPjSCn3EMIPjK ECdQ== X-Gm-Message-State: APzg51AE042VJIxvHWr3JYQ/hBJiTlB3g6jkeTAt9mcmi7klg7ag1j3b ff3fO4UJH1vWrXWVTLGUxvDpBi6h X-Google-Smtp-Source: ANB0VdaAVnwOxNTKJVaevGP2X+ouTW1COmHEj1SKBbVEg6jDGOBUZXKO1pIr95V+IHBrpCw7ug/kEA== X-Received: by 2002:a5d:4605:: with SMTP id t5-v6mr997720wrq.200.1534871027408; Tue, 21 Aug 2018 10:03:47 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 21 Aug 2018 19:02:12 +0200 Message-Id: <1534870966-9287-41-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534870966-9287-1-git-send-email-pbonzini@redhat.com> References: <1534870966-9287-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PULL 40/74] 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: "Emilio G. Cota" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" Instead of declaring it volatile. Signed-off-by: Emilio G. Cota Message-Id: <20180819091335.22863-6-cota@braap.org> Signed-off-by: Paolo Bonzini --- 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 1514d7e..b4ed130 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 1.8.3.1