From patchwork Wed Oct 2 18:49:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13820257 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 85D8ACEACF3 for ; Wed, 2 Oct 2024 18:50:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F0DF06B03FD; Wed, 2 Oct 2024 14:50:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EBC4D6B0400; Wed, 2 Oct 2024 14:50:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D10906B03FF; Wed, 2 Oct 2024 14:50:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A78FB6B03FB for ; Wed, 2 Oct 2024 14:50:12 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 4445D1A0E8F for ; Wed, 2 Oct 2024 18:50:12 +0000 (UTC) X-FDA: 82629552264.18.F1ED6F1 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf27.hostedemail.com (Postfix) with ESMTP id 6FC6E4001D for ; Wed, 2 Oct 2024 18:50:10 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jakiBEt2; spf=pass (imf27.hostedemail.com: domain of jlayton@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727894970; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3gU3nyrraY8CubZ8FodkvGoDohKy/j1zXwdzD5kWX0M=; b=t1bLJ+bebspB/QNiJID/OfySxD9B5ApXMv7XA/E3ar+yFeg2VQXzphzk3CKZqeo0shcoFA msntQiIKSasns9XckfUXzALODvRestakOQgz6BaeBTnajLPgFjxfJBAeQRkd1XzOki0TCW g3HGgrYVX44ZX/5IaZFXfRr3nVOKuwM= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jakiBEt2; spf=pass (imf27.hostedemail.com: domain of jlayton@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727894970; a=rsa-sha256; cv=none; b=L+tUAeKtC4s3kz6uRYkgJfyMssEppYus1yBFAstyn1Oc3R7ClSpuj26gC5LQ0xQMF3kwFm Cb6TT5IAlRdrhHX4hMbcrEiIIkMWVRyU3kDneVIUPyHHlC/VfOijwv8Je7jtyKwMFEr84O q5FyZvJq/Sg3EilCMIIR0M20V25pe7s= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 1BBBAA427CA; Wed, 2 Oct 2024 18:50:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E6EDC4CECD; Wed, 2 Oct 2024 18:50:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727895009; bh=ybB7Jq6PT/ZNMBeOogL4z2UfVWt3aicdUam5Wxv2K1c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=jakiBEt2k3OKyDhgEkn9ZhNmc3gm+CSxovyXO4T9s0vMM3vnbfRaX33hpGWtWeGod 0w+jC14ldR+52dDugSmbDba+UaPQ2TlIytUZuco35MeImO8FZ43+OVtnIVSb3oYyr0 qRnTOc+mZADskjg9Nos7u59aZ8n5g8X+hT7Vto9njcHshvaHZ2j5BZH0Dsy0nNXdsK InQ3dJWOAg6ld7Kt2+gtL/D9Fw2TS9P5hgwyOBBpnJ97kuXvKMykbohVnxbW3kQ6zn Chul7ZArrdzfjCAqzCvN1gBoMyY9O2Q4T9cfNc1AOuhh85Ic4xkI6zbzuQ2BJxSaLx e75dB3iQvoWyA== From: Jeff Layton Date: Wed, 02 Oct 2024 14:49:34 -0400 Subject: [PATCH v9 06/12] fs: add percpu counters for significant multigrain timestamp events MIME-Version: 1.0 Message-Id: <20241002-mgtime-v9-6-77e2baad57ac@kernel.org> References: <20241002-mgtime-v9-0-77e2baad57ac@kernel.org> In-Reply-To: <20241002-mgtime-v9-0-77e2baad57ac@kernel.org> To: John Stultz , Thomas Gleixner , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Randy Dunlap , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Chuck Lever , Vadim Fedorenko Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, Jeff Layton X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=3446; i=jlayton@kernel.org; h=from:subject:message-id; bh=ybB7Jq6PT/ZNMBeOogL4z2UfVWt3aicdUam5Wxv2K1c=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBm/ZXMCff1Bu3nV1C9p/EgImanbwC6KH7xo9Z8L WHrsJ1mIgKJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZv2VzAAKCRAADmhBGVaC Fb4LD/9wspekghH2RFnMuwf1MnF4LUapWBw5tZWsQIODmI+2sIhcxzp5USg264EHIX6q5+yoJ/z 8ud9S98Wj3j1G/x5W/4FeqscjDBuelE3urjjbdcNyU4FC6+EENRbn22SvQ1DIxSOy+luToAtjgA 4mbu+gHEBNweGUkg4H6VD3M7PNrqEU8TNotbwvMMtpdHLdcsaG6YdHBgYt6WwSiwJPwlYZv6g// OUPNGen7nqk1dMUyrWVUmpnvaM3ALEJe+3ywkwfu6i1mCIc9JC0EfLoPoAn5+q/z+ydn4FtZj7Z qWp6JQSb9H3SsUyn/KUB2vRVD5yzcG/++qxzeZM7C3umzt5bkC9N69H7Yc7Vc7n8t+uHIZwt863 kai0nolffijAAxKGY6mM8phzDIoqKyAXPoPe2pFaa6Ouf2GFMzdLy/BVb1QDf0gHPs1vlKZI/rZ SlLk+m/pPRYiHQNo0t5RKMv42xtaDSL6dGSePgtDc3oF3E5/jNyRzQQ/w2pZjtKkAkMHef3YP2w c7Qc+U9OJGF1M3aTlL2cOyRSY3m/9pkNMFuioHQ02Hy59Nxo5eZe4gC2PsapgJWjxEIsWLFZEUu 9aDCY97TV11I8B8BJsw/sEHcwFqADXX+vRzYODKX1fqWJAQhmeWUYVWQUAxM4X8ssPWO5mzK9ij Mmdk4UMLqKk2slQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspam-User: X-Stat-Signature: t1stbcopj7m1ersh9ez7rm4b5katzx7m X-Rspamd-Queue-Id: 6FC6E4001D X-Rspamd-Server: rspam11 X-HE-Tag: 1727895010-108592 X-HE-Meta: U2FsdGVkX1+6jII2Sw3euPMWUq5z4nTOXnVbnTImMRXRGUHpYHm9eO50hBSdh3b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sOcJVs+NhEruxnajPGl9mfeGG4nOJFsI5Kr60r5focy4ZzZrwGmzNA11SinxCKyDOId6PWf/ToNWuoerDQ5f0JggmfW65S73RopYpN+lM9bbqsuZSoVOWNGGTf+mPy+2N5vr1W+mvPuT7NJeyaf7V+KAHj960nC+cYApvk7GN21X69gmuWdMwnsJ/HBqXTXmX2u/3qV/RkGGRCisPmG/jd2g= 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: New percpu counters for counting various stats around multigrain timestamp events, and a new debugfs file for displaying them when CONFIG_DEBUG_FS is enabled: - number of attempted ctime updates - number of successful i_ctime_nsec swaps - number of fine-grained timestamp fetches Reviewed-by: Josef Bacik Reviewed-by: Darrick J. Wong Reviewed-by: Jan Kara Tested-by: Randy Dunlap # documentation bits Signed-off-by: Jeff Layton --- fs/inode.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/fs/inode.c b/fs/inode.c index f7a25c511d6b..0223f8ec3cfb 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include #define CREATE_TRACE_POINTS #include @@ -101,6 +103,69 @@ long get_nr_dirty_inodes(void) return nr_dirty > 0 ? nr_dirty : 0; } +#ifdef CONFIG_DEBUG_FS +static DEFINE_PER_CPU(long, mg_ctime_updates); +static DEFINE_PER_CPU(long, mg_fine_stamps); +static DEFINE_PER_CPU(long, mg_ctime_swaps); + +static unsigned long get_mg_ctime_updates(void) +{ + int i; + unsigned long sum = 0; + + for_each_possible_cpu(i) + sum += per_cpu(mg_ctime_updates, i); + return sum; +} + +static unsigned long get_mg_fine_stamps(void) +{ + int i; + unsigned long sum = 0; + + for_each_possible_cpu(i) + sum += per_cpu(mg_fine_stamps, i); + return sum; +} + +static unsigned long get_mg_ctime_swaps(void) +{ + int i; + unsigned long sum = 0; + + for_each_possible_cpu(i) + sum += per_cpu(mg_ctime_swaps, i); + return sum; +} + +#define mgtime_counter_inc(__var) this_cpu_inc(__var) + +static int mgts_show(struct seq_file *s, void *p) +{ + unsigned long ctime_updates = get_mg_ctime_updates(); + unsigned long ctime_swaps = get_mg_ctime_swaps(); + unsigned long fine_stamps = get_mg_fine_stamps(); + + seq_printf(s, "%lu %lu %lu\n", + ctime_updates, ctime_swaps, fine_stamps); + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(mgts); + +static int __init mg_debugfs_init(void) +{ + debugfs_create_file("multigrain_timestamps", S_IFREG | S_IRUGO, NULL, NULL, &mgts_fops); + return 0; +} +late_initcall(mg_debugfs_init); + +#else /* ! CONFIG_DEBUG_FS */ + +#define mgtime_counter_inc(__var) do { } while (0) + +#endif /* CONFIG_DEBUG_FS */ + /* * Handle nr_inode sysctl */ @@ -2689,8 +2754,10 @@ struct timespec64 inode_set_ctime_current(struct inode *inode) if (timespec64_compare(&now, &ctime) <= 0) { ktime_get_real_ts64_mg(&now); now = timestamp_truncate(now, inode); + mgtime_counter_inc(mg_fine_stamps); } } + mgtime_counter_inc(mg_ctime_updates); /* No need to cmpxchg if it's exactly the same */ if (cns == now.tv_nsec && inode->i_ctime_sec == now.tv_sec) { @@ -2704,6 +2771,7 @@ struct timespec64 inode_set_ctime_current(struct inode *inode) /* If swap occurred, then we're (mostly) done */ inode->i_ctime_sec = now.tv_sec; trace_ctime_ns_xchg(inode, cns, now.tv_nsec, cur); + mgtime_counter_inc(mg_ctime_swaps); } else { /* * Was the change due to someone marking the old ctime QUERIED?