From patchwork Fri Dec 13 13:50:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13907063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BDA7E7717F for ; Fri, 13 Dec 2024 13:51:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1DEC56B009A; Fri, 13 Dec 2024 08:51:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 18FF06B009B; Fri, 13 Dec 2024 08:51:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 030936B009C; Fri, 13 Dec 2024 08:51:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D507C6B009A for ; Fri, 13 Dec 2024 08:51:18 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 86113C0EE0 for ; Fri, 13 Dec 2024 13:51:18 +0000 (UTC) X-FDA: 82890072132.16.799390A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 9A224C001B for ; Fri, 13 Dec 2024 13:51:05 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KDpay3Wf; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734097852; a=rsa-sha256; cv=none; b=mRO1WXPNLHUarw1aSRzWfT99FXWKbtT7UrQv5MVqoegsfMmoz45JJml5Y9USQWJO+i40qx sVVl2RhawB2YJ2luho4dav8ILteKsopHUeQmDajllvJWFb31+5N9akaVRrSvevypfpPpzN svJDx8OL+VtpY3Z6QXMbGYBagBu54EI= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KDpay3Wf; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734097852; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Iv9WM7D/h/d7OTq2M7QoeqOwEbcTnPmdrMlMHFXuPOU=; b=7pblcs438wSnTLI2OkeW5bDUd2NjHaUbl/UWshgkmAR1iOtYRhAdCQc0u+ia02ubsfRGha M5u7N4Rs8J/O5LZ6zcXBXJ/+Cw5SxJDyt1j4UKkF99XWLODkUYwvsh2Ttv3L8jIu2uQA40 tOpNWBYbpVJM6i7cja8AFo/zWkE5ras= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734097876; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Iv9WM7D/h/d7OTq2M7QoeqOwEbcTnPmdrMlMHFXuPOU=; b=KDpay3Wf9N1bk21dHvAPJJ+WN/h/WJHQThySi0mDDrxZdRfdNE6a/odtPsJduKZ3MwCaKb Q2Oi6yV4wxZYq1beavzcYWz9g19KrCnM3Gh/lyn3UpVrBlxBhOCenzVFn4m3zgTZMRB9/q G+rquVcYZns3CxIjhE0NcllkA3SxaV0= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-649-Z0u6tnJ2N66YU4thKkuufg-1; Fri, 13 Dec 2024 08:51:11 -0500 X-MC-Unique: Z0u6tnJ2N66YU4thKkuufg-1 X-Mimecast-MFC-AGG-ID: Z0u6tnJ2N66YU4thKkuufg Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4184F1956089; Fri, 13 Dec 2024 13:51:08 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.48]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9E5001956086; Fri, 13 Dec 2024 13:51:03 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Max Kellermann , Ilya Dryomov , Xiubo Li , Trond Myklebust , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zilin Guan , Akira Yokosawa Subject: [PATCH 07/10] netfs: Fix missing barriers by using clear_and_wake_up_bit() Date: Fri, 13 Dec 2024 13:50:07 +0000 Message-ID: <20241213135013.2964079-8-dhowells@redhat.com> In-Reply-To: <20241213135013.2964079-1-dhowells@redhat.com> References: <20241213135013.2964079-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Stat-Signature: tumyzsayytopbkowfuec1ndekbgpmng9 X-Rspam-User: X-Rspamd-Queue-Id: 9A224C001B X-Rspamd-Server: rspam08 X-HE-Tag: 1734097865-333958 X-HE-Meta: U2FsdGVkX19RJKPM4RbhYYqDJhnRu74H5QL1QYOWc4ziVlOmTU6ZkBAtqMajF1PT5GMC8ZhM/Hpnms6Crz3uQxcHZaI8e7xWsNPJ1tP9T51RHBHTPP0oL4YAyRoTpJ+XqfdKKe8PAJTFfqw4BEgF8pJ41IBjAf1i69yY26bB34NqGKXuKIVtgHSFlTJINS0PhLjdC0UDl+qX88moeILX5rIeN2e/WfUtU/wg18284r/pU2CMyk+xHxGdO44IJoyamZsccMM80eNQ7JoCdYBZYlx6aYGagEQQYZT4lo/ThpxkeGHvbUQkrjpAmpg/vzT0YwUYOdGOu2585FkSkXqP8UbZp5RcAQuLN9XHra9SW7YY8h/GFBrhRnVSDb30IfaHwskLgH/zljOR3dAUifDky3wJ2CHzde3GztOC0Qh9UK0PxWE15wiZl59Y+eIi7wfuzXzK+mjvI3O/LAN8VusL+UAh0yYCqq1BEilrxfpd6CoUhYoyvDweOF1q0OaZZv/0474h3Tv6aZ7raA/rfgNSdUUT0nRHbduobRGOzClKidacsuZ4jS3/Sio9H6rdvl5bbKmMmFEodawlWDlbTAQxACj+iLQf7KyGEnQAFNI6ev6HQ+jR+7gAED+M81LQVvRaFo+h7oEhcFuvlBiwCfJUVc1uofsihNH2z9k2KtdnVspQcyLLxvshas7L47tzm1CUGDaEOnb9Nv2pDiWFrih8yLAeUhoafwfaql7qOR21ta/5J0dTlyXFETL6wWREOvMqU0o/jmngIAdAQNsI5hR5iT/VTpn5YyJFw3sE+t7EwlBJGzqoigTfTjYV+Z+miQ0DeBYuLYixv+s3/02SIKxIyOWuRMN4XbNEzPagyi/RX1f0g/Q1jasrO4HX0t4oh/Yr2N0Jy+bSdCj6jCB5r+xoPwgHapsAOIUDQwNk1ldRNBqSl781N7pCUEsgHOTEVltLPYg1vwtsh+82lGUVvaX R5lCWAZq PgoVfdAI2Ln7UcymvaTF/6qRBvY/l45WUAEYCBl5ULOB94pKT/10BbBA4NYQwhLl5dgKxBM504bvfLMeipVjiQRzzGVHzyHd606Jxp4u7kf9DmgzsFP0qiwY6JVJfKE9h6YOUinC5SsN7VTU+59ecP6dZ+z56Zt8xjBj6EmbQMAjIZQFn/nTfNzFHTqkpe2x6MASbx8YbExMEMixz/srzcFLIzAW4X2hLVbHy+t11ZV2BKowVqrGPAnNKd4wUTEiUFzlLxVx1SL3oLqAv6y45FA+Nvb4/uAEYpb1MQ4O346n2dy7KC82rYjGQjnZhP3OXVpLrEIEN0a5AnaNdifvi2twSX62CP529alNo4tdo/n2uGm7BR6liR6N9BRjxzZqlmZCKh/1iCywTCcxyixAhAZAEhG5i9bdVosxPL/iFc+AIMTtFWKoxb5F+0yFDzVT72Pw7 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Use clear_and_wake_up_bit() rather than something like: clear_bit_unlock(NETFS_RREQ_IN_PROGRESS, &rreq->flags); wake_up_bit(&rreq->flags, NETFS_RREQ_IN_PROGRESS); as there needs to be a barrier inserted between which is present in clear_and_wake_up_bit(). Fixes: 288ace2f57c9 ("netfs: New writeback implementation") Fixes: ee4cdf7ba857 ("netfs: Speed up buffered reading") Signed-off-by: David Howells cc: Zilin Guan cc: Akira Yokosawa cc: Jeff Layton cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org Reviewed-by: Akira Yokosawa --- fs/netfs/read_collect.c | 3 +-- fs/netfs/write_collect.c | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/fs/netfs/read_collect.c b/fs/netfs/read_collect.c index b415e3972336..46ce3b7adf07 100644 --- a/fs/netfs/read_collect.c +++ b/fs/netfs/read_collect.c @@ -379,8 +379,7 @@ static void netfs_rreq_assess(struct netfs_io_request *rreq) task_io_account_read(rreq->transferred); trace_netfs_rreq(rreq, netfs_rreq_trace_wake_ip); - clear_bit_unlock(NETFS_RREQ_IN_PROGRESS, &rreq->flags); - wake_up_bit(&rreq->flags, NETFS_RREQ_IN_PROGRESS); + clear_and_wake_up_bit(NETFS_RREQ_IN_PROGRESS, &rreq->flags); trace_netfs_rreq(rreq, netfs_rreq_trace_done); netfs_clear_subrequests(rreq, false); diff --git a/fs/netfs/write_collect.c b/fs/netfs/write_collect.c index 1d438be2e1b4..82290c92ba7a 100644 --- a/fs/netfs/write_collect.c +++ b/fs/netfs/write_collect.c @@ -501,8 +501,7 @@ static void netfs_collect_write_results(struct netfs_io_request *wreq) goto need_retry; if ((notes & MADE_PROGRESS) && test_bit(NETFS_RREQ_PAUSE, &wreq->flags)) { trace_netfs_rreq(wreq, netfs_rreq_trace_unpause); - clear_bit_unlock(NETFS_RREQ_PAUSE, &wreq->flags); - wake_up_bit(&wreq->flags, NETFS_RREQ_PAUSE); + clear_and_wake_up_bit(NETFS_RREQ_PAUSE, &wreq->flags); } if (notes & NEED_REASSESS) { @@ -605,8 +604,7 @@ void netfs_write_collection_worker(struct work_struct *work) _debug("finished"); trace_netfs_rreq(wreq, netfs_rreq_trace_wake_ip); - clear_bit_unlock(NETFS_RREQ_IN_PROGRESS, &wreq->flags); - wake_up_bit(&wreq->flags, NETFS_RREQ_IN_PROGRESS); + clear_and_wake_up_bit(NETFS_RREQ_IN_PROGRESS, &wreq->flags); if (wreq->iocb) { size_t written = min(wreq->transferred, wreq->len); @@ -714,8 +712,7 @@ void netfs_write_subrequest_terminated(void *_op, ssize_t transferred_or_error, trace_netfs_sreq(subreq, netfs_sreq_trace_terminated); - clear_bit_unlock(NETFS_SREQ_IN_PROGRESS, &subreq->flags); - wake_up_bit(&subreq->flags, NETFS_SREQ_IN_PROGRESS); + clear_and_wake_up_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags); /* If we are at the head of the queue, wake up the collector, * transferring a ref to it if we were the ones to do so.