[f2fs-dev] [RFC PATCH v4 3/3] f2fs: introduce tracepoints for inline extent lookup and update

Yongpeng Yang <[email protected]> Thu, 6 Aug 2026 21:19:05 +0800
Newsgroups net.sourceforge.lists.linux-f2fs-devel
Message-ID <[email protected]>
From: Yongpeng Yang <[email protected]>

Add tracepoints to aid performance analysis and debugging of the
inline extent mechanism:

- trace_f2fs_iext_lookup_blkaddr_start: fired at the beginning of an
  inline extent lookup, recording the inode and logical block offset.

- trace_f2fs_iext_lookup_blkaddr_end: fired on successful lookup,
  recording the inode, logical offset, resolved physical block address,
  and extent length.

- trace_f2fs_iext_update_data_blkaddr: fired when updating a block
  mapping in the inline extent area, recording the inode, logical
  offset, and new physical block address.

These tracepoints can be used with ftrace/perf to measure inline
extent cache hit rates and identify hot files benefiting from the
feature.

Signed-off-by: Yongpeng Yang <[email protected]>
---
 fs/f2fs/iextent.c           |  7 ++++
 include/trace/events/f2fs.h | 79 +++++++++++++++++++++++++++++++++++++
 2 files changed, 86 insertions(+)

diff --git a/fs/f2fs/iextent.c b/fs/f2fs/iextent.c
index e2eed9e79960..09e2994ab61f 100644
--- a/fs/f2fs/iextent.c
+++ b/fs/f2fs/iextent.c
@@ -9,6 +9,7 @@
 
 #include "f2fs.h"
 #include "iextent.h"
+#include <trace/events/f2fs.h>
 
 /*
  * ASSERT - debug assertion for inline extent code.
@@ -256,6 +257,7 @@ int f2fs_iext_update_data_blkaddr(struct inode *inode, struct folio *ifolio,
 	block_t start, end;
 	unsigned int len;
 
+	trace_f2fs_iext_update_data_blkaddr(inode, fofs, blkaddr);
 	/* NEW_ADDR blocks are never cached. Treat it as a delete. */
 	if (blkaddr == NEW_ADDR)
 		blkaddr = NULL_ADDR;
@@ -345,6 +347,8 @@ int f2fs_iext_lookup_blkaddr(struct inode *inode, struct folio *ifolio,
 	int index, hit;
 	block_t blk_start, fofs_start;
 
+	trace_f2fs_iext_lookup_blkaddr_start(inode, fofs);
+
 	if (EXT_ENTRY_COUNT(eh) == 0 || F2FS_EXT_LOGICAL_END(last_ext) < fofs)
 		return -ENOENT;
 
@@ -361,6 +365,9 @@ int f2fs_iext_lookup_blkaddr(struct inode *inode, struct folio *ifolio,
 	if (len)
 		*len = F2FS_EXT_LEN(ext) - (fofs - fofs_start);
 
+	trace_f2fs_iext_lookup_blkaddr_end(inode, fofs,
+			*blkaddr, len ? *len : 1);
+
 	return 0;
 }
 
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index 270c1a2c24c4..dc468a0c2980 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -2623,6 +2623,85 @@ TRACE_EVENT(f2fs_fault_report,
 		__entry->data)
 );
 
+TRACE_EVENT(f2fs_iext_lookup_blkaddr_start,
+
+	TP_PROTO(struct inode *inode, unsigned int pgofs),
+
+	TP_ARGS(inode, pgofs),
+
+	TP_STRUCT__entry(
+		__field(u64,	ino)
+		__field(dev_t,	dev)
+		__field(unsigned int, pgofs)
+	),
+
+	TP_fast_assign(
+		__entry->dev = inode->i_sb->s_dev;
+		__entry->ino = inode->i_ino;
+		__entry->pgofs = pgofs;
+	),
+
+	TP_printk("dev = (%d,%d), ino = %llu, pgofs = %u",
+		show_dev_ino(__entry),
+		__entry->pgofs)
+);
+
+TRACE_EVENT(f2fs_iext_lookup_blkaddr_end,
+
+	TP_PROTO(struct inode *inode, unsigned int pgofs, block_t blkaddr,
+						unsigned int len),
+
+	TP_ARGS(inode, pgofs, blkaddr, len),
+
+	TP_STRUCT__entry(
+		__field(u64,	ino)
+		__field(dev_t,	dev)
+		__field(unsigned int, pgofs)
+		__field(u32, blk)
+		__field(unsigned int, len)
+	),
+
+	TP_fast_assign(
+		__entry->dev = inode->i_sb->s_dev;
+		__entry->ino = inode->i_ino;
+		__entry->pgofs = pgofs;
+		__entry->blk = blkaddr;
+		__entry->len = len;
+	),
+
+	TP_printk("dev = (%d,%d), ino = %llu, pgofs = %u, blkaddr = %u, len = %u",
+		show_dev_ino(__entry),
+		__entry->pgofs,
+		__entry->blk,
+		__entry->len)
+);
+
+TRACE_EVENT(f2fs_iext_update_data_blkaddr,
+
+	TP_PROTO(struct inode *inode, unsigned int pgofs, block_t blkaddr),
+
+	TP_ARGS(inode, pgofs, blkaddr),
+
+	TP_STRUCT__entry(
+		__field(u64,	ino)
+		__field(dev_t,	dev)
+		__field(unsigned int, pgofs)
+		__field(u32, blk)
+	),
+
+	TP_fast_assign(
+		__entry->dev = inode->i_sb->s_dev;
+		__entry->ino = inode->i_ino;
+		__entry->pgofs = pgofs;
+		__entry->blk = blkaddr;
+	),
+
+	TP_printk("dev = (%d,%d), ino = %llu, pgofs = %u, blkaddr = %u",
+		show_dev_ino(__entry),
+		__entry->pgofs,
+		__entry->blk)
+);
+
 #endif /* _TRACE_F2FS_H */
 
  /* This part must be outside protection */
-- 
2.43.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel