From patchwork Tue Oct 1 10:58:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13817773 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 8F0B8CE7D0D for ; Tue, 1 Oct 2024 10:59:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 19BED280070; Tue, 1 Oct 2024 06:59:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12549280068; Tue, 1 Oct 2024 06:59:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDF49280070; Tue, 1 Oct 2024 06:59:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CCA20280068 for ; Tue, 1 Oct 2024 06:59:13 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8D6C7140F41 for ; Tue, 1 Oct 2024 10:59:13 +0000 (UTC) X-FDA: 82624736586.23.547A695 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf14.hostedemail.com (Postfix) with ESMTP id C68E310001D for ; Tue, 1 Oct 2024 10:59:11 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qqCwKBGQ; spf=pass (imf14.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=1727780224; 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: references:dkim-signature; bh=tr7b5vb09XrVU8wucA8PEObVNEzBIv/GfVwXTf+8JVk=; b=hAzE2+jL51gPzjMWXuju1eoT07S3ULTJSHPeCMnXb3Wvgddxc+McN0REkIIodSaj8dmuZk LZyiRI1h8Xc/+lJ7zPBj/SOqjDNTaQueKi3X25lMi4dOT7VpJepu/uUBS49pwjpkpJ63I7 Zed8aiUxggxMeqlJosT6PK78xiK2hiA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727780224; a=rsa-sha256; cv=none; b=AEQ8vcYaHYNDJmRA5cOI0gl88ojEClfVHon8tVk/yuOpp3/YZPo0mfhLF0ZlUp9jpnibqX LErjoAAwvXNmHorlz7CEDcsN/57/60HmtHxnDUaFtvAU02tPcq1HlW0rk0Ze4GEnWxsLpV QmOrRt++7B8V4u33Mq4kccSKMpFoE4s= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qqCwKBGQ; spf=pass (imf14.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 9EDBFA433FA; Tue, 1 Oct 2024 10:59:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13B87C4CEC6; Tue, 1 Oct 2024 10:59:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727780350; bh=VLG6bH+4TEIixDiT/n5phywyTssvqS4L5B6xFjWpTj8=; h=From:Subject:Date:To:Cc:From; b=qqCwKBGQbvG5Y7mZadC21ECsFZNdJvThYEu/Dv+m4Qm2YJpPEw1ehBj3+E4O1j0Hc 34iGuvB+XYv+ko88xtmz50o1jPX4QsFOOAkrGWer9YtYbLYpzNPhoywZWUI3BzXqA8 whBHNvTEoN3TeH7/xY748xHxVmuCN45euqpjyEwh6iY1NiYsepnbjp7qQ/AOssqT3l RTVCurl1yLRKecobCnstz3PKjoBa9+Ypvjkm4bCLf12sScF16s5b/73uHNAXhCpyK2 IxYaT50e5qyd5tbrvVdnRWbi5L/OQmYx5UseY365i6yAeSjqpNVlQbDEquK6M/ssxy GE3ua1LLqdrtA== From: Jeff Layton Subject: [PATCH v8 00/12] fs: multigrain timestamp redux Date: Tue, 01 Oct 2024 06:58:54 -0400 Message-Id: <20241001-mgtime-v8-0-903343d91bc3@kernel.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAO7V+2YC/1WNQQ6CMBBFr0Jmbc1QChRX3sO4oHSEiQKmJY2Gc HcLxqjL9zPvzQyeHJOHQzKDo8CexyGC3iXQdPXQkmAbGSRKhVWaib6duCchsam0aWytNUE8vju 68GMLnc6RO/bT6J5bNxTr+k6Uaf5JhEKgUJpymyljpamPV3ID3faja2FthPLr/bwOZfQqaRVKp Mwg/nnLsrwA+W2M09UAAAA= 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=5473; i=jlayton@kernel.org; h=from:subject:message-id; bh=VLG6bH+4TEIixDiT/n5phywyTssvqS4L5B6xFjWpTj8=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBm+9X51ZWxnSKAlgEHwigtPXgYjKvq2MPxoDofW DNLLrUo8GyJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZvvV+QAKCRAADmhBGVaC FXUnD/9xk4rPMsOtYRJn8MOO+8/wK4SICpYo7lIFsgLUPfBpnAKNP7LkeQCRJUPQ6t0Iqv8CCw1 m1RnSWyApVghZBl1ekTUYvFXl1YmeXaYR658KnqlrzpxjEXHo9gcvc6J4yJ/SzxoNT5U0fbBjdQ BtDokFss63xqrWz6LrlmT4Ei3hS4r8RN9vQ80/F7mmwd4c2hI5QgXOFWMVAebF7OmELcRD57PKi YOyH4RvlM5dyXYaeHLy67DiA3m2DhKqZL20ZiNQtBSZTitLWcWRSHT9/NdKL3FtPT+H2Pp+F3rd n1HSKA9jfXaJpZmxXDY76sxl5l0PEWFL70N9Zm9JzbTxTe8LtQBM3zxWGrf9IQSKODhmAgBigPO KzNevAoKHwDlG6dOVwJYdhv4h7GnutryT8KF7Sn1Zdoakfe5cWfUZ0XL8RK6zvqF62hXkysUwKA PwoLRSMsKyck7oAfJwhOnLEpeReMW6vTT/NzOvB3CYR/bjkUEyB8Mt64SJzuwgZsqKZfUEfdFRu h3GSFEft5mhQOOmKuGyTL6ef3p1Dhz1EbWWdsTy+RS53VvOuLKupj8EvIr91Mvx0IfbVsOUQ7Kq /UnT4LFTEg9ef6a4gimMUdyqdz1I+LxBJ+2iqLGoOCawWztpO0XPrUqk42qzWOIYyxtDqVf+GDu oIN/luq0GQ530aw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Stat-Signature: ixxc1wockoy1yqf9mkkgmoq5g5gu473e X-Rspamd-Queue-Id: C68E310001D X-Rspam-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EW7eu8ZiugBaUUNGMx+SY8KUwSqH/djaZAqXckAXMn5XK6TrgD9laElM3DFiGxX6I2t3pWQBaMq4y1J52F1w34oAkRBPa7seH/JXntFy1VUYtY12/oFlTkpjTWaJX/rHyzj9HGZti8M3sqZdVW3ZnLS9wh3jC76bn6hegoiUyG4wJXK0Wxex5g5tdTTOw43YWQ4AjwF9kf1QxsJQ0c7MA2MDcvwWu6LQ== 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: This is a replacement for the v6 series sitting in Christian's vfs.mgtime branch. The kernel test robot reported a performance regression in v6 due to the changes to current_time(). This patchset addresses that by moving the ctime floor handling into the timekeeper code, which allows us to avoid multiple seqcount loops when fetching and converting times. The basic approach is still the same. The only difference is in where the timestamp floor is handled, and in how we get new timestamps. This reduces the changes to fs/inode.c and avoids a lot of the messiness of handling both timespec64's and ktime_t values. The pipe1_threads test shows these averages on my test rig: v6.11-rc7 103561295 (baseline) v6.11-rc7 + v6 series 95995565 (~7% slower) v6.11-rc7 + v7 series 101357203 (~2% slower) ...so the performance difference here is significant. The main difference between v6 and v7 is in the first two patches, so I've dropped the R-b's from those. The rest I left intact. Note that there is one additional patch in this series (#4) that adds support for handling delegated timestamps. The patches that make use of that are in Chuck's nfsd-next branch. Taking that in here should make that merge easier. R-b's would be welcome (particularly from the timekeeper folks). Signed-off-by: Jeff Layton --- Changes in v8: - split patch that adds percpu counters into fs and timekeeping patches - convert percpu counters to unsigned longs - directly access the offs_real value in timekeeper instead of going through offsets array - drop WARN_ON's in timekeeping patches - better changelogs and more comments for the timekeeping bits - better document how backward realtime clock jumps affect things - Link to v7: https://lore.kernel.org/r/20240913-mgtime-v7-0-92d4020e3b00@kernel.org Changes in v7: - move the floor value handling into timekeeper for better performance - Link to v6: https://lore.kernel.org/r/20240715-mgtime-v6-0-48e5d34bd2ba@kernel.org Changes in v6: - Normalize timespec64 in inode_set_ctime_to_ts - use DEFINE_PER_CPU counters for better vfs consistency - skip ctime cmpxchg if the result means nothing will change - add trace_ctime_xchg_skip to track skipped ctime updates - use __print_flags in ctime_ns_xchg tracepoint - Link to v5: https://lore.kernel.org/r/20240711-mgtime-v5-0-37bb5b465feb@kernel.org Changes in v5: - refetch coarse time in coarse_ctime if not returning floor - timestamp_truncate before swapping new ctime value into place - track floor value as atomic64_t - cleanups to Documentation file - Link to v4: https://lore.kernel.org/r/20240708-mgtime-v4-0-a0f3c6fb57f3@kernel.org Changes in v4: - reordered tracepoint fields for better packing - rework percpu counters again to also count fine grained timestamps - switch to try_cmpxchg for better efficiency - Link to v3: https://lore.kernel.org/r/20240705-mgtime-v3-0-85b2daa9b335@kernel.org Changes in v3: - Drop the conversion of i_ctime fields to ktime_t, and use an unused bit of the i_ctime_nsec field as QUERIED flag. - Better tracepoints for tracking floor and ctime updates - Reworked percpu counters to be more useful - Track floor as monotonic value, which eliminates clock-jump problem Changes in v2: - Added Documentation file - Link to v1: https://lore.kernel.org/r/20240626-mgtime-v1-0-a189352d0f8f@kernel.org --- Jeff Layton (12): timekeeping: add interfaces for handling timestamps with a floor value fs: add infrastructure for multigrain timestamps fs: have setattr_copy handle multigrain timestamps appropriately fs: handle delegated timestamps in setattr_copy_mgtime fs: tracepoints around multigrain timestamp events fs: add percpu counters for significant multigrain timestamp events timekeeping: add percpu counter for tracking floor swap events Documentation: add a new file documenting multigrain timestamps xfs: switch to multigrain timestamps ext4: switch to multigrain timestamps btrfs: convert to multigrain timestamps tmpfs: add support for multigrain timestamps Documentation/filesystems/index.rst | 1 + Documentation/filesystems/multigrain-ts.rst | 125 +++++++++++++ fs/attr.c | 60 +++++- fs/btrfs/file.c | 25 +-- fs/btrfs/super.c | 3 +- fs/ext4/super.c | 2 +- fs/inode.c | 278 +++++++++++++++++++++++++--- fs/stat.c | 42 ++++- fs/xfs/libxfs/xfs_trans_inode.c | 6 +- fs/xfs/xfs_iops.c | 10 +- fs/xfs/xfs_super.c | 2 +- include/linux/fs.h | 36 +++- include/linux/timekeeping.h | 5 + include/trace/events/timestamp.h | 124 +++++++++++++ kernel/time/timekeeping.c | 97 ++++++++++ kernel/time/timekeeping_debug.c | 13 ++ kernel/time/timekeeping_internal.h | 9 + mm/shmem.c | 2 +- 18 files changed, 767 insertions(+), 73 deletions(-) --- base-commit: 9852d85ec9d492ebef56dc5f229416c925758edc change-id: 20240913-mgtime-20c98bcda88e Best regards,