From patchwork Wed Aug 31 22:29:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pranith Kumar X-Patchwork-Id: 9307953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2418C60487 for ; Wed, 31 Aug 2016 22:29:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1319D290E0 for ; Wed, 31 Aug 2016 22:29:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07CDF2910B; Wed, 31 Aug 2016 22:29:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 86F5E290E0 for ; Wed, 31 Aug 2016 22:29:43 +0000 (UTC) Received: from localhost ([::1]:56206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfE0r-0001ND-Si for patchwork-qemu-devel@patchwork.kernel.org; Wed, 31 Aug 2016 18:29:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38679) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfE0W-0001LF-A0 for qemu-devel@nongnu.org; Wed, 31 Aug 2016 18:29:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bfE0V-00054s-DH for qemu-devel@nongnu.org; Wed, 31 Aug 2016 18:29:20 -0400 Received: from mail-yw0-x243.google.com ([2607:f8b0:4002:c05::243]:33823) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfE0R-00051m-2J; Wed, 31 Aug 2016 18:29:15 -0400 Received: by mail-yw0-x243.google.com with SMTP id j12so2510123ywb.1; Wed, 31 Aug 2016 15:29:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=HCfMK1v8GgkN5wu0vBL+ZBkOJnpKvRYTh3r1VRHoadk=; b=pgQLLAiqTt8AcpJfVg0nol7ThdmH2U21BUeXo8LgooRhUSJk1K6x6CtT2vvZofmI+i NFlY1Yu3oRPqCAp1vl/uCqRNg3bHtyDSX9vjeTcq/9kvt0CN+Opsex/MmO9/IM/QW0c5 ZYY+o5xUp28b5M6t0YrD+5K0ly7NxxT0QXpJy6nGnzWY98wlValBB4Opyve03X3kyR7a a3kS9Via69mq+jLKugr4zncTzGR5V7DW7cgMHIPADf70x+yJtsM2fSLKWrHJsLibFYhU sWi8ss287O/lbnrf/gURlQq1QWm291ckZm2HyianGXbPepyhYuiPTaOwWTGxw3wMNIwC /02g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=HCfMK1v8GgkN5wu0vBL+ZBkOJnpKvRYTh3r1VRHoadk=; b=gxBplhg3mlAfonSN2UE8Ctt5VmrIQ58ll7ivhK3HLhiNCpKqlUD1rC82kkwOXoCiMN CrUnlJSgoFvV0gWu+NcxL7XaF1OY/ACt/TfbTL8Hj/6MRvjhbHVMoKIvC/iLbQ3ZuQIx QYchgSXGRwSbsK584jNFWMic12aJ/4IfHDR4aqpTGF9+QqFBO0/NDdzAcq34wCzA3CLT PBiQkB/LOERjLKDpt71elBUcwryHQpmXsZRgm/CTLrPUjFv68RjUIRA9ChB0meiAUeYa gdG/SUWo3UuNlLEWhGiFHBNfm6mV/CbITvWBRjQNe7t0CmhVUHW5o+imu09xcwVGrndT c7Og== X-Gm-Message-State: AE9vXwPou6sWP17vj3ldCZ4ep7D5pdNT3wJBVyU2lRwAx0YBoO7uNGMRr1Qv4XM2zzR0xw== X-Received: by 10.129.132.19 with SMTP id u19mr10435180ywf.255.1472682552677; Wed, 31 Aug 2016 15:29:12 -0700 (PDT) Received: from evgadesktop.attlocal.net (108-232-152-155.lightspeed.tukrga.sbcglobal.net. [108.232.152.155]) by smtp.gmail.com with ESMTPSA id f206sm722628ywf.42.2016.08.31.15.29.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 Aug 2016 15:29:11 -0700 (PDT) From: Pranith Kumar To: Stefan Hajnoczi , Fam Zheng , qemu-block@nongnu.org (open list:Block I/O path), qemu-devel@nongnu.org (open list:All patches CC here) Date: Wed, 31 Aug 2016 18:29:09 -0400 Message-Id: <20160831222909.26983-1-bobby.prani@gmail.com> X-Mailer: git-send-email 2.9.3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4002:c05::243 Subject: [Qemu-devel] [PATCH] aio: Remove spurious smp_read_barrier_depends() 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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP smp_read_barrier_depends() should be used only if you are reading dependent pointers which are shared. Here 'bh' is a local variable and dereferencing it will always be ordered after loading 'bh', i.e., bh->next will always be ordered after fetching bh. This patch removes the barrier and adds a comment why storing 'bh->next' is necessary. Signed-off-by: Pranith Kumar --- async.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/async.c b/async.c index 3bca9b0..6b691aa 100644 --- a/async.c +++ b/async.c @@ -77,8 +77,7 @@ int aio_bh_poll(AioContext *ctx) ret = 0; for (bh = ctx->first_bh; bh; bh = next) { - /* Make sure that fetching bh happens before accessing its members */ - smp_read_barrier_depends(); + /* store bh->next since bh can be freed in aio_bh_call() */ next = bh->next; /* The atomic_xchg is paired with the one in qemu_bh_schedule. The * implicit memory barrier ensures that the callback sees all writes