From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3E54386567 for ; Thu, 20 Aug 2026 03:17:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787195863; cv=none; b=nrERaYkk8ngjWibczvd2yadENSzKowcOaMH0gruwN32CVLk03I66QVhmvaGQ/Tr0T5Y0CP/Y/fAvO68wJVKKuNSwXX+MYpZdnEWdSkQFjrUaxlrx6VqyjVeaU/xNV8DjieCKApD6Af9Se9sHLtQh5iYWSqse/fVCiW91DLxDRkA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787195863; c=relaxed/simple; bh=cdk27i7Sg/wqb5ZYQefr9E2star7eWGUvLs9hPxNYfA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GJ944ENDs8zMWKtaKSbwsznVGgJq/AP9Bp3EIBRLv1w2i/m2Km2Vs2Z0EdCXwnkkd9deRZAs+vmDCdCcZg9eZu60TaXmKxSDGiopoXn7xcKwwQBnWgSxf3XQXdrLs1bnLfX2FEUqmEx1nj4sUAenwGEoH5CfqnV2dLkDd7YTdx8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Tg7luIWj; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Tg7luIWj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4BCE1F00A3D; Thu, 20 Aug 2026 03:17:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787195860; bh=lADRimhtawiee5KmYO4UJjxsiC5Zyk3QqnDGPMpfYno=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Tg7luIWjbXIIhtPHAgbv8aId5TWan/r3RnSxQdoTNlmkKQZMYrPwae91XgsTrzylu N3pU0O69uak43kimiWApRTSLNr1n1YUplZ7feiRwEDy3vALaDQGDrTMDR9rvqehR4m s3BgNS2dLtm/5e0pRF9eafMu2QSlWJxsuvrEPJ7cRYvx3mTM7X3dHDTdDRR9sNzE79 mEwpDyxoTS3YFhQ2dYDw1g2aaal/zPmZRyTiFbW46ur2oaN7fCgwQU1OgiXuLsUb3g b0p02wdv5kWJhgMXgUWeE4FoKfCrfnlVe6Gzc/mOsIAqdMYjKpVNKAS33SriERD+Rz wqA33NuQHhsYg== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH v1 11/12] f2fs: cache: introduce tracepoints Date: Thu, 20 Aug 2026 11:17:20 +0800 Message-ID: <20260820031721.12218-12-chao@kernel.org> X-Mailer: git-send-email 2.55.0.737.g08866a6d13-goog In-Reply-To: <20260820031721.12218-1-chao@kernel.org> References: <20260820031721.12218-1-chao@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This patch introduces ftrace tracepoints to observe and profile metadata cache operations: - trace_f2fs_cache_set_dirty to trace marking a cached block dirty - trace_f2fs_write_cache to trace single block writeback submission - trace_f2fs_write_caches to tracesbatch writeback and sync sessions Signed-off-by: Chao Yu --- fs/f2fs/cache.c | 2 ++ fs/f2fs/checkpoint.c | 6 ++++ fs/f2fs/segment.c | 3 ++ include/trace/events/f2fs.h | 71 +++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+) diff --git a/fs/f2fs/cache.c b/fs/f2fs/cache.c index c1e5c945391f..d57adf52c3a5 100644 --- a/fs/f2fs/cache.c +++ b/fs/f2fs/cache.c @@ -16,6 +16,7 @@ #include "f2fs.h" #include "cache.h" #include "node.h" +#include #include "segment.h" void f2fs_cache_wait_writeback_cond(struct f2fs_cached_block *entry, @@ -78,6 +79,7 @@ bool f2fs_mark_cache_dirty(struct f2fs_cached_block *entry) enum count_type type = IS_META_CACHE(cache) ? F2FS_DIRTY_META : F2FS_DIRTY_NODES; + trace_f2fs_cache_set_dirty(entry, IS_META_CACHE(cache) ? META : NODE); f2fs_cache_update_tag(entry, 0, F2FS_CACHE_TAG_DIRTY); inc_page_count(cache->sbi, type); return true; diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 508132652693..8bb3b701ce89 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -550,6 +550,8 @@ static bool __f2fs_write_meta_cache(struct f2fs_cached_block *entry, { struct f2fs_sb_info *sbi = entry->cache->sbi; + trace_f2fs_write_cache(entry, META); + if (unlikely(f2fs_cp_error(sbi))) { if (is_sbi_flag_set(sbi, SBI_IS_CLOSE)) { f2fs_force_clear_cache_dirty(entry); @@ -608,6 +610,8 @@ long f2fs_sync_meta_caches(struct f2fs_sb_info *sbi, long nr_to_write, struct blk_plug plug; bool background = nr_to_write != LONG_MAX; + trace_f2fs_write_caches(sbi, nr_to_write, 0, META); + blk_start_plug(&plug); while ((nr = f2fs_cache_gang_lookup_tag(META_CACHE(sbi), entries, @@ -663,6 +667,8 @@ long f2fs_sync_meta_caches(struct f2fs_sb_info *sbi, long nr_to_write, blk_finish_plug(&plug); + trace_f2fs_write_caches(sbi, nr_to_write, nwritten, META); + return nwritten; } diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 3a585fc7c197..e37d57052b49 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -4170,6 +4170,9 @@ void f2fs_do_write_node_page(unsigned int nid, struct f2fs_io_info *fio) { struct f2fs_summary sum; + if (fio->is_cache) + trace_f2fs_write_cache(fio->cache_entry, NODE); + set_summary(&sum, nid, 0, 0); do_write_page(&sum, fio); diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h index 1dd9fc5afc46..7eb3528d35be 100644 --- a/include/trace/events/f2fs.h +++ b/include/trace/events/f2fs.h @@ -1429,6 +1429,50 @@ DEFINE_EVENT(f2fs__folio, f2fs_set_page_dirty, TP_ARGS(folio, type) ); +DECLARE_EVENT_CLASS(f2fs__cached_block, + + TP_PROTO(struct f2fs_cached_block *block, int type), + + TP_ARGS(block, type), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(pgoff_t, index) + __field(int, type) + __field(int, dirty) + __field(int, uptodate) + ), + + TP_fast_assign( + __entry->dev = block->cache->sbi->sb->s_dev; + __entry->index = block->index; + __entry->type = type; + __entry->dirty = f2fs_cache_test_dirty(block); + __entry->uptodate = f2fs_cache_test_uptodate(block); + ), + + TP_printk("dev = (%d,%d), %s, index = %lu, dirty = %d, uptodate = %d", + show_dev(__entry->dev), + show_block_type(__entry->type), + (unsigned long)__entry->index, + __entry->dirty, + __entry->uptodate) +); + +DEFINE_EVENT(f2fs__cached_block, f2fs_write_cache, + + TP_PROTO(struct f2fs_cached_block *block, int type), + + TP_ARGS(block, type) +); + +DEFINE_EVENT(f2fs__cached_block, f2fs_cache_set_dirty, + + TP_PROTO(struct f2fs_cached_block *block, int type), + + TP_ARGS(block, type) +); + TRACE_EVENT(f2fs_replace_atomic_write_block, TP_PROTO(struct inode *inode, struct inode *cow_inode, pgoff_t index, @@ -1573,6 +1617,33 @@ TRACE_EVENT(f2fs_writepages, __entry->for_sync) ); +TRACE_EVENT(f2fs_write_caches, + + TP_PROTO(struct f2fs_sb_info *sbi, long nr_to_write, long nwritten, int type), + + TP_ARGS(sbi, nr_to_write, nwritten, type), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(long, nr_to_write) + __field(long, nwritten) + __field(int, type) + ), + + TP_fast_assign( + __entry->dev = sbi->sb->s_dev; + __entry->nr_to_write = nr_to_write; + __entry->nwritten = nwritten; + __entry->type = type; + ), + + TP_printk("dev = (%d,%d), %s, nr_to_write = %ld, nwritten = %ld", + show_dev(__entry->dev), + show_block_type(__entry->type), + __entry->nr_to_write, + __entry->nwritten) +); + TRACE_EVENT(f2fs_readpages, TP_PROTO(struct inode *inode, pgoff_t start, unsigned int nrpage), -- 2.49.0 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DC288C5DF82 for ; Thu, 20 Aug 2026 03:18:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:MIME-Version:References:In-Reply-To: Message-ID:Date:To:Sender:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=KeNl0WU6P8VnWmJ0wz3HPy9LiZIr5xhtpA8HsrWIul0=; b=IF4NMCXOmHGno7jhwz36MnoAeU teK2Qwx0CiIa/iQA2wtN2HqBpvGsclLzGoExb2645gb3cTJM5xUvkNHZe8O/icuTwWs05hL3HiuTj Y0MO+X3prbN5WJn44CaVGHBK8HXnk3mbKI9vomb7ok94Bp3WQQI1YSYtsweHxphxWdVg=; Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1wwtIF-0002Mu-RT; Thu, 20 Aug 2026 03:18:16 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1wwtHm-0002LS-Me for linux-f2fs-devel@lists.sourceforge.net; Thu, 20 Aug 2026 03:17:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=lADRimhtawiee5KmYO4UJjxsiC5Zyk3QqnDGPMpfYno=; b=NzX8/z5tFHj2jGd1fbBRBt/KtJ 3oAVe6q7k5OYtD3Whe+hRWCYrBdVVG2Hyn4XwLpmQ6XuwZsI+Pr/JbjP11Q+f9xOiyWjQ7pNjzZDA /c0zatGLpf66vW6c0rOI2QRjJmhHYepeDSI9V1CQgSz8HGTxuenLBaxqqdCN6bPU0Fs0=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=lADRimhtawiee5KmYO4UJjxsiC5Zyk3QqnDGPMpfYno=; b=PmS9f8B6OWeM+D8XAOawG/ucL7 N37Hgd+UCPKgDf3kXkwmauAYqOVN+cKREsf3af2AVKJ0ofxAD3cDdEfxWT+P2PbsVN7sq/vaANOMU rTyLSgpEW67Z+nG0Psnjqqn2x2sKYNTEIMmjFllS/cMoXxdQadgCrGvtgZJU3jCoa51I=; Received: from sea.source.kernel.org ([172.234.252.31]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1wwtHm-00033B-0N for linux-f2fs-devel@lists.sourceforge.net; Thu, 20 Aug 2026 03:17:47 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id B697E43F82 for ; Thu, 20 Aug 2026 03:17:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4BCE1F00A3D; Thu, 20 Aug 2026 03:17:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787195860; bh=lADRimhtawiee5KmYO4UJjxsiC5Zyk3QqnDGPMpfYno=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Tg7luIWjbXIIhtPHAgbv8aId5TWan/r3RnSxQdoTNlmkKQZMYrPwae91XgsTrzylu N3pU0O69uak43kimiWApRTSLNr1n1YUplZ7feiRwEDy3vALaDQGDrTMDR9rvqehR4m s3BgNS2dLtm/5e0pRF9eafMu2QSlWJxsuvrEPJ7cRYvx3mTM7X3dHDTdDRR9sNzE79 mEwpDyxoTS3YFhQ2dYDw1g2aaal/zPmZRyTiFbW46ur2oaN7fCgwQU1OgiXuLsUb3g b0p02wdv5kWJhgMXgUWeE4FoKfCrfnlVe6Gzc/mOsIAqdMYjKpVNKAS33SriERD+Rz wqA33NuQHhsYg== To: jaegeuk@kernel.org Date: Thu, 20 Aug 2026 11:17:20 +0800 Message-ID: <20260820031721.12218-12-chao@kernel.org> X-Mailer: git-send-email 2.55.0.737.g08866a6d13-goog In-Reply-To: <20260820031721.12218-1-chao@kernel.org> References: <20260820031721.12218-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1wwtHm-00033B-0N Subject: [f2fs-dev] [PATCH v1 11/12] f2fs: cache: introduce tracepoints X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Chao Yu via Linux-f2fs-devel Reply-To: Chao Yu Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This patch introduces ftrace tracepoints to observe and profile metadata cache operations: - trace_f2fs_cache_set_dirty to trace marking a cached block dirty - trace_f2fs_write_cache to trace single block writeback submission - trace_f2fs_write_caches to tracesbatch writeback and sync sessions Signed-off-by: Chao Yu --- fs/f2fs/cache.c | 2 ++ fs/f2fs/checkpoint.c | 6 ++++ fs/f2fs/segment.c | 3 ++ include/trace/events/f2fs.h | 71 +++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+) diff --git a/fs/f2fs/cache.c b/fs/f2fs/cache.c index c1e5c945391f..d57adf52c3a5 100644 --- a/fs/f2fs/cache.c +++ b/fs/f2fs/cache.c @@ -16,6 +16,7 @@ #include "f2fs.h" #include "cache.h" #include "node.h" +#include #include "segment.h" void f2fs_cache_wait_writeback_cond(struct f2fs_cached_block *entry, @@ -78,6 +79,7 @@ bool f2fs_mark_cache_dirty(struct f2fs_cached_block *entry) enum count_type type = IS_META_CACHE(cache) ? F2FS_DIRTY_META : F2FS_DIRTY_NODES; + trace_f2fs_cache_set_dirty(entry, IS_META_CACHE(cache) ? META : NODE); f2fs_cache_update_tag(entry, 0, F2FS_CACHE_TAG_DIRTY); inc_page_count(cache->sbi, type); return true; diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 508132652693..8bb3b701ce89 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -550,6 +550,8 @@ static bool __f2fs_write_meta_cache(struct f2fs_cached_block *entry, { struct f2fs_sb_info *sbi = entry->cache->sbi; + trace_f2fs_write_cache(entry, META); + if (unlikely(f2fs_cp_error(sbi))) { if (is_sbi_flag_set(sbi, SBI_IS_CLOSE)) { f2fs_force_clear_cache_dirty(entry); @@ -608,6 +610,8 @@ long f2fs_sync_meta_caches(struct f2fs_sb_info *sbi, long nr_to_write, struct blk_plug plug; bool background = nr_to_write != LONG_MAX; + trace_f2fs_write_caches(sbi, nr_to_write, 0, META); + blk_start_plug(&plug); while ((nr = f2fs_cache_gang_lookup_tag(META_CACHE(sbi), entries, @@ -663,6 +667,8 @@ long f2fs_sync_meta_caches(struct f2fs_sb_info *sbi, long nr_to_write, blk_finish_plug(&plug); + trace_f2fs_write_caches(sbi, nr_to_write, nwritten, META); + return nwritten; } diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 3a585fc7c197..e37d57052b49 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -4170,6 +4170,9 @@ void f2fs_do_write_node_page(unsigned int nid, struct f2fs_io_info *fio) { struct f2fs_summary sum; + if (fio->is_cache) + trace_f2fs_write_cache(fio->cache_entry, NODE); + set_summary(&sum, nid, 0, 0); do_write_page(&sum, fio); diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h index 1dd9fc5afc46..7eb3528d35be 100644 --- a/include/trace/events/f2fs.h +++ b/include/trace/events/f2fs.h @@ -1429,6 +1429,50 @@ DEFINE_EVENT(f2fs__folio, f2fs_set_page_dirty, TP_ARGS(folio, type) ); +DECLARE_EVENT_CLASS(f2fs__cached_block, + + TP_PROTO(struct f2fs_cached_block *block, int type), + + TP_ARGS(block, type), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(pgoff_t, index) + __field(int, type) + __field(int, dirty) + __field(int, uptodate) + ), + + TP_fast_assign( + __entry->dev = block->cache->sbi->sb->s_dev; + __entry->index = block->index; + __entry->type = type; + __entry->dirty = f2fs_cache_test_dirty(block); + __entry->uptodate = f2fs_cache_test_uptodate(block); + ), + + TP_printk("dev = (%d,%d), %s, index = %lu, dirty = %d, uptodate = %d", + show_dev(__entry->dev), + show_block_type(__entry->type), + (unsigned long)__entry->index, + __entry->dirty, + __entry->uptodate) +); + +DEFINE_EVENT(f2fs__cached_block, f2fs_write_cache, + + TP_PROTO(struct f2fs_cached_block *block, int type), + + TP_ARGS(block, type) +); + +DEFINE_EVENT(f2fs__cached_block, f2fs_cache_set_dirty, + + TP_PROTO(struct f2fs_cached_block *block, int type), + + TP_ARGS(block, type) +); + TRACE_EVENT(f2fs_replace_atomic_write_block, TP_PROTO(struct inode *inode, struct inode *cow_inode, pgoff_t index, @@ -1573,6 +1617,33 @@ TRACE_EVENT(f2fs_writepages, __entry->for_sync) ); +TRACE_EVENT(f2fs_write_caches, + + TP_PROTO(struct f2fs_sb_info *sbi, long nr_to_write, long nwritten, int type), + + TP_ARGS(sbi, nr_to_write, nwritten, type), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(long, nr_to_write) + __field(long, nwritten) + __field(int, type) + ), + + TP_fast_assign( + __entry->dev = sbi->sb->s_dev; + __entry->nr_to_write = nr_to_write; + __entry->nwritten = nwritten; + __entry->type = type; + ), + + TP_printk("dev = (%d,%d), %s, nr_to_write = %ld, nwritten = %ld", + show_dev(__entry->dev), + show_block_type(__entry->type), + __entry->nr_to_write, + __entry->nwritten) +); + TRACE_EVENT(f2fs_readpages, TP_PROTO(struct inode *inode, pgoff_t start, unsigned int nrpage), -- 2.49.0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel