f2fs: adjust iostat tracepoints
Subsystems (2)
PATCH 1/1 f2fs: adjust iostat tracepoints
From: liujinbao1 <[email protected]>
Move trace_f2fs_submit_read_bio() and trace_f2fs_submit_write_bio() after iostat context initialization, and add trace_f2fs_iostat_update() so f2fs iostat can be adjusted through tracepoints.
Use ktime_get_ns() for more accurate iostat accounting.
--- fs/f2fs/data.c | 4 ++-- fs/f2fs/iostat.c | 5 ++++- fs/f2fs/iostat.h | 2 +- include/trace/events/f2fs.h | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 4 deletions(-)
fs/f2fs/data.c +2 -2
@@ -568,9 +568,9 @@ void f2fs_submit_read_bio(struct f2fs_sb_info *sbi, struct bio *bio,return ;WARN_ON_ONCE (!is_read_io (bio_op (bio))); -trace_f2fs_submit_read_bio (sbi->sb, type, bio);iostat_update_submit_ctx (bio, type); +trace_f2fs_submit_read_bio (sbi->sb, type, bio);blk_crypto_submit_bio (bio); }
@@ -578,8 +578,8 @@ static void f2fs_submit_write_bio(struct f2fs_sb_info *sbi, struct bio *bio, enum page_type type) {WARN_ON_ONCE (is_read_io (bio_op (bio))); -trace_f2fs_submit_write_bio (sbi->sb, type, bio);iostat_update_submit_ctx (bio, type); +trace_f2fs_submit_write_bio (sbi->sb, type, bio);blk_crypto_submit_bio (bio); }
fs/f2fs/iostat.c +4 -1
@@ -257,7 +257,7 @@ static inline void __update_iostat_latency(struct bio_iostat_ctx *iostat_ctx,if (!sbi->iostat_enable)return ; - ts_diff = jiffies - iostat_ctx->submit_ts; + ts_diff =ktime_get_ns () - iostat_ctx->submit_ts;if (page_type ==META_FLUSH ) { page_type =META ; }else if (page_type >=NR_PAGE_TYPE ) {
@@ -278,6 +278,9 @@ void iostat_update_and_unbind_ctx(struct bio *bio)struct bio_iostat_ctx *iostat_ctx = bio->bi_private;enum iostat_lat_type lat_type; +trace_f2fs_iostat_update (iostat_ctx->sbi->sb, bio, + iostat_ctx->submit_ts); +if (op_is_write (bio_op (bio))) { lat_type = bio->bi_opf &REQ_SYNC ?WRITE_SYNC_IO :WRITE_ASYNC_IO ;
fs/f2fs/iostat.h +1 -1
@@ -49,7 +49,7 @@ static inline void iostat_update_submit_ctx(struct bio *bio, {struct bio_iostat_ctx *iostat_ctx = bio->bi_private; - iostat_ctx->submit_ts = jiffies; + iostat_ctx->submit_ts =ktime_get_ns (); iostat_ctx->type = type; }
include/trace/events/f2fs.h +32 -0
@@ -2315,6 +2315,38 @@ TRACE_EVENT(f2fs_iostat_latency, __entry->n_wr_as_peak, __entry->n_wr_as_avg, __entry->n_wr_as_cnt, __entry->m_wr_as_peak, __entry->m_wr_as_avg, __entry->m_wr_as_cnt) ); + +TRACE_EVENT (f2fs_iostat_update, + + TP_PROTO(struct super_block *sb, struct bio *bio, + unsigned long submit_ts), + +TP_ARGS (sb, bio, submit_ts), + +TP_STRUCT__entry ( + __field(dev_t, dev) + __field(enum req_op, op) + __field(blk_opf_t, op_flags) + __field(sector_t, sector) + __field(unsigned int, size) + __field(unsigned long, submit_ts) + ), + +TP_fast_assign ( + __entry->dev = sb->s_dev; + __entry->op = bio_op(bio); + __entry->op_flags = bio->bi_opf; + __entry->sector = bio->bi_iter.bi_sector; + __entry->size = bio->bi_iter.bi_size; + __entry->submit_ts = submit_ts; + ), + +TP_printk ("dev=(%d,%d), rw = %s(%s), sector = %llu, size = %u" , +show_dev (__entry->dev), +show_bio_type (__entry->op, __entry->op_flags), + (unsigned long long )__entry->sector, + __entry->size) +);#endif TRACE_EVENT(f2fs_bmap,
Signature · 8 lines
2.43.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 3 lines · On 7/31/26 19:29, liujinbao1 wrote:
From: liujinbao1 <[email protected]>
Move
trace_f2fs_submit_read_bio()andtrace_f2fs_submit_write_bio()
Why? can you please explain more?
Quoted 43 lines
after iostat context initialization, and add
trace_f2fs_iostat_update()so f2fs iostat can be adjusted through tracepoints.Use
ktime_get_ns()for more accurate iostat accounting.Signed-off-by liujinbao1 <[email protected]>--- fs/f2fs/data.c | 4 ++-- fs/f2fs/iostat.c | 5 ++++- fs/f2fs/iostat.h | 2 +- include/trace/events/f2fs.h | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 4 deletions(-)fs/f2fs/data.c +2
-2@@ -568,9 +568,9 @@ void f2fs_submit_read_bio(struct f2fs_sb_info *sbi, struct bio *bio,return ;WARN_ON_ONCE (!is_read_io (bio_op (bio))); -trace_f2fs_submit_read_bio (sbi->sb, type, bio);iostat_update_submit_ctx (bio, type); +trace_f2fs_submit_read_bio (sbi->sb, type, bio);blk_crypto_submit_bio (bio); }@@ -578,8 +578,8 @@ static void f2fs_submit_write_bio(struct f2fs_sb_info *sbi, struct bio *bio, enum page_type type) {WARN_ON_ONCE (is_read_io (bio_op (bio))); -trace_f2fs_submit_write_bio (sbi->sb, type, bio);iostat_update_submit_ctx (bio, type); +trace_f2fs_submit_write_bio (sbi->sb, type, bio);blk_crypto_submit_bio (bio); }fs/f2fs/iostat.c +0
-0
fs/f2fs/iostat.c static inline void __update_iostat_latency(struct bio_iostat_ctx *iostat_ctx, · line 260
Quoted 5 lines
fs/f2fs/iostat.c +1
-1@@ -257,7 +257,7 @@ static inline void __update_iostat_latency(struct bio_iostat_ctx *iostat_ctx,if (!sbi->iostat_enable)return ; - ts_diff = jiffies - iostat_ctx->submit_ts; + ts_diff =ktime_get_ns () - iostat_ctx->submit_ts;
It missed to adjust below codes:
iostat_lat[idx][io].peak_lat =
jiffies_to_msecs(io_lat->peak_lat[idx][io]);
^^^^^^^^^^^^^^^^
iostat_lat[idx][io].cnt = io_lat->bio_cnt[idx][io];
iostat_lat[idx][io].avg_lat = iostat_lat[idx][io].cnt ?
jiffies_to_msecs(io_lat->sum_lat[idx][io]) / iostat_lat[idx][io].cnt : 0;
^^^^^^^^^^^^^^^^Quoted 18 lines
fs/f2fs/iostat.c +3
-0if (page_type ==META_FLUSH ) { page_type =META ; }else if (page_type >=NR_PAGE_TYPE ) {@@ -278,6 +278,9 @@ void iostat_update_and_unbind_ctx(struct bio *bio)struct bio_iostat_ctx *iostat_ctx = bio->bi_private;enum iostat_lat_type lat_type; +trace_f2fs_iostat_update (iostat_ctx->sbi->sb, bio, + iostat_ctx->submit_ts); +if (op_is_write (bio_op (bio))) { lat_type = bio->bi_opf &REQ_SYNC ?WRITE_SYNC_IO :WRITE_ASYNC_IO ;fs/f2fs/iostat.h +0
-0
fs/f2fs/iostat.h static inline void iostat_update_submit_ctx(struct bio *bio, · line 52
Quoted 5 lines
fs/f2fs/iostat.h +1
-1@@ -49,7 +49,7 @@ static inline void iostat_update_submit_ctx(struct bio *bio, {struct bio_iostat_ctx *iostat_ctx = bio->bi_private; - iostat_ctx->submit_ts = jiffies; + iostat_ctx->submit_ts =ktime_get_ns ();
Hmm, it's in I/O path, can you please check how will this affect performance?
Quoted 32 lines
fs/f2fs/iostat.h +0
-0iostat_ctx->type = type; }include/trace/events/f2fs.h +21
-0@@ -2315,6 +2315,38 @@ TRACE_EVENT(f2fs_iostat_latency, __entry->n_wr_as_peak, __entry->n_wr_as_avg, __entry->n_wr_as_cnt, __entry->m_wr_as_peak, __entry->m_wr_as_avg, __entry->m_wr_as_cnt) ); + +TRACE_EVENT(f2fs_iostat_update, + + TP_PROTO(struct super_block *sb, struct bio *bio, + unsigned long submit_ts), + + TP_ARGS(sb, bio, submit_ts), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(enum req_op, op) + __field(blk_opf_t, op_flags) + __field(sector_t, sector) + __field(unsigned int, size) + __field(unsigned long, submit_ts) + ), + + TP_fast_assign( + __entry->dev = sb->s_dev; + __entry->op = bio_op(bio); + __entry->op_flags = bio->bi_opf;
include/trace/events/f2fs.h TRACE_EVENT(f2fs_iostat_latency, · line 2348
Quoted 10 lines
include/trace/events/f2fs.h +10
-0+ __entry->sector = bio->bi_iter.bi_sector; + __entry->size = bio->bi_iter.bi_size; + __entry->submit_ts = submit_ts; + ), + +TP_printk ("dev=(%d,%d), rw = %s(%s), sector = %llu, size = %u" , +show_dev (__entry->dev), +show_bio_type (__entry->op, __entry->op_flags), + (unsigned long long )__entry->sector, + __entry->size)
Missed to print submit_ts?
Thanks,
include/trace/events/f2fs.h TRACE_EVENT(f2fs_iostat_latency, · line 2352
Quoted 4 lines
include/trace/events/f2fs.h +1
-0+);#endif TRACE_EVENT(f2fs_bmap,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Hi,
Thank you for the review. We have decided not to upstream this patch,
as the functionality is now implemented through a vendor hook and no F2FS core changes are needed.
I will withdraw this patch. Thanks again for your time.
Best regards,
liujinbao1
Quoted 135 lines · Chao Yu
Quoted 3 lines · On 7/31/26 19:29, liujinbao1 wrote:
From: liujinbao1 <[email protected]>
Move
trace_f2fs_submit_read_bio()andtrace_f2fs_submit_write_bio()Why? can you please explain more?
Quoted 40 lines
after iostat context initialization, and add
trace_f2fs_iostat_update()so f2fs iostat can be adjusted through tracepoints.Use
ktime_get_ns()for more accurate iostat accounting.Signed-off-by liujinbao1 <[email protected]>---
fs/f2fs/data.c | 4 ++--
fs/f2fs/iostat.c | 5 ++++- fs/f2fs/iostat.h | 2 +-include/trace/events/f2fs.h| 32 ++++++++++++++++++++++++++++++++4 files changed, 39 insertions(+), 4 deletions(-)fs/f2fs/data.c +1
-1@@ -568,9 +568,9 @@ void f2fs_submit_read_bio(struct f2fs_sb_info *sbi, struct bio *bio, return; WARN_ON_ONCE(!is_read_io(bio_op(bio))); - trace_f2fs_submit_read_bio(sbi->sb, type, bio); iostat_update_submit_ctx(bio, type); + trace_f2fs_submit_read_bio(sbi->sb, type, bio); blk_crypto_submit_bio(bio); } @@ -578,8 +578,8 @@ static void f2fs_submit_write_bio(struct f2fs_sb_info *sbi, struct bio *bio, enum page_type type){
WARN_ON_ONCE(is_read_io(bio_op(bio))); -trace_f2fs_submit_write_bio(sbi->sb, type, bio);iostat_update_submit_ctx(bio, type);
+trace_f2fs_submit_write_bio(sbi->sb, type, bio);blk_crypto_submit_bio(bio);
}
diff --gita/fs/f2fs/iostat.cb/fs/f2fs/iostat.cindexae265e3e9b2c..73d810b3b7ff100644fs/f2fs/iostat.c static inline void __update_iostat_latency(struct · line 261
Quoted 5 lines
fs/f2fs/iostat.c +1
-0@@ -257,7 +257,7 @@ static inline void __update_iostat_latency(struct bio_iostat_ctx *iostat_ctx, if (!sbi->iostat_enable) return; - ts_diff = jiffies - iostat_ctx->submit_ts; + ts_diff = ktime_get_ns() - iostat_ctx->submit_ts;It missed to adjust below codes:
iostat_lat[idx][io].peak_lat =
jiffies_to_msecs(io_lat->peak_lat[idx][io]);^^^^^^^^^^^^^^^^
iostat_lat[idx][io].cnt = io_lat->bio_cnt[idx][io]; iostat_lat[idx][io].avg_lat = iostat_lat[idx][io].cnt ?
jiffies_to_msecs(io_lat->sum_lat[idx][io])/ iostat_lat[idx][io].cnt : 0;^^^^^^^^^^^^^^^^
Quoted 17 lines
fs/f2fs/iostat.c +0
-0if (page_type == META_FLUSH) { page_type = META;} else if (
page_type>=NR_PAGE_TYPE) {fs/f2fs/iostat.c +2
-0@@ -278,6 +278,9 @@ void iostat_update_and_unbind_ctx(struct bio *bio) struct bio_iostat_ctx *iostat_ctx = bio->bi_private; enum iostat_lat_type lat_type; + trace_f2fs_iostat_update(iostat_ctx->sbi->sb, bio, + iostat_ctx->submit_ts); + if (op_is_write(bio_op(bio))) {
lat_type=bio->bi_opf&REQ_SYNC?
WRITE_SYNC_IO:WRITE_ASYNC_IO;fs/f2fs/iostat.h +0
-0fs/f2fs/iostat.h static inline void iostat_update_submit_ctx(struct · line 53
Quoted 5 lines
fs/f2fs/iostat.h +1
-0@@ -49,7 +49,7 @@ static inline void iostat_update_submit_ctx(struct bio *bio, { struct bio_iostat_ctx *iostat_ctx = bio->bi_private; - iostat_ctx->submit_ts = jiffies; + iostat_ctx->submit_ts = ktime_get_ns();Hmm, it's in I/O path, can you please check how will this affect performance?
Quoted 31 lines
fs/f2fs/iostat.h +0
-0iostat_ctx->type = type; }diff --git
a/include/trace/events/f2fs.hb/include/trace/events/f2fs.hindex270c1a2c24c4..b97e0740d7ed100644include/trace/events/f2fs.h +21
-0@@ -2315,6 +2315,38 @@ TRACE_EVENT(f2fs_iostat_latency, __entry->n_wr_as_peak, __entry->n_wr_as_avg, __entry->n_wr_as_cnt, __entry->m_wr_as_peak, __entry->m_wr_as_avg, __entry->m_wr_as_cnt) ); + +TRACE_EVENT(f2fs_iostat_update, + + TP_PROTO(struct super_block *sb, struct bio *bio, + unsigned long submit_ts), + + TP_ARGS(sb, bio, submit_ts), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(enum req_op, op) + __field(blk_opf_t, op_flags) + __field(sector_t, sector) + __field(unsigned int, size) + __field(unsigned long, submit_ts) + ), + + TP_fast_assign( + __entry->dev = sb->s_dev; + __entry->op = bio_op(bio); + __entry->op_flags = bio->bi_opf;include/trace/events/f2fs.h TRACE_EVENT(f2fs_iostat_latency, · line 2348
Quoted 10 lines
include/trace/events/f2fs.h +10
-0+ __entry->sector = bio->bi_iter.bi_sector; + __entry->size = bio->bi_iter.bi_size; + __entry->submit_ts = submit_ts; + ), + + TP_printk("dev=(%d,%d), rw = %s(%s), sector = %llu, size = %u", + show_dev(__entry->dev), + show_bio_type(__entry->op, __entry->op_flags), + (unsigned long long)__entry->sector, + __entry->size)Missed to print
submit_ts?
Quoted 6 lines
Thanks,
Quoted 3 lines
include/trace/events/f2fs.h +1
-0+); #endif TRACE_EVENT(f2fs_bmap,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel