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 8F7773E1713 for ; Mon, 31 Aug 2026 09:22:54 +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=1788168176; cv=none; b=Fnh/yiGsscR4bSsL7QlHidmqMZsrt9j6USFZtl4kGWjxTRKs+8FtYq+BOAAruo10uZgJ+84acsg1EfnlaBIMxGUbee47td81gB4vgt9godatumiWXQnZS1KJy9K3vWel0xK7u0Q3Q7VHzPREd7q/eP2xyMC6OwwAxAXiL/PM4fc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788168176; c=relaxed/simple; bh=LH0IMLHWivXqrD4eUZdU7G4+vYwbev8cw3e0aoPKUbE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CQxLfnVjb/31clnjQ4A02/GL4GkJ9bqebsF+ut0HAJAhSJH1SFWQfCeqt0pg2OjlOpC31p/S2JlbGgtzniq3xIpgS4On43IukFfue8jlmrD3N8yMViMoDEnd9cavz0eBdolQxaEvvZwzc+OorT6f0548Qe/Y8uO9p3PfBqOKXAQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z7stTx4E; 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="Z7stTx4E" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B3501F0155B; Mon, 31 Aug 2026 09:22:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788168174; bh=RO+OSb+Cay0e5ijSyfitRBKCIZSK8lnvzq6nie9e0PI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Z7stTx4EAdFK7px1V6jTcgbAm8l0UjsSIVyPzYNP4PqG7ijKbfVQf84WoUoG55XYH svzqAGBtAn+PGAwAQPIVlGi7tB9ilRqN0soH2d2BNGhGdU7YvExr7oQiHRfYWiAQ1x zlvE1Wc9zlH5rK/cVnFODOp9ISs7e01kVZGu+Qvaa8eu6hjZZGMUUujuSh9K84SUM5 6bTqNvHEkd50USbIY+8ziPdQzrsmyKE9fWTGEo2UwiwTkKOYQ7I18NF7C4JzZ39duy P0GNf3ITOtWwc2PaqehmvZvO4EMYQaX/t9aMmdm6aoNicirU6CNmPIziK4iUjTWhVm 8Dx/EmDg7e5YQ== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH v5 11/12] f2fs: cache: introduce tracepoints Date: Mon, 31 Aug 2026 17:22:26 +0800 Message-ID: <20260831092227.739737-12-chao@kernel.org> X-Mailer: git-send-email 2.55.0.897.gb25b4bd76c-goog In-Reply-To: <20260831092227.739737-1-chao@kernel.org> References: <20260831092227.739737-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 From: Chao Yu 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 | 3 ++ fs/f2fs/checkpoint.c | 6 ++++ fs/f2fs/segment.c | 3 ++ include/trace/events/f2fs.h | 71 +++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+) diff --git a/fs/f2fs/cache.c b/fs/f2fs/cache.c index 8276682d6af8..88e941b44e38 100644 --- a/fs/f2fs/cache.c +++ b/fs/f2fs/cache.c @@ -15,6 +15,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, @@ -76,6 +77,8 @@ 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, F2FS_CACHE_TAG_NONE, F2FS_CACHE_TAG_DIRTY); inc_page_count(cache->sbi, type); diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 29f5ad50611a..037465e34190 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -551,6 +551,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); @@ -609,6 +611,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, @@ -664,6 +668,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 a3a5024f904b..9eda920d61e5 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -4169,6 +4169,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 d53be932df01..df4cd346ae72 100644 --- a/include/trace/events/f2fs.h +++ b/include/trace/events/f2fs.h @@ -1430,6 +1430,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, @@ -1574,6 +1618,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