From patchwork Wed Aug 14 20:38:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13763952 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 71A6FC52D7F for ; Wed, 14 Aug 2024 20:39:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0965E6B0095; Wed, 14 Aug 2024 16:39:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 046216B0096; Wed, 14 Aug 2024 16:39:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E76656B0098; Wed, 14 Aug 2024 16:39:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C30BD6B0095 for ; Wed, 14 Aug 2024 16:39:45 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 7B924A8358 for ; Wed, 14 Aug 2024 20:39:45 +0000 (UTC) X-FDA: 82452017130.01.6E8EB4F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf29.hostedemail.com (Postfix) with ESMTP id CD28012000E for ; Wed, 14 Aug 2024 20:39:43 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FHQep7wa; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.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=1723667925; a=rsa-sha256; cv=none; b=CXhYGfY/kCM3cTIm0E26KxlVT41iug+wruuVIeXujG4ingZ8ndK72k7WtRTdNjT3ciQ46g jRGvj+CuhT+oyurTEitVVFCmZFMJT3zGVLbVMbSgv1I7bC4fzeCgiZU39yjrpMQpp8CRYW YqS8cic6hWGJw7TzV0HLAya0euMitVE= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FHQep7wa; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.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=1723667925; 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=uDrUQ7Tmc3LMCcmpsItzClcB/6T7pKhhgt+iqpix15s=; b=0aJ6WnwhfieRGmI29DGrvspTpBD29YYW+h4GFWeSGIw4vuiFdjIX0S4+ebjtSXPEF/v1Ps Y97KFUgZ5i2xLof/DCoqR2qFuqmRKYPBzOGforOYWJ7zcavoXp8IHIn1BgVc2Ec953zdMZ NWUT6xsK5pfpbfHudkVXOdrEpj/3bUk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723667983; 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=uDrUQ7Tmc3LMCcmpsItzClcB/6T7pKhhgt+iqpix15s=; b=FHQep7waFQreGCKwNcL9umSoWvYO7iN3rWbtrbZHCKViyl0hO57LuzSNfSjOASJL6rF1rB A2tXCeykULk0gskAh3UqBnZm+lnUXnOt+SEPzpjduObZ8QLi9Lx5Lwzkt9sDMq5n9xd8NN 5805Y9MaykjEogefuPO8HOs4N3Dipi8= 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-137-hLPCHq2nOU26AtMXXsTm9g-1; Wed, 14 Aug 2024 16:39:38 -0400 X-MC-Unique: hLPCHq2nOU26AtMXXsTm9g-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 D502818EB236; Wed, 14 Aug 2024 20:39:34 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.30]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 279A019560A3; Wed, 14 Aug 2024 20:39:27 +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 v2 04/25] netfs: Record contention stats for writeback lock Date: Wed, 14 Aug 2024 21:38:24 +0100 Message-ID: <20240814203850.2240469-5-dhowells@redhat.com> In-Reply-To: <20240814203850.2240469-1-dhowells@redhat.com> References: <20240814203850.2240469-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: CD28012000E X-Stat-Signature: eqim1e9rc565auby8bwtcnd79rqndk5s X-Rspam-User: X-HE-Tag: 1723667983-493106 X-HE-Meta: U2FsdGVkX1+7Eo37G8mhBjrrHlZ9EHP6l1NTMKR+TLwVoSLiVXTGrfkgAUJ5tdaaeIo9RMsON7uV6SBkGbEKI4ymLaN+QMHmLz3+Mf6homkwdodab+hoA3bCfnGgDryczyccH3FrDQYqLZOGIa/2s7j8qhZAgiO+DvgtvhqgA6UAx4pVBysuYuKRuViMHY7TDqNg+iWe7luWoGcIlRU/q5wd0feBLjNAzEDpibJWpcxwkKcrfhMV6kYGddwzIR+eO2koenIivKPUoK4VaCrZSrY3aa6AbnaDsERPbyC7NS09O35MY4QuvMNVdIGvQJ3bucFncAdShw5uK9zxnRp45mFHHefB3tq6CXB8tm2xMps/hCTqKAKRWlnf7Li3NKojVGs9q7Q45wioxcPe44zQnahs4+hLhOrjET+rfua6jlrDm0Km9uIMffVEiNcjD1Q4WkVwwrX3XdI0K7Ry5uBPMAX+t0ABx7jmFdYRusXQxNUQ8f19/S6P0qYlCY0ZXuHt2pHp6Z90CEkPMQuXqCY7c0LHL9GjyGBHJ9qw9WiLLuf6edgbaUsZCpHF5+MNFaVqwwWEQiOZ7sRvXlKRw5psNjYDRHH+qM30dUfq+1QNfx5yB7tA5Vv7N/htZYO85e55qh5ffYiXd/wq5lRf2MUHm08ANqzrJkFI+SuChEVoEjzYi1D1Jz4yvMsaO8GIUCLf0+p216/tE0CdhWhkop5arEZCGQtLvvLHG5qXMLnVpXAgenVqyC1h2jH0Oikz6Rm8Ks1eWtM+D0gImMAgW9rsoJUHgOWulfuo4ROKDA4ka9CZ3BPMIPA9oR8/XJgIoj0NJlQ3vJoypMSpRxukRFy+/zJrUzZ5njiaZLdRBVSTwRewzjBLEeltSbAbNd5s9+ZHG3f4418JNsxYVphr1IXb95JSgJF1otWiPOLlmhozxsCLokHV3G8PPSKytdu2d6Q/KU3ZIlKU2OhvGAazCRK DUEj7WQ2 6h/acp4emv3abQiryJaL6j23Lp8F1hCAHDmis32gBLBBOnHLwdU9zVbDzLFpKvAtVAD0veKwO950o2U+hH/OCC686+csUlTuLwzrqzWfs5TSjY2lDrpFLklfz/TsrNLTRxfZMX721uxVgiV4GhRtJqPBv94hR7ny8sgU2AVyP1ypdG56dX0BReTV+OEKGtT0z5agMR1aL2EuCPxtcZXtUdflaGkiQsX0MKFAM2JMcssF0o3JRXH2UnIigaX6c+9zw2nRCjsi3bMx9xf7RbLBmLiqFDqJa+lW4M7paqZvtDJofZcLSDEtCfdYl4DsHfuuCS51/vhHemRSVlY2C3LV+U0CRbC1Yj6J3Uq3LJtNk244nqHgcCp8my9YU+F1oBJgpnUYgKL/e7F+aOTPSywFlceirrgC8/VNESR2NdcqBEe9K9JbGj+2HmhU5ad2mbw1RGAEr 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 3f7e37e50c7d..44f35a0faaca 100644 --- a/fs/netfs/write_issue.c +++ b/fs/netfs/write_issue.c @@ -505,10 +505,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);