From patchwork Mon Jul 29 16:19:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13745288 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 AD7FBC3DA4A for ; Mon, 29 Jul 2024 16:20:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C6BF6B009B; Mon, 29 Jul 2024 12:20:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 350346B009C; Mon, 29 Jul 2024 12:20:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A22F6B009D; Mon, 29 Jul 2024 12:20:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E86D66B009B for ; Mon, 29 Jul 2024 12:20:56 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B0442A0495 for ; Mon, 29 Jul 2024 16:20:56 +0000 (UTC) X-FDA: 82393304112.27.354C72E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 065EAC001A for ; Mon, 29 Jul 2024 16:20:54 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VESzchOo; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722270051; a=rsa-sha256; cv=none; b=KTWkWuLGG5+uw5XfRMm3vBhl/AaE27ZlERCyzhZJa6ZGbuFQn87neP/aRrmrQTvf+STL5D 05TV4C+NTb6xfhWWvbpfMIymRbkzD28GdQzlsfwxI9eHyvX1/WVxw4OitTpbfNyODPhNUB 8yHanTdyvzdIUQcPf/BFd6Ck2fw9Kas= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VESzchOo; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1722270051; 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=L/oVpDumRjUlX+aosidOXdQbOjRrDxev6yeZ4FfFDPg=; b=kkpdz0/mkvPEY1uuSOdD9n/D9NgoKAR758MrXMbETrmoUQfka4KT8I7Do11VuEPVBhEIqZ kN/YfDvWs+DYFDN5XBZ6s85ApA68VHRbzQzgcBsa+qsCqTtklmFwoOXeorD6VoMPctSySC +BMbXnBFz2XoaxhZTtxTuySrjKVDsNQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722270054; 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=L/oVpDumRjUlX+aosidOXdQbOjRrDxev6yeZ4FfFDPg=; b=VESzchOoU7xgS5wS2iDeleEPgIVstiYYBSoNRQObVNK0SC3S2sLncLlUx8gr00rQvQf3YX MIR9aov8dDhRtuRiHemrfSj0OaYXY/JSM4l0XEPD5iaffPmpKedNNUjmEn/BcFvBsAW4G0 wvXyN+2lVT4mhZdzGn6y/JrQHUClpIg= Received: from mx-prod-mc-03.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-526-WgW1m07KO_iavDTjj_y9Sw-1; Mon, 29 Jul 2024 12:20:49 -0400 X-MC-Unique: WgW1m07KO_iavDTjj_y9Sw-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 73DCC1955D4C; Mon, 29 Jul 2024 16:20:45 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.216]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7174519560AE; Mon, 29 Jul 2024 16:20:39 +0000 (UTC) From: David Howells To: Christian Brauner , Steve French , Matthew Wilcox Cc: David Howells , Jeff Layton , Gao Xiang , Dominique Martinet , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Eric Van Hensbergen , Ilya Dryomov , 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, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Steve French Subject: [PATCH 04/24] netfs: Record contention stats for writeback lock Date: Mon, 29 Jul 2024 17:19:33 +0100 Message-ID: <20240729162002.3436763-5-dhowells@redhat.com> In-Reply-To: <20240729162002.3436763-1-dhowells@redhat.com> References: <20240729162002.3436763-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Rspam-User: X-Rspamd-Queue-Id: 065EAC001A X-Rspamd-Server: rspam01 X-Stat-Signature: c33kh67j77yigcfkk93edq4ejrqqykjg X-HE-Tag: 1722270054-982283 X-HE-Meta: U2FsdGVkX18LCwccX84wSr/3r5L/zw3duB0Ga/bgRouWIsttzlvLqxhuLR9fT6IHCkxHk0pi5WmKhAuU9TobjDBzCwPEvRfxrz2O2jTGN3pUW+X6upF0ID4+REAu1dYhplVinI/FsIeUtxrgT8KMio4mt6pEGzJ3yl927V3seLLok/VKeFDu9/KqvXJ02kwGvxSZbt/mMOSn78l8CqYyEu9oTGos+DNFCbvzNOoYv9GtYwDjXBQkfr4VFgtwOqP2h0KKVOWSfgNBoCCXfGiqgj5FtatTyHCk/URA6b1M/Wh0/bGdxBlOnb+y00BnX6JldQbYnTh4Dql/Ch7uFWrZWeJ4VKkVF+rf0N1RQC6zuK3bfBxTwk9XdmKL4pw9n9ZGo77MVPn/rIXn0F483CYCZK2GtgKdw9G8JiB2W60y6+DCs5cOAYadElgfHeq97o56dJfvqXeYjLh4Gz6faoirc62Duuw/zrhXWpsmSmvduB4S5TwsNG6tBpoKojS7fjW6Xcspo5A/nZ/FtftCdyyx3GyDrgiSx0k2RJ4MT0xuJ1aZ5CzlN0qXGxNBkcNLKFMpHxbYd2YnvmmFewfQf25oo85hFAOQcCHPQrYWwtHsBcVW7JjnoAi1iNHPi0+bppfsmlTX+M+3iWbOc5643XceQT6A6KvNYRlxS3gxSGbkbHImsDoFt7iE3raP8I1o7DWZzl3WWx2TKkH7W7fyX1C0oC8oa8ToRcC+DqlKiPwV0N+0OKKOEbflqkZ39bRMaPC0PYBVrCb/TvrScYmsU8TiIdIuuOCcPkk6q2BQ0JOLL3EuZlDYqN594qqVDPkXkDFOPEl21LIbsElWjcpc4DI79YKt1MmLGeuOz6o7GtTgeR/YEFK9HQCZIF2Ib4Kkeaa3gvda2WQ2NXpxhQgSwkqL9tD4KBDJlnBx6oIEQiIP1MsT2i11u7QLgmCeFkiRrP9wv3fscuFgMK84FuFVhL0 gqVLOUwO KXEkwaw41Pb65gxzbgyvwX4TLkvaXyEQA8Wr8pMk1DVx3feNHNyUFQptrfmOqiF2k7bSndOSokpqsE/EYKxaBlguGRJwytbE9dGhEmxttg5JNC4uu7XqI+aWvZzxbZE/Yc1pQFSvxygnNwqbRvmOm3WvknEYr3Tu5rKUSXAe1KtSvVnYf1FV24wvoKO8JeaIOI3RM3/wL6I93BVfEInsCRS9Bta37hl963k7yOVFxHWXP+LTTKA59J+6+VTJUMY2o5e3Z1waA12CGXRxQ8XHyYVPe7p2K8p/Ru0nuVr4EiyOP5ZZY+5lI8GaxXVslFYUPs8WoQdcFliXjZCXuJomXi19sju3XrT79tw53XTTfhPQvTA1/H8J45FlTZlN2aNhE6HyCzBnJSibTuiSYXE2H66oZO5doI1gt4qX6usuFEjPsb2bcYAVB1oCh7uDwcKG2lzUY 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: Record statistics for contention upon the writeback serialisation lock that prevents racing writeback calls from causing each other to interleave their writebacks. These can be viewed in /proc/fs/netfs/stats on the WbLock line, with skip=N indicating the number of non-SYNC writebacks skipped and wait=N indicating the number of SYNC writebacks that waited. Signed-off-by: David Howells cc: Jeff Layton cc: Steve French cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org --- fs/netfs/internal.h | 2 ++ fs/netfs/stats.c | 5 +++++ fs/netfs/write_issue.c | 10 +++++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/fs/netfs/internal.h b/fs/netfs/internal.h index 7773f3d855a9..9e6e0e59d7e4 100644 --- a/fs/netfs/internal.h +++ b/fs/netfs/internal.h @@ -117,6 +117,8 @@ extern atomic_t netfs_n_wh_upload_failed; extern atomic_t netfs_n_wh_write; extern atomic_t netfs_n_wh_write_done; extern atomic_t netfs_n_wh_write_failed; +extern atomic_t netfs_n_wb_lock_skip; +extern atomic_t netfs_n_wb_lock_wait; int netfs_stats_show(struct seq_file *m, void *v); diff --git a/fs/netfs/stats.c b/fs/netfs/stats.c index 95ed2d2623a8..5fe1c396e24f 100644 --- a/fs/netfs/stats.c +++ b/fs/netfs/stats.c @@ -39,6 +39,8 @@ atomic_t netfs_n_wh_upload_failed; atomic_t netfs_n_wh_write; atomic_t netfs_n_wh_write_done; atomic_t netfs_n_wh_write_failed; +atomic_t netfs_n_wb_lock_skip; +atomic_t netfs_n_wb_lock_wait; int netfs_stats_show(struct seq_file *m, void *v) { @@ -78,6 +80,9 @@ int netfs_stats_show(struct seq_file *m, void *v) atomic_read(&netfs_n_rh_rreq), atomic_read(&netfs_n_rh_sreq), atomic_read(&netfs_n_wh_wstream_conflict)); + seq_printf(m, "WbLock : skip=%u wait=%u\n", + atomic_read(&netfs_n_wb_lock_skip), + atomic_read(&netfs_n_wb_lock_wait)); return fscache_stats_show(m); } EXPORT_SYMBOL(netfs_stats_show); diff --git a/fs/netfs/write_issue.c b/fs/netfs/write_issue.c index 9258d30cffe3..e7d4f39b8fdc 100644 --- a/fs/netfs/write_issue.c +++ b/fs/netfs/write_issue.c @@ -503,10 +503,14 @@ int netfs_writepages(struct address_space *mapping, struct folio *folio; int error = 0; - if (wbc->sync_mode == WB_SYNC_ALL) + if (!mutex_trylock(&ictx->wb_lock)) { + if (wbc->sync_mode == WB_SYNC_NONE) { + netfs_stat(&netfs_n_wb_lock_skip); + return 0; + } + netfs_stat(&netfs_n_wb_lock_wait); mutex_lock(&ictx->wb_lock); - else if (!mutex_trylock(&ictx->wb_lock)) - return 0; + } /* Need the first folio to be able to set up the op. */ folio = writeback_iter(mapping, wbc, NULL, &error);