From patchwork Thu Jun 27 01:00:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13713677 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 9047FC30653 for ; Thu, 27 Jun 2024 01:00:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 191FB6B00B8; Wed, 26 Jun 2024 21:00:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1420D6B00BB; Wed, 26 Jun 2024 21:00:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EAF896B00BC; Wed, 26 Jun 2024 21:00:51 -0400 (EDT) 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 C16A06B00B8 for ; Wed, 26 Jun 2024 21:00:51 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 66E3FC1868 for ; Thu, 27 Jun 2024 01:00:51 +0000 (UTC) X-FDA: 82274863902.03.39679BD Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf18.hostedemail.com (Postfix) with ESMTP id ECE331C0005 for ; Thu, 27 Jun 2024 01:00:48 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=B2qBsDkL; spf=pass (imf18.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719450040; 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=dqvbR/ksUpOrrPO+D5G3n1uKBNVPH7yx2hwqQYkG+mc=; b=6HjEE4EVue/CpyQ5DjaUwN1N0qLiGmK/qNlJI0AghvtrHCrSNoEmZwO6uV+TNj84mETwYj rr37KP6Kd5eezWjGZzoVFf0sL6wi/OU8vttfnzlQKBLFdBqYtLTTztRaxZ8IPghCwqoF1h 9V80R/aRJ0fR9iQ2wCo+4aepBjnicMo= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=B2qBsDkL; spf=pass (imf18.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719450040; a=rsa-sha256; cv=none; b=KgpK1JO0NYDzF5ZrWmDZyAiomq6kisR/fywodSV3jL8lO3NR6DMU3TpktdYkRCDdNgPPtH +Mgm2ovLuw+69jYiSPQPLz+OeqOvl4wx5XxaJV0Fgove0KFLnKXluPhhX0XmyGDrSay8gO 6hp2PBeknFHnCZcz+mTp84px2rNhe/U= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 41C38CE2D2C; Thu, 27 Jun 2024 01:00:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FBB2C4AF0B; Thu, 27 Jun 2024 01:00:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719450045; bh=alV5zibd2F0pMNbUX/mWZ+tG97f9Xo1V9J1WqjSbP8A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=B2qBsDkL0dxLN9WUghKk/yCHEP7gA4zZFWEppqkoSjuXlX1Ly40r0xAI0yucOKYj2 HkDxytNHwn6CwxUDEusjmW+bsaESAP8HANhfrp4Hj6j9T2veupYhwNtdMLFVItDMXy j2AzGP0bDuO5MEAcmbTEA8R6/zOCUPOj1CJK3xDa2DXG6IVhGxDkzhdSDwRe61LRAX 5Bhrp4Fg9F3xougTOgKp/XrG031v71BPC58JJcUR1kCgeVG73za33yIuZXm6I36dPO 7FIbSwBzm1okS9/gCa3hCBqZ0AcgJiP9QpSZYiFE/bURPowb8jz+OV5NoVTfNtlZKW aqydfCIOCqxvw== From: Jeff Layton Date: Wed, 26 Jun 2024 21:00:25 -0400 Subject: [PATCH 05/10] fs: add percpu counters to count fine vs. coarse timestamps MIME-Version: 1.0 Message-Id: <20240626-mgtime-v1-5-a189352d0f8f@kernel.org> References: <20240626-mgtime-v1-0-a189352d0f8f@kernel.org> In-Reply-To: <20240626-mgtime-v1-0-a189352d0f8f@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton Cc: kernel-team@fb.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2307; i=jlayton@kernel.org; h=from:subject:message-id; bh=alV5zibd2F0pMNbUX/mWZ+tG97f9Xo1V9J1WqjSbP8A=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmfLmvP3m8cgNO12xHkX/kvGeeOvTHePjzc/p9E 73Z0udL2yeJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZny5rwAKCRAADmhBGVaC FVlYD/4q+QmTQ2BI3Y18pmSgyzhp+KsUaATjRNzT+mnMep2m7m1Gs2NuvWMCE7ogykMMDOjDMsJ sNvujib/blGj7gu3gYUWWOvZxnG34l4mhlVhdGs6xANPbLR5FMECfrsa5uQdJMLzuqOPgNnOhzU XieSHD6nsA4r4Hmqii/LDHKEwCU2HlAhtEgwdMOjVcQzKHiHoxuH03WR6yZaEzw1da20OJs5I8N B+gsf15KKvItUFHdBLu53BeVIVaAklaFg4DWvJm6MaxweD2QSVAjQ9Knf5dYJm4f29NcjElQ/pV V+hmOYJPtu3L5Dj9txMdu5fH5b4tOHT8a41rNL/eyU9PUta0GQX2uWHh7HLEZErUSiK7z4f1+tZ SMmcj45nVV6QYF+RMcnXcRG0aJGDxT9pNGhkkUhDmxNqdoAFbIwEGw2bbAEfpAx4lkWlHltyOE/ C3RWGGnPKRRHCBOXnb76vJHiDsT1yG3EyzsQEVCSnKohcNYKBcYMI6a0PnpL4QfyHqq8wZi2+f9 ZFGXq9RdXZPuIR4UwZt/YZE5SRl5MznqGcYcMVcU86xVjMkFUKKkDglI8O6xhHBbUw7CxN6GRiu DNbxDJGy3MTBLASlA+MkUOayWh4rJcPzch7NEoW2ex55o0g2b8Lg/qrEEVnEIGuk9Eo6/H8WmZh eav0qapDN1tVzpA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: ECE331C0005 X-Stat-Signature: bws7ff1sm4tpbhosxgo9mmi19mkymj5d X-Rspam-User: X-HE-Tag: 1719450048-520864 X-HE-Meta: U2FsdGVkX1+XNm3bAcDPFOK2M6ItbbUnQTY78PjydTQme7nbOG/CNTcWrUbx2FBozbkgn6EMI4AoXgAZ1lLYW+3JA83hNtWQBJbU45bCnBEwFWb5QQ36n/57D1KPpq1NE6ADf97W0NJhAWrOF1+EwSDJ2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G0/F3b4t0ieWJIAOhn9rOXXwQQc2fRnDkkd6fwmskJ9E 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: Keep a pair of percpu counters so we can track what proportion of timestamps is fine-grained. Signed-off-by: Jeff Layton --- fs/inode.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/fs/inode.c b/fs/inode.c index 12790a26102c..18a9d1398773 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include #define CREATE_TRACE_POINTS #include @@ -64,6 +66,11 @@ static __cacheline_aligned_in_smp DEFINE_SPINLOCK(inode_hash_lock); /* Don't send out a ctime lower than this (modulo backward clock jumps). */ static __cacheline_aligned_in_smp ktime_t ctime_floor; + +/* Keep track of the number of fine vs. coarse timestamp fetches */ +static struct percpu_counter mg_fine_ts; +static struct percpu_counter mg_coarse_ts; + /* * Empty aops. Can be used for the cases where the user does not * define any of the address_space operations. @@ -2636,6 +2643,9 @@ struct timespec64 inode_set_ctime_current(struct inode *inode) trace_ctime_floor_update(inode, floor, now, old); if (old != floor) now = old; + percpu_counter_inc(&mg_fine_ts); + } else { + percpu_counter_inc(&mg_coarse_ts); } retry: /* Try to swap the ctime into place. */ @@ -2711,3 +2721,32 @@ umode_t mode_strip_sgid(struct mnt_idmap *idmap, return mode & ~S_ISGID; } EXPORT_SYMBOL(mode_strip_sgid); + +static int mgts_show(struct seq_file *s, void *p) +{ + u64 fine = percpu_counter_sum(&mg_fine_ts); + u64 coarse = percpu_counter_sum(&mg_coarse_ts); + + seq_printf(s, "%llu %llu\n", fine, coarse); + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(mgts); + +static int __init mg_debugfs_init(void) +{ + int ret = percpu_counter_init(&mg_fine_ts, 0, GFP_KERNEL); + + if (ret) + return ret; + + ret = percpu_counter_init(&mg_coarse_ts, 0, GFP_KERNEL); + if (ret) { + percpu_counter_destroy(&mg_fine_ts); + return ret; + } + + debugfs_create_file("multigrain_timestamps", S_IFREG | S_IRUGO, NULL, NULL, &mgts_fops); + return 0; +} +late_initcall(mg_debugfs_init);