From patchwork Mon Jul 1 10:26:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13717786 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 4440EC2BD09 for ; Mon, 1 Jul 2024 10:27:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 879846B009F; Mon, 1 Jul 2024 06:27:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8029E6B00A1; Mon, 1 Jul 2024 06:27:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E1486B00A2; Mon, 1 Jul 2024 06:27:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 34E236B009F for ; Mon, 1 Jul 2024 06:27:26 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B1479A1B17 for ; Mon, 1 Jul 2024 10:27:25 +0000 (UTC) X-FDA: 82290806850.29.A160D2A Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf24.hostedemail.com (Postfix) with ESMTP id 3EAFE180018 for ; Mon, 1 Jul 2024 10:27:22 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=se0TP++U; spf=pass (imf24.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=1719829633; 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=v+o9ZKQHoAFrsB1RwNJWn7d7I26VkGC4qWULKLYnDpk=; b=8N9ks8C8ZN9EISh5HitXLm+esPToSBeDi7Ors28ULy3Az7mOQYA76jnYZilOJwLEbp4jxN PxZlED9bSGJzoABKIotyIVL1nRl90s3VPzFxP/faH6JvQcy0OMLPZy+xJdhc3y5IWzlWHN yzKutqgBc+PUABdN91THeKycXewnhys= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=se0TP++U; spf=pass (imf24.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=1719829633; a=rsa-sha256; cv=none; b=qi9Nplc6aa9yUv+ZCoO4/16GfXmCXz3D2HuS3C2lkAwW62Lc/Ghp0zNPZfDEe+/SZEDsTT M6FOT76VBEn6BPQDCIDhMHzztzKMhF//JYwzNKLkk/1cRwiacHaOJ6ZTTB7doHmVGk9U2s ia971/G6LBRLfBNuNyNoBtTwMU598w8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 70636CE1177; Mon, 1 Jul 2024 10:27:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1685C4AF0F; Mon, 1 Jul 2024 10:27:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719829639; bh=JWRcJeXc6fXcX2y9b+IE3C2Bm9hRJGE2VXVsCkiQEEs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=se0TP++UJvdc9tTwQYDWqPXK5SsoCVQEe8u53ed6hPWPwfOgnV88jaGfk7sTo2eXL nRY8Iw2KVokCOgKmtjXDKPs2VPCxAu8K40B7e9mMhjpiFChsUkptNZ24fsETyJsWp7 5D2pKr6uJKJohwPP+TgVb9bw2jPKI/Yo9aiC+RYFhFHGudB/p3G5Ml7axOb0rU+o/w wFDC7qDsqDCY2oZ+aW2yd3pLVq6BOzINc57Ooz542ufQe902LOAsamYyzUvesAO/68 gLkjwevJtszygqTdxvRSNkvVRfseGT4a+O9+IfgapnQnk9HZsFnrF4NiHMXOmaD2Cx ApGhjU0KxyCyA== From: Jeff Layton Date: Mon, 01 Jul 2024 06:26:41 -0400 Subject: [PATCH v2 05/11] fs: add percpu counters to count fine vs. coarse timestamps MIME-Version: 1.0 Message-Id: <20240701-mgtime-v2-5-19d412a940d9@kernel.org> References: <20240701-mgtime-v2-0-19d412a940d9@kernel.org> In-Reply-To: <20240701-mgtime-v2-0-19d412a940d9@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: Andi Kleen , 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=2236; i=jlayton@kernel.org; h=from:subject:message-id; bh=JWRcJeXc6fXcX2y9b+IE3C2Bm9hRJGE2VXVsCkiQEEs=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmgoR4nLWjcXTKYRX92RbOTrFgWknM7qS0hOAxr IJZCQkOSZyJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZoKEeAAKCRAADmhBGVaC FfCmEACKq11QB244lQsJ4wjlEbpNH5+UfFQoAsuVPJp5dxRHy58bwatwzEoStmos+TxpRPReuYO BZjYKqcEMxqby1upgyyi89Q5zEcjY4WURlCYdJljzTmfLmwOxWxQSEPqAnD59ClVzeTCtubwg/9 shcH+Zved1qwW9PV+wgOieb8ctvp5cvV/kLLH4Wf7tHxSELULTrGMj4ZCQnJ/Fwkg78BzW5cSXw MKJM6eQnTkYJ/qtsUFgTTqJVnoAd5GYRkotdtq5qHMu7mpa+kjTA3rRml4h+EprFZ+9KgM7iKn7 BtSyY34jgzUZ7Y7j6mfanIFxe9wKcPN6QJO4xixne5zYaMza+GpFleQdtl5KMqw3qMkR8cJWPVw MUfT4rPv1o6Pwh1fNhqiH1mM2sn3PTbYaYKRzqV1UZg4wdICMImwMvZwQOWS9wtReEdWgUdaFV5 FcbwT2b4VRyf0gmqgjhOH5IcWz5ga4SiIfxyUt6yooXr5maDt+gzF+3d5Iz6FwPZB1opA37HRfO 4lSGU+7r1Mw2ddmhvir8Ou7hyu5rbN3QZtxiqllJUt1EjD74o7zu8+l5kEMUPKh7hyEl0qRrwL2 OtN2Sp+jGr24JxTcjGfdSrCSRgQK8wGLxb91PP9SWu2lTnLgC6ejX/I6eIDgdOwqb8OKfVyiSPW b6R2CXcnj8f+Hfw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 3EAFE180018 X-Stat-Signature: qwbdqtnz1oa4ra1w5q9y6jowd53gptuf X-HE-Tag: 1719829642-41372 X-HE-Meta: U2FsdGVkX1+RPvlx7gbBFJvTKmYorSZI73RxedqojypG2QC39pgEj7TuUCKnrexaRZgIJUjOIUmKo64mlZw3WUYcxrrtxlaA1hS1tCmN2LzICvaXprz4xEihkUILnu3AkHHgVP4Xx/IzK/csdf8j3vxPgjVPSXofwWj4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p7Lso8QTSwJognCtJfYxYd8tJHuOd0pVQM/Ikssw9M86Wl6MZjuu 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 | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/fs/inode.c b/fs/inode.c index 12790a26102c..5b5a1a8c0bb7 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,10 @@ 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; + +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 +2642,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 +2720,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);