From mboxrd@z Thu Jan 1 00:00:00 1970 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 360DCC3DA41 for ; Fri, 5 Jul 2024 17:03:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6DC176B009F; Fri, 5 Jul 2024 13:03:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 668B86B00A0; Fri, 5 Jul 2024 13:03:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48DA26B00A1; Fri, 5 Jul 2024 13:03:08 -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 1AA6F6B009F for ; Fri, 5 Jul 2024 13:03:08 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C09CA802CF for ; Fri, 5 Jul 2024 17:03:07 +0000 (UTC) X-FDA: 82306319214.07.26CF1D7 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id C30AC8002A for ; Fri, 5 Jul 2024 17:03:05 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DNNqRxxG; spf=pass (imf02.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 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=1720198965; 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=6gc5xFi1PzoJqcDWQttptvMjlFkvz91LoSIRbtc1mqM=; b=lWeTJ5aPT2mTS5hfz+rv6kzSRO+z+j6sYN9HYPNygV6oh/hCjDZCfSA9n/NsbF3trgPu0z GECUUF1omRrllHDBJlNsqa/JHuuLfjz3zg0D/uVgYbn7q9beiN15WitT6GdxHgqjj/ZZoo I1Q2Hxjreo+ML+w8qx1XAI5ZyM+DOTs= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DNNqRxxG; spf=pass (imf02.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 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=1720198965; a=rsa-sha256; cv=none; b=QoeRlrv9cuGh1wz8qUhz5cqbN2/54Kv3uEOiY6YwdbXkTLt5ki+hSq2rKO8Ace0nEb4MRy 01XjyKlKbn/+hozdMCPRXsCnAu+xTLC90yr4kcX3PJG8RlG6lwjQLBTO9IJ45Mxw4jUG36 g50qz05tAIKEuHjdmlCZ+/jxstAtYao= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E798162C29; Fri, 5 Jul 2024 17:03:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48923C4AF50; Fri, 5 Jul 2024 17:03:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720198984; bh=+1OK0xDU8G2id45dYRlr32i7detxgV/LcM9BvZ/n97g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=DNNqRxxGHO2l4hhgMZOJMofVeLsl83SaLoA4KkS5nEgKlJ0pS0A8N+2rNxaioxT7+ CiFK+0AmFofAfVZs+rMS9qrqHOgg0cfKitBFhCBCtIn749P6sRp1IHp9ti9A/Hhnf4 vn3ob6MrGjJ/X0lncPcmZyt4UeEwBXTiR06bbxI3+ZDSLvuqJ5aKzBOiAd/DqRcPvd FZJYkk/KuuiLgsRwX+b7/RXis4CLt9jJYZFNODl5tGvZiwKGwmRgoXbbIKOyRV8ZrF /VI6OGDuR+/+HfUPSu+3EIFe372dvyPYeFE/K9TqGAcCA0T/B2GJhWjVdg5EybMTwF buKVApYBc0XUg== From: Jeff Layton Date: Fri, 05 Jul 2024 13:02:37 -0400 Subject: [PATCH v3 3/9] fs: add percpu counters to count fine vs. coarse timestamps MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240705-mgtime-v3-3-85b2daa9b335@kernel.org> References: <20240705-mgtime-v3-0-85b2daa9b335@kernel.org> In-Reply-To: <20240705-mgtime-v3-0-85b2daa9b335@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 , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , 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, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3096; i=jlayton@kernel.org; h=from:subject:message-id; bh=+1OK0xDU8G2id45dYRlr32i7detxgV/LcM9BvZ/n97g=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmiCc9NpIqArIlvQ4m695T/o+BYLlZdPbZsZCBm 5bymx7blxGJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZognPQAKCRAADmhBGVaC FbXsD/0S1Bkq6Yz6RSyvaCXFu41T9zBOdd/yMsk5WBlsV5ppRy2jxalIc7hhIAH2yAxNRTiW6AD Fs6Q6+/UensT2Wt3JluZVcZnHjaR4mL/Xt23H2ZuIYL3owWxb2kQkZG6EfaOi4ASqNpv1fS3V5B /0DQkwBfkoD+9RrlkdTJ/EY4vUOVvHN5sHVA44yTEhF8K/IT9R3HoyBTLWkwNI1qpRuZGUh8UZq Zb5qZxrocLXCzs9Ay7qb+WCTjP51ng3xmTY0KgcH1K81TFGNhvNraGBtwF4FGxaB6AOt6UqWxkI YOeDijkYylcOHaA4l7xnstdm71Ia1CPlNbQEw7hmxhpwD0DKmXUFWBNUP9Uuu4gdY0Ma6JdlIod pi+Vp5JXL2z2rhNNpjATuCqHocDFDEj1RFijUY2vF9cLLwgjvyEbx7DukXeFuC98jL3YaiJE1cS g6zsqYzFfjN/34zAJo2ooq1x5vGIW42JVCJdx9iVK3E7Mi8YhU42jKEmk2+Ci7WXqxdu4/yp0XJ pERG93gcMk25kcaVssOjMAHGeQr9GHwl8TkraT9olc59qhGXmfiycf9MqmfgbVLKSbecBPGNS5u WKpNuOESwnEZO0RKQadcRLJLenjgMmQtpb/DggW2mSevrnANhab5pDD9tB0/C0qlqvmlhfdWpbJ ySj1wc4LTu71FoQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Stat-Signature: mfjygxuskxbzj7mpc69btqhubnaz8dkr X-Rspam-User: X-Rspamd-Queue-Id: C30AC8002A X-Rspamd-Server: rspam02 X-HE-Tag: 1720198985-552065 X-HE-Meta: U2FsdGVkX1+exAB1o6xgEBLOEABPjdneeiqijmZOZDEUgrj1c5wiafY+TSmdfZIhmKy1P9u7rs1HR5OKxrqYearPx/yfvNnaXLVPoUbLPsdjgUd7qcAIem7zQmbH0pA6Y+DAQPr72u6TQZo6R+i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7mM6oMX67z6nUeguhQ8b7Oij9sAwJ4QR0yfpMpOECDLtu/WdIxynwL6AL+/4c8Z 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 | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/fs/inode.c b/fs/inode.c index 4ab7aee3558c..2e5610ebb205 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include #define CREATE_TRACE_POINTS #include @@ -69,6 +71,11 @@ static __cacheline_aligned_in_smp DEFINE_SPINLOCK(inode_hash_lock); * converted to the realtime clock on an as-needed basis. */ static __cacheline_aligned_in_smp ktime_t ctime_floor; + +static struct percpu_counter mg_ctime_updates; +static struct percpu_counter mg_floor_swaps; +static struct percpu_counter mg_ctime_swaps; + /* * Empty aops. Can be used for the cases where the user does not * define any of the address_space operations. @@ -2662,11 +2669,14 @@ struct timespec64 inode_set_ctime_current(struct inode *inode) * as good, so keep it. */ old = cmpxchg(&ctime_floor, floor, fine); - if (old != floor) + if (old == floor) + percpu_counter_inc(&mg_floor_swaps); + else fine = old; now = ktime_mono_to_real(fine); } } + percpu_counter_inc(&mg_ctime_updates); now_ts = ktime_to_timespec64(now); retry: /* Try to swap the nsec value into place. */ @@ -2676,6 +2686,7 @@ struct timespec64 inode_set_ctime_current(struct inode *inode) /* If swap occurred, then we're (mostly) done */ if (cur == cns) { inode->i_ctime_sec = now_ts.tv_sec; + percpu_counter_inc(&mg_ctime_swaps); } else { /* * Was the change due to someone marking the old ctime QUERIED? @@ -2745,3 +2756,39 @@ 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 ctime_updates = percpu_counter_sum(&mg_ctime_updates); + u64 floor_swaps = percpu_counter_sum(&mg_floor_swaps); + u64 ctime_swaps = percpu_counter_sum(&mg_ctime_swaps); + + seq_printf(s, "%llu %llu %llu\n", ctime_updates, ctime_swaps, floor_swaps); + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(mgts); + +static int __init mg_debugfs_init(void) +{ + int ret = percpu_counter_init(&mg_ctime_updates, 0, GFP_KERNEL); + + if (ret) + return ret; + + ret = percpu_counter_init(&mg_floor_swaps, 0, GFP_KERNEL); + if (ret) { + percpu_counter_destroy(&mg_ctime_updates); + return ret; + } + + ret = percpu_counter_init(&mg_ctime_swaps, 0, GFP_KERNEL); + if (ret) { + percpu_counter_destroy(&mg_floor_swaps); + percpu_counter_destroy(&mg_ctime_updates); + return ret; + } + debugfs_create_file("multigrain_timestamps", S_IFREG | S_IRUGO, NULL, NULL, &mgts_fops); + return 0; +} +late_initcall(mg_debugfs_init); -- 2.45.2