From patchwork Wed Apr 24 21:54:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Stefan_B=C3=BChler?= X-Patchwork-Id: 10915791 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 33F4C922 for ; Wed, 24 Apr 2019 21:54:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23B2F28B8F for ; Wed, 24 Apr 2019 21:54:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17C1B28B9C; Wed, 24 Apr 2019 21:54:27 +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.9 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3B8F28B8F for ; Wed, 24 Apr 2019 21:54:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731840AbfDXVyZ (ORCPT ); Wed, 24 Apr 2019 17:54:25 -0400 Received: from mail.stbuehler.de ([5.9.32.208]:41014 "EHLO mail.stbuehler.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731763AbfDXVyZ (ORCPT ); Wed, 24 Apr 2019 17:54:25 -0400 Received: from chromobil.fritz.box (unknown [IPv6:2a02:8070:a29c:5000:823f:5dff:fe0f:b5b6]) by mail.stbuehler.de (Postfix) with ESMTPSA id 46327C030BD; Wed, 24 Apr 2019 21:54:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=stbuehler.de; s=stbuehler1; t=1556142863; bh=j00YEKIBIYx8iSi1Y8E2AsbiGHpsyQBbnqztzAtf1uE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=X/OcvXlyLV6MDawzUJ6YwlKQ9k84bUI0JnIL3yFch0mWe/Gt2DnZCJgbW5Vgk8/zE K6rNDpIXYp0txCL9Cw1eATrjana3yCnzKjac4Zrnjh6mP4JhwiKuK3d8Y7a5Fgr5Ij ij+SHikoHgGn61q1+fT9RszJTJNxgM/WzqOySGcc= From: =?utf-8?q?Stefan_B=C3=BChler?= To: Jens Axboe , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH barrier cleanup v1 3/7] io_uring: remove unnecessary barrier before reading cq head Date: Wed, 24 Apr 2019 23:54:18 +0200 Message-Id: <20190424215422.7404-3-source@stbuehler.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190424215422.7404-1-source@stbuehler.de> References: <54496e17-97de-9f9a-9972-c448226bb768@stbuehler.de> <20190424215422.7404-1-source@stbuehler.de> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The memory operations before reading cq head are unrelated and we don't care about their order. Document that the control dependency in combination with READ_ONCE and WRITE_ONCE forms a barrier we need. Signed-off-by: Stefan Bühler --- fs/io_uring.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 1f4419f38ef1..2c101230df71 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -431,8 +431,11 @@ static struct io_uring_cqe *io_get_cqring(struct io_ring_ctx *ctx) unsigned tail; tail = ctx->cached_cq_tail; - /* See comment at the top of the file */ - smp_rmb(); + /* + * writes to the cq entry need to come after reading head; the + * control dependency is enough as we're using WRITE_ONCE to + * fill the cq entry + */ if (tail - READ_ONCE(ring->r.head) == ring->ring_entries) return NULL;