From patchwork Wed Oct 18 17:41:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13427577 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 E9D1CCDB47E for ; Wed, 18 Oct 2023 17:41:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D6C08D0178; Wed, 18 Oct 2023 13:41:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 785588D0016; Wed, 18 Oct 2023 13:41:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 625AF8D0178; Wed, 18 Oct 2023 13:41:42 -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 4C4528D0016 for ; Wed, 18 Oct 2023 13:41:42 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 130D31A03EE for ; Wed, 18 Oct 2023 17:41:42 +0000 (UTC) X-FDA: 81359299644.02.DD0B380 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf30.hostedemail.com (Postfix) with ESMTP id 421F580010 for ; Wed, 18 Oct 2023 17:41:40 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GcpsqU3P; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf30.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697650900; 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=GwidXsdVI70LROKQV78+/AtnjaNX0OCUTFQHQNNMJNo=; b=KSFbWnTID7WBOL/q6GOCXhdSgZqKc7YfrzlyZnr47yRW3geD/MhSvvk+rozR73rMDiz2CX sUGKQPfmY1Hg78xWff5pNQkn/HJZdDxT62QxhgjTAlkB7oNIMthX+CNqaahema/QyDpRFl HeHbDzv9SHH/N9xhuo6vjIqzIA8QM/Q= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GcpsqU3P; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf30.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697650900; a=rsa-sha256; cv=none; b=HXP5VLHU3yf/p9RCYuXk4VPeR3kh7Re39zpCNTewhapazBzcZwQWI5bsrQ3n5mztt14DLL TrGPtBSiMjyDzOp8mgIfD6H3kyqSk2aDaPBww7N2lmvNUXDcSVCbWyvXWRn3WOmYjJRBmL hhlygLE2wLtThFb+I+3SVHtt3/CVujM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 711DC618B4; Wed, 18 Oct 2023 17:41:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1BBFC433D9; Wed, 18 Oct 2023 17:41:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697650899; bh=oV0lFdI7Yn7QJ5JE87c+C5HW+Uto4gEIDr/OnGVhofo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GcpsqU3PkpNElzrRNZAh3XTjk9L9FU1ZFKJ0Nuy36O4dTnIGzGvLmzqNHSEPu56yj fwpfkupeILBixno66h7UwaC+ESWCL5Mn9+PHSEDIe/d39R2QJtMWQdIk9dtKO+8mBv fs9yJoR0RLy47E5axLbnbDIwRRY/K92Ahi/zp/JiYqTrHQqZBsRgMsLEMiI58WmFY7 CPOULDJXAtNvZY2Y4tUNSA5fdezHHf+X+L8uPAgCasaFp2dpwPzXlw41p5JMyEMgSF V8IDjIp+cpdNbLf2y+84w2Z35QTu7OAnQl+JskaMxc+mKp7GxaRqPDtAUViX1j0jwi 1qYxkdVgrYioQ== From: Jeff Layton Date: Wed, 18 Oct 2023 13:41:10 -0400 Subject: [PATCH RFC 3/9] timekeeping: add new debugfs file to count multigrain timestamps MIME-Version: 1.0 Message-Id: <20231018-mgtime-v1-3-4a7a97b1f482@kernel.org> References: <20231018-mgtime-v1-0-4a7a97b1f482@kernel.org> In-Reply-To: <20231018-mgtime-v1-0-4a7a97b1f482@kernel.org> To: Linus Torvalds , Alexander Viro , Christian Brauner , John Stultz , Thomas Gleixner , Stephen Boyd , Chandan Babu R , "Darrick J. Wong" , Dave Chinner , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Amir Goldstein , Jan Kara , David Howells Cc: linux-fsdevel@vger.kernel.org, linux-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.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2249; i=jlayton@kernel.org; h=from:subject:message-id; bh=oV0lFdI7Yn7QJ5JE87c+C5HW+Uto4gEIDr/OnGVhofo=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlMBjIZJAEh2EvSWsTRIXNUoSp+/gPrdnrW38DM 8NdE4JkFmWJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZTAYyAAKCRAADmhBGVaC FYbiD/0ZFfWVcuSGUPgSgemJY2MzGuMffXnd/jkl+/NHQ1nlRsWS01DWyVwdWucUQasEC1H0rdI 5uXOT2GcTX/68+GO+2tqvb1JlhSnujcLZm1Lg456xiDlllxlwIhZ9tZrlYVCOrYuP8jEqXYvjZU V+pX3XjE/kpytbDpv4jBNXvd33alsrO1+bznAl0pM2sOm/dVXZQSQ8NYrpztvxjJk5qNLqUPS7Z U77qUZBIXUm2mQR8NpLwL471ld2/NmDB4pWDRjvCl9+E9LUaKW68g5iDdMrP1FYZEgo5nuBug26 G9gk1+WG8MzsHsYFl6ELLbS2zBVqoMtrdqt568EogG7jT0bV9ZMQdIYySUOXW4QYfw8xmG5gMep x76CG8p1DUeFingRztj1TLljnTJOBjvvu6/y4uHysrrk48R5ZJgW10j9GNfzFxlmWLjzROb5uq1 DrLstWJYcyyzYThiFx6ceWhtadCHD8oOozKVH0QwA2Iz6TUjCXq4wmT/TUthsNQ64iTwZKIscuS i8Te9fkr7v+sjrBd7L3KROqoW+H82LEsMIQaJGP7fXOLTpmGndcbF9RRWYs3TY48ha1YUBvq1tG mr5XAlH/ldtbzv9DCdGsn+zCmXwMuFoPEEiGSzhQzKBi1Xi62s7eCGftf2cmFcAvZBqTr8ByLyl avNZl9vDKp3Z4KQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 421F580010 X-Stat-Signature: qp7z8c8csg7khx1sa13rnkxx1s7gj5xs X-HE-Tag: 1697650900-47113 X-HE-Meta: U2FsdGVkX1/HladBBFDVNl6avAlNEoo47s0JFEqYZGrpYQcjjZBwfro/YGKkx4j9Ywh1sRX7QzTpSLNhl+A4B3m25oUhLOFc81Dfr9iooDjiF91K/ZmtBeQUYrK/F/zJKegjZvtzIvXI1+YC0PUNlFadOyU3qhwLfxErp0l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+O4445hxSLQO9uIzOjt8Edl6l02S0A7XVaIunjS 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: Add two percpu counters for tracking multigrain timestamps -- one for coarse-grained timestamps and one for fine-grained ones. Add a new debugfs file for summing them and outputting the result. Signed-off-by: Jeff Layton --- kernel/time/timekeeping.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 7c20c98b1ea8..c843838cb643 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include "tick-internal.h" #include "ntp_internal.h" @@ -59,6 +61,9 @@ static struct { static struct timekeeper shadow_timekeeper; +struct percpu_counter mg_fine_ts; +struct percpu_counter mg_coarse_ts; + /* flag for if timekeeping is suspended */ int __read_mostly timekeeping_suspended; @@ -2326,6 +2331,7 @@ void ktime_get_mg_fine_ts64(struct timespec64 *ts) ts->tv_nsec = 0; timespec64_add_ns(ts, nsecs); + percpu_counter_inc(&mg_fine_ts); } /** @@ -2361,6 +2367,7 @@ void ktime_get_mg_coarse_ts64(struct timespec64 *ts) ts->tv_nsec = 0; timespec64_add_ns(ts, nsec); } + percpu_counter_inc(&mg_coarse_ts); } /* @@ -2581,3 +2588,33 @@ void hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_ts) } EXPORT_SYMBOL(hardpps); #endif /* CONFIG_NTP_PPS */ + +static int fgts_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(fgts); + +static int __init tk_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, &fgts_fops); + return 0; +} +late_initcall(tk_debugfs_init);