f2fs: reset iostat_count in f2fs_reset_iostat()
Subsystems (2)
PATCH 1/4 f2fs: reset iostat_count in f2fs_reset_iostat()
Commit 8754b465c249 ("f2fs: support accounting iostat count and avg_bytes") forgot to reset iostat count in f2fs_reset_iostat(), let's fix it.
--- fs/f2fs/iostat.c | 1 + 1 file changed, 1 insertion(+)
fs/f2fs/iostat.c +1 -0
@@ -220,6 +220,7 @@ void f2fs_reset_iostat(struct f2fs_sb_info *sbi)spin_lock_irq (&sbi->iostat_lock);for (i =0 ; i <NR_IO_TYPE ; i++) { + sbi->iostat_count[i] =0 ; sbi->rw_iostat[i] =0 ; sbi->prev_rw_iostat[i] =0 ; }
Signature · 1 line
2.25.1
PATCH 2/4 f2fs: no need to call ktime_get_real_seconds() if iostat is not enabled
When the iostat is not enabled, it is meaningless to call ktime_get_real_seconds() to assign values to variables.
Let's put the call to the ktime_get_real_seconds() after iostat is enabled.
--- fs/f2fs/iostat.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/f2fs/iostat.c +1 -2
@@ -29,12 +29,11 @@ int __maybe_unused iostat_info_seq_show(struct seq_file *seq, void *offset) {struct super_block *sb = seq->private;struct f2fs_sb_info *sbi =F2FS_SB (sb); -time64_t now =ktime_get_real_seconds ();if (!sbi->iostat_enable)return 0 ; -seq_printf (seq,"time: %-16llu\n" , now); +seq_printf (seq,"time: %-16llu\n" ,ktime_get_real_seconds ());seq_printf (seq,"\t\t\t%-16s %-16s %-16s\n" ,"io_bytes" ,"count" ,"avg_bytes" );
Signature · 1 line
2.25.1
PATCH 3/4 f2fs: introduce IOSTAT_INFO_SHOW macro
In reply to Yangtao LiDefine IOSTAT_INFO_SHOW macro and use it to simplify code.
--- fs/f2fs/iostat.c | 136 +++++++++++------------------------------------ 1 file changed, 32 insertions(+), 104 deletions(-)
fs/f2fs/iostat.c +32 -104
@@ -25,6 +25,12 @@ static inline unsigned long long iostat_get_avg_bytes(struct f2fs_sb_info *sbi, sbi->iostat_count[type]) : 0; } +#define IOSTAT_INFO_SHOW (name, type) \ + seq_printf(seq, "%-23s %-16llu %-16llu %-16llu\n", \ + name":", sbi->rw_iostat[type], \ + sbi->iostat_count[type], \ + iostat_get_avg_bytes(sbi, type)) \ +int __maybe_unused iostat_info_seq_show (struct seq_file *seq,void *offset) {struct super_block *sb = seq->private;
@@ -39,120 +45,42 @@ int __maybe_unused iostat_info_seq_show(struct seq_file *seq, void *offset)/* print app write IOs */ seq_puts (seq,"[WRITE]\n" ); -seq_printf (seq,"app buffered data: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[APP_BUFFERED_IO ], - sbi->iostat_count[APP_BUFFERED_IO ], -iostat_get_avg_bytes (sbi,APP_BUFFERED_IO )); -seq_printf (seq,"app direct data: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[APP_DIRECT_IO ], - sbi->iostat_count[APP_DIRECT_IO ], -iostat_get_avg_bytes (sbi,APP_DIRECT_IO )); -seq_printf (seq,"app mapped data: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[APP_MAPPED_IO ], - sbi->iostat_count[APP_MAPPED_IO ], -iostat_get_avg_bytes (sbi,APP_MAPPED_IO )); -seq_printf (seq,"app buffered cdata: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[APP_BUFFERED_CDATA_IO ], - sbi->iostat_count[APP_BUFFERED_CDATA_IO ], -iostat_get_avg_bytes (sbi,APP_BUFFERED_CDATA_IO )); -seq_printf (seq,"app mapped cdata: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[APP_MAPPED_CDATA_IO ], - sbi->iostat_count[APP_MAPPED_CDATA_IO ], -iostat_get_avg_bytes (sbi,APP_MAPPED_CDATA_IO )); +IOSTAT_INFO_SHOW ("app buffered data" ,APP_BUFFERED_IO ); +IOSTAT_INFO_SHOW ("app direct data" ,APP_DIRECT_IO ); +IOSTAT_INFO_SHOW ("app mapped data" ,APP_MAPPED_IO ); +IOSTAT_INFO_SHOW ("app buffered cdata" ,APP_BUFFERED_CDATA_IO ); +IOSTAT_INFO_SHOW ("app mapped cdata" ,APP_MAPPED_CDATA_IO );/* print fs write IOs */ -seq_printf (seq,"fs data: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[FS_DATA_IO ], - sbi->iostat_count[FS_DATA_IO ], -iostat_get_avg_bytes (sbi,FS_DATA_IO )); -seq_printf (seq,"fs cdata: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[FS_CDATA_IO ], - sbi->iostat_count[FS_CDATA_IO ], -iostat_get_avg_bytes (sbi,FS_CDATA_IO )); -seq_printf (seq,"fs node: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[FS_NODE_IO ], - sbi->iostat_count[FS_NODE_IO ], -iostat_get_avg_bytes (sbi,FS_NODE_IO )); -seq_printf (seq,"fs meta: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[FS_META_IO ], - sbi->iostat_count[FS_META_IO ], -iostat_get_avg_bytes (sbi,FS_META_IO )); -seq_printf (seq,"fs gc data: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[FS_GC_DATA_IO ], - sbi->iostat_count[FS_GC_DATA_IO ], -iostat_get_avg_bytes (sbi,FS_GC_DATA_IO )); -seq_printf (seq,"fs gc node: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[FS_GC_NODE_IO ], - sbi->iostat_count[FS_GC_NODE_IO ], -iostat_get_avg_bytes (sbi,FS_GC_NODE_IO )); -seq_printf (seq,"fs cp data: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[FS_CP_DATA_IO ], - sbi->iostat_count[FS_CP_DATA_IO ], -iostat_get_avg_bytes (sbi,FS_CP_DATA_IO )); -seq_printf (seq,"fs cp node: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[FS_CP_NODE_IO ], - sbi->iostat_count[FS_CP_NODE_IO ], -iostat_get_avg_bytes (sbi,FS_CP_NODE_IO )); -seq_printf (seq,"fs cp meta: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[FS_CP_META_IO ], - sbi->iostat_count[FS_CP_META_IO ], -iostat_get_avg_bytes (sbi,FS_CP_META_IO )); +IOSTAT_INFO_SHOW ("fs data" ,FS_DATA_IO ); +IOSTAT_INFO_SHOW ("fs cdata" ,FS_CDATA_IO ); +IOSTAT_INFO_SHOW ("fs node" ,FS_NODE_IO ); +IOSTAT_INFO_SHOW ("fs meta" ,FS_META_IO ); +IOSTAT_INFO_SHOW ("fs gc data" ,FS_GC_DATA_IO ); +IOSTAT_INFO_SHOW ("fs gc node" ,FS_GC_NODE_IO ); +IOSTAT_INFO_SHOW ("fs cp data" ,FS_CP_DATA_IO ); +IOSTAT_INFO_SHOW ("fs cp node" ,FS_CP_NODE_IO ); +IOSTAT_INFO_SHOW ("fs cp meta" ,FS_CP_META_IO );/* print app read IOs */ seq_puts (seq,"[READ]\n" ); -seq_printf (seq,"app buffered data: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[APP_BUFFERED_READ_IO ], - sbi->iostat_count[APP_BUFFERED_READ_IO ], -iostat_get_avg_bytes (sbi,APP_BUFFERED_READ_IO )); -seq_printf (seq,"app direct data: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[APP_DIRECT_READ_IO ], - sbi->iostat_count[APP_DIRECT_READ_IO ], -iostat_get_avg_bytes (sbi,APP_DIRECT_READ_IO )); -seq_printf (seq,"app mapped data: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[APP_MAPPED_READ_IO ], - sbi->iostat_count[APP_MAPPED_READ_IO ], -iostat_get_avg_bytes (sbi,APP_MAPPED_READ_IO )); -seq_printf (seq,"app buffered cdata: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[APP_BUFFERED_CDATA_READ_IO ], - sbi->iostat_count[APP_BUFFERED_CDATA_READ_IO ], -iostat_get_avg_bytes (sbi,APP_BUFFERED_CDATA_READ_IO )); -seq_printf (seq,"app mapped cdata: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[APP_MAPPED_CDATA_READ_IO ], - sbi->iostat_count[APP_MAPPED_CDATA_READ_IO ], -iostat_get_avg_bytes (sbi,APP_MAPPED_CDATA_READ_IO )); +IOSTAT_INFO_SHOW ("app buffered data" ,APP_BUFFERED_READ_IO ); +IOSTAT_INFO_SHOW ("app direct data" ,APP_DIRECT_READ_IO ); +IOSTAT_INFO_SHOW ("app mapped data" ,APP_MAPPED_READ_IO ); +IOSTAT_INFO_SHOW ("app buffered cdata" ,APP_BUFFERED_CDATA_READ_IO ); +IOSTAT_INFO_SHOW ("app mapped cdata" ,APP_MAPPED_CDATA_READ_IO );/* print fs read IOs */ -seq_printf (seq,"fs data: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[FS_DATA_READ_IO ], - sbi->iostat_count[FS_DATA_READ_IO ], -iostat_get_avg_bytes (sbi,FS_DATA_READ_IO )); -seq_printf (seq,"fs gc data: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[FS_GDATA_READ_IO ], - sbi->iostat_count[FS_GDATA_READ_IO ], -iostat_get_avg_bytes (sbi,FS_GDATA_READ_IO )); -seq_printf (seq,"fs cdata: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[FS_CDATA_READ_IO ], - sbi->iostat_count[FS_CDATA_READ_IO ], -iostat_get_avg_bytes (sbi,FS_CDATA_READ_IO )); -seq_printf (seq,"fs node: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[FS_NODE_READ_IO ], - sbi->iostat_count[FS_NODE_READ_IO ], -iostat_get_avg_bytes (sbi,FS_NODE_READ_IO )); -seq_printf (seq,"fs meta: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[FS_META_READ_IO ], - sbi->iostat_count[FS_META_READ_IO ], -iostat_get_avg_bytes (sbi,FS_META_READ_IO )); +IOSTAT_INFO_SHOW ("fs data" ,FS_DATA_READ_IO ); +IOSTAT_INFO_SHOW ("fs gc data" ,FS_GDATA_READ_IO ); +IOSTAT_INFO_SHOW ("fs cdata" ,FS_CDATA_READ_IO ); +IOSTAT_INFO_SHOW ("fs node" ,FS_NODE_READ_IO ); +IOSTAT_INFO_SHOW ("fs meta" ,FS_META_READ_IO );/* print other IOs */ seq_puts (seq,"[OTHER]\n" ); -seq_printf (seq,"fs discard: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[FS_DISCARD ], - sbi->iostat_count[FS_DISCARD ], -iostat_get_avg_bytes (sbi,FS_DISCARD )); -seq_printf (seq,"fs flush: %-16llu %-16llu %-16llu\n" , - sbi->rw_iostat[FS_FLUSH ], - sbi->iostat_count[FS_FLUSH ], -iostat_get_avg_bytes (sbi,FS_FLUSH )); +IOSTAT_INFO_SHOW ("fs discard" ,FS_DISCARD ); +IOSTAT_INFO_SHOW ("fs flush" ,FS_FLUSH );return 0 ; }
Signature · 1 line
2.25.1
PATCH 4/4 f2fs: rename rw_iostat to iostat_bytes
In reply to Yangtao LiThe contents stored in the rw_iostat and prev_rw_iostat arrays do not quite match the meaning of the names. In fact, array storage is not only read, write io, but also discard and flush. In addition, in order to better distinguish it from the iostat_count array, it is more accurate to say that io bytes are stored in it. Also, the FS_DISCARD and FS_FLUSH_IO names are less harmonious than others. Let's change to new names.
--- fs/f2fs/f2fs.h | 8 ++++---- fs/f2fs/iostat.c | 20 ++++++++++---------- fs/f2fs/segment.c | 4 ++-- include/trace/events/f2fs.h | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-)
fs/f2fs/f2fs.h +4 -4
@@ -1191,8 +1191,8 @@ enum iostat_type {FS_META_READ_IO ,/* meta read IOs */ /* other */ -FS_DISCARD ,/* discard */ -FS_FLUSH ,/* flush */ +FS_DISCARD_IO ,/* discard */ +FS_FLUSH_IO ,/* flush */ NR_IO_TYPE, };
@@ -1856,8 +1856,8 @@ struct f2fs_sb_info {/* For app/fs IO statistics */ spinlock_t iostat_lock;unsigned long long iostat_count[NR_IO_TYPE ]; -unsigned long long rw_iostat[NR_IO_TYPE ]; -unsigned long long prev_rw_iostat[NR_IO_TYPE ]; +unsigned long long iostat_bytes[NR_IO_TYPE ]; +unsigned long long prev_iostat_bytes[NR_IO_TYPE ];bool iostat_enable;unsigned long iostat_next_period;unsigned int iostat_period_ms;
fs/f2fs/iostat.c +10 -10
@@ -21,13 +21,13 @@ static mempool_t *bio_iostat_ctx_pool;static inline unsigned long long iostat_get_avg_bytes (struct f2fs_sb_info *sbi,enum iostat_type type) { -return sbi->iostat_count[type] ?div64_u64 (sbi->rw_iostat[type], +return sbi->iostat_count[type] ?div64_u64 (sbi->iostat_bytes[type], sbi->iostat_count[type]) :0 ; }#define IOSTAT_INFO_SHOW (name, type) \ seq_printf(seq, "%-23s %-16llu %-16llu %-16llu\n", \ - name":", sbi->rw_iostat[type], \ + name":", sbi->iostat_bytes[type], \ sbi->iostat_count[type], \ iostat_get_avg_bytes(sbi, type)) \
@@ -79,8 +79,8 @@ int __maybe_unused iostat_info_seq_show(struct seq_file *seq, void *offset)/* print other IOs */ seq_puts (seq,"[OTHER]\n" ); -IOSTAT_INFO_SHOW ("fs discard" ,FS_DISCARD ); -IOSTAT_INFO_SHOW ("fs flush" ,FS_FLUSH ); +IOSTAT_INFO_SHOW ("fs discard" ,FS_DISCARD_IO ); +IOSTAT_INFO_SHOW ("fs flush" ,FS_FLUSH_IO );return 0 ; }
@@ -129,9 +129,9 @@ static inline void f2fs_record_iostat(struct f2fs_sb_info *sbi)msecs_to_jiffies (sbi->iostat_period_ms);for (i =0 ; i <NR_IO_TYPE ; i++) { - iostat_diff[i] = sbi->rw_iostat[i] - - sbi->prev_rw_iostat[i]; - sbi->prev_rw_iostat[i] = sbi->rw_iostat[i]; + iostat_diff[i] = sbi->iostat_bytes[i] - + sbi->prev_iostat_bytes[i]; + sbi->prev_iostat_bytes[i] = sbi->iostat_bytes[i]; }spin_unlock_irqrestore (&sbi->iostat_lock, flags);
@@ -148,8 +148,8 @@ void f2fs_reset_iostat(struct f2fs_sb_info *sbi)spin_lock_irq (&sbi->iostat_lock);for (i =0 ; i <NR_IO_TYPE ; i++) { sbi->iostat_count[i] =0 ; - sbi->rw_iostat[i] =0 ; - sbi->prev_rw_iostat[i] =0 ; + sbi->iostat_bytes[i] =0 ; + sbi->prev_iostat_bytes[i] =0 ; }spin_unlock_irq (&sbi->iostat_lock);
@@ -161,7 +161,7 @@ void f2fs_reset_iostat(struct f2fs_sb_info *sbi)static inline void __f2fs_update_iostat (struct f2fs_sb_info *sbi,enum iostat_type type,unsigned long long io_bytes) { - sbi->rw_iostat[type] += io_bytes; + sbi->iostat_bytes[type] += io_bytes; sbi->iostat_count[type]++; }
fs/f2fs/segment.c +2 -2
@@ -504,7 +504,7 @@ static int __submit_flush_wait(struct f2fs_sb_info *sbi, {int ret =blkdev_issue_flush (bdev);if (!ret) -f2fs_update_iostat (sbi,NULL ,FS_FLUSH ,0 ); +f2fs_update_iostat (sbi,NULL ,FS_FLUSH_IO ,0 );trace_f2fs_issue_flush (bdev,test_opt (sbi,NOBARRIER ),test_opt (sbi,FLUSH_MERGE ), ret);
@@ -1184,7 +1184,7 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,atomic_inc (&dcc->issued_discard); -f2fs_update_iostat (sbi,NULL ,FS_DISCARD , len *F2FS_BLKSIZE ); +f2fs_update_iostat (sbi,NULL ,FS_DISCARD_IO , len *F2FS_BLKSIZE ); lstart += len; start += len;
include/trace/events/f2fs.h +1 -1
@@ -1972,7 +1972,7 @@ TRACE_EVENT(f2fs_iostat, __entry->fs_cdrio = iostat[FS_CDATA_READ_IO ]; __entry->fs_nrio = iostat[FS_NODE_READ_IO ]; __entry->fs_mrio = iostat[FS_META_READ_IO ]; - __entry->fs_discard = iostat[FS_DISCARD ]; + __entry->fs_discard = iostat[FS_DISCARD_IO ]; ), TP_printk("dev = (%d,%d), "
Signature · 1 line
2.25.1
Jaegeuk Kim
maintainerHi Yangtao,
These are all in dev-test branch, which means you don't need to stack up more patches on top of it. I just integrated most of them into two original patches. Could you please take a look at this?
c1706cc0cd72 f2fs: add iostat support for flush acd6f525e01c f2fs: support accounting iostat count and avg_bytes
https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/log/?h=dev-test
Thanks,
Quoted 22 lines · Yangtao Li
Commit
8754b465c249("f2fs: support accounting iostat count andavg_bytes") forgot to reset iostat count inf2fs_reset_iostat(), let's fix it.Signed-off-by Yangtao Li <[email protected]>--- fs/f2fs/iostat.c | 1 + 1 file changed, 1 insertion(+)fs/f2fs/iostat.c +1
-0@@ -220,6 +220,7 @@ void f2fs_reset_iostat(struct f2fs_sb_info *sbi)spin_lock_irq (&sbi->iostat_lock);for (i =0 ; i <NR_IO_TYPE ; i++) { + sbi->iostat_count[i] =0 ; sbi->rw_iostat[i] =0 ; sbi->prev_rw_iostat[i] =0 ; }Signature · 1 line
2.25.1
Quoted 8 lines · Jaegeuk Kim
Hi Yangtao,
These are all in dev-test branch, which means you don't need to stack up more patches on top of it. I just integrated most of them into two original patches. Could you please take a look at this?
c1706cc0cd72f2fs: add iostat support for flushacd6f525e01cf2fs: support accounting iostat count andavg_bytes
+#define IOSTAT_INFO_SHOW(name, type) \
+ seq_printf(seq, "%-23s %-16llu %-16llu %-16llu\n", \
+ name":", sbi->iostat_bytes[type], \
+ sbi->iostat_count[type], \
+ iostat_get_avg_bytes(sbi, type)) \
'\' doesn't align in column, otherwise it looks good to me.
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Jaegeuk Kim
maintainerQuoted 16 lines · Chao Yu
Quoted 8 lines · Jaegeuk Kim
Hi Yangtao,
These are all in dev-test branch, which means you don't need to stack up more patches on top of it. I just integrated most of them into two original patches. Could you please take a look at this?
c1706cc0cd72f2fs: add iostat support for flushacd6f525e01cf2fs: support accounting iostat count andavg_bytes(quoted diff) +5
-0+#define IOSTAT_INFO_SHOW(name, type) \ + seq_printf(seq, "%-23s %-16llu %-16llu %-16llu\n", \ + name":", sbi->iostat_bytes[type], \ + sbi->iostat_count[type], \ + iostat_get_avg_bytes(sbi, type)) \
Quoted 1 line
'\' doesn't align in column, otherwise it looks good to me.
Applied with the fix.
Quoted 4 lines
Reviewed-by Chao Yu <[email protected]>Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Dear Jaegeuk,
Quoted 4 lines
Hi Yangtao,
These are all in dev-test branch, which means you don't need to stack up more patches on top of it. I just integrated most of them into two original patches.
Ok, I'll merge the previous commits and resend next time.
Quoted 1 line
Could you please take a look at this?
LGTM.
Quoted 1 line
Applied with the fix.
Thanks!
BTW, I would like to ask whether it is possible to maintain discard in separated file.
https://patchwork.kernel.org/project/f2fs/patch/[email protected]/
MBR,
Yangtao
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Jaegeuk Kim
maintainerQuoted 13 lines · Yangtao Li
Dear Jaegeuk,
Quoted 4 lines
Hi Yangtao,
These are all in dev-test branch, which means you don't need to stack up more patches on top of it. I just integrated most of them into two original patches.
Ok, I'll merge the previous commits and resend next time.
Quoted 1 line
Could you please take a look at this?
LGTM.
Quoted 7 lines
Quoted 1 line
Applied with the fix.
Thanks!
BTW, I would like to ask whether it is possible to maintain discard in separated file.
https://patchwork.kernel.org/project/f2fs/patch/[email protected]/
Not worth.
Quoted 3 lines
MBR,
Yangtao