From patchwork Thu Jun 20 17:31:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13705987 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 CF630C41513 for ; Thu, 20 Jun 2024 17:32:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 528968D00C5; Thu, 20 Jun 2024 13:32:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E3C88D00AF; Thu, 20 Jun 2024 13:32:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1CD6D8D00C5; Thu, 20 Jun 2024 13:32:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D696A8D00AF for ; Thu, 20 Jun 2024 13:32:44 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7CF9E160445 for ; Thu, 20 Jun 2024 17:32:44 +0000 (UTC) X-FDA: 82251961848.25.1700D9C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf01.hostedemail.com (Postfix) with ESMTP id BCF9C40018 for ; Thu, 20 Jun 2024 17:32:42 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dffVP7uT; spf=pass (imf01.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718904758; 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=fBEsJ0JBnkoJ2efzkpyXGTGqwkO8a4ye4BCeFPtv9T0=; b=SIKi62ftb9qh67EyJNyDKzNtNFEMBXt/fpO220ibFrFHDRJjcz8h2XHwWKMwSLiV671uu7 RskQSFF/xrCUm0EzpIgclLeN49mEHuvtKiEHDL+uRA3TmH1KK+kXtNMDUpmO2zZ4XaH4Vk cQFjkFAmNI14MfBKsFmfz5qhKeysWw0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dffVP7uT; spf=pass (imf01.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718904758; a=rsa-sha256; cv=none; b=goTEe/A5wZH9C4uIO/8l8M4cU5/8I3OzOZa8F5Sx2e8oeZopgCGNGdo91KzFpIQgZkjkNJ HryTVGTolqLteIJ+A9TIpIp6oqo2OTlUeDyDoqBxUCJzoFJYhhT704tVZriAShsNGbzIIo /z2HTgOnQ45uXYliqYU+vhy8KNmjH3w= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718904762; 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=fBEsJ0JBnkoJ2efzkpyXGTGqwkO8a4ye4BCeFPtv9T0=; b=dffVP7uT8Ly7KyyOSuFSjtrk0sCOmFQKhl4Ez/34lGiAAXLJ9qRS/yhvJaAcxMUGNvamfc 1AABbTS0HhdQTVr5a5D+Bl1pQHnWk5QCokWdQpCfloD3Z54gQ3WisIU3MY49Luk1eAPTJI KE0H/rWLPdwVgST1Ea/y4Li1FbDUrD4= Received: from mx-prod-mc-01.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-663-cjerBB3ZN4CST4QI6Rz8_g-1; Thu, 20 Jun 2024 13:32:36 -0400 X-MC-Unique: cjerBB3ZN4CST4QI6Rz8_g-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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3704619560BE; Thu, 20 Jun 2024 17:32:32 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.39.195.156]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C96C319560AE; Thu, 20 Jun 2024 17:32:25 +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 05/17] netfs: Record contention stats for writeback lock Date: Thu, 20 Jun 2024 18:31:23 +0100 Message-ID: <20240620173137.610345-6-dhowells@redhat.com> In-Reply-To: <20240620173137.610345-1-dhowells@redhat.com> References: <20240620173137.610345-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: BCF9C40018 X-Stat-Signature: ioa5toqjnmw7zrwu8jkqxd6ia5du89wg X-HE-Tag: 1718904762-320732 X-HE-Meta: U2FsdGVkX1+Bdv4zOQQxkIf/DG58H89PCTyp8kZVG70lIJHeyMz0ybfSff755qCghhJO6iQdN9vEyE4/+e5Ch13n60+GNCc0pXIkmSTEOAdjU0qmZ6dc/26cA/Dz5blcEwl/sY3HevKo85feAX8vfrrZaSjuoI0ve5C7u2mip83P3ZtVBH4Ky7XCEIXw6ht5bqeAR99rsx5RxRL50z1wQqtCoi9iRMO3tNuAjgIrr2AORO6rCmujw37koB347UCaynd2GBxxREgK03Xd+WaJ9C/zEBJvqPf4pf7l4EutNe+/HoY32sq5B72WSBbmjp0Ejfd4HtbAnGWjNg37hfZ+j7Jnl9GzsSZhOKxyubYlCku0g1oE7dZYP6iEhcmyZHfhERuupYYcN+LwkOvY7wj3k/8mWGAN7Y5YYvolcWK5Nozuie3J0027701iKx8uxm0mDYlpcIUV8tVSIXAYOqLneZ3da6adlus9Sn56bb5lwzE2DFBbkjEMztMnLJV80l7lvyzzLsgxSQ5CWdi/Mc/SQlsqaG8M+Bd8TLubE36txzlA00KdU7Iq5ymEMYTmcxFK5UFBRspPLBCqBm+42AHTqdnJjFFFDrnCq9PdwncdCzAy09TNcA/+8ta4asSK+z7mRtuDhQMhPpTAG/ZyvyXboTJATdKjv38kkHl5+CVV/c3IAEnbxO7AqIsl13QhzbFCoXL25qrFwFHQl9Y0XoR33J+ErEao7ikDcgP309n1rS7LDdKhA93vZNUuKORPxRfvipk7KmeTan+eAAsMzr7+tM+S5ZV3w7wAS9dh7IpwvIrOKX7h0LW1aaW1oO+gtlmLrMAqN4Kj9gZr25AjveG7ND/LXbNnMAcBHMEBU2+8FImRnNNf91Ziwa/cFoPTAtyX1LlGnDF7Xe17RN6IkNrRggoepyxgvZQtOWyn2r+YrQdSdkXH2uRfK0Ax9IPyPS+RTCZHV7lDmW0FnYozYda vIJHpLip D0YWv7INSrgStexVR8lIftE5DlaVbCq0jHBVs/knCLC0SVXh/AaZ5YM+DTA1HnJFJnpVTF3j8UjyPI1kBkUMh+aHsL0MHaLNqV7DsJEi8+ZjKgTXKWioJJPCN0vXubT/4lV3Xi5c3jt46l/tfYVL3IpaYTC/5DUfav5Gl9eo4yxf2aS58KlK5ATP2CFiusdfQQOvR97anjRzs3Fvwp0S2u7Ob4ThudaY29ennS5vwj1lIXprFtg8YXJhQ0MPvQVsxj5tokktGhqJtvSLiG1SThG3yEKU82UQhxfUXawi0JIxXpSWzCOqWCpN6K4knaJcWkLMjJ5VtDtq4XrvXTPgeIvykdY9FLcDrjTf5MuuWSP04Fsqr0UEaMdbxrOsSzEMdOghSZmvLQS5KuOpBAb3wVoo2cBDjriPq55azTXKE5MqFuJqp+MUY8KoPbVEa5LG3k3J8 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 95e281a8af78..42443d99967d 100644 --- a/fs/netfs/internal.h +++ b/fs/netfs/internal.h @@ -126,6 +126,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 ec6cf8707fb0..cd3ddf07ab49 100644 --- a/fs/netfs/write_issue.c +++ b/fs/netfs/write_issue.c @@ -502,10 +502,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);