f2fs: introduce periodic iostat io latency traces
Subsystems (2)
PATCH v3 1/1 f2fs: introduce periodic iostat io latency traces
From: Daeho Jeong <[email protected]>
Whenever we notice some sluggish issues on our machines, we are always curious about how well all types of I/O in the f2fs filesystem are handled. But, it's hard to get this kind of real data. First of all, we need to reproduce the issue while turning on the profiling tool like blktrace, but the issue doesn't happen again easily. Second, with the intervention of any tools, the overall timing of the issue will be slightly changed and it sometimes makes us hard to figure it out.
So, I added F2FS_IOSTAT config option to support printing out IO latency statistics tracepoint events which are minimal things to understand filesystem's I/O related behaviors. With "iostat_enable" sysfs node on, we can get this statistics info in a periodic way and it would cause the least overhead. Plus, I've moved other I/O statistics related features into a separate file with the same kernel config option for better maintenance.
[samples]
f2fs_ckpt-254:1-507 [003] .... 2842.439683: f2fs_iostat_latency:
dev = (254,11), iotype [peak lat.(ms)/avg lat.(ms)/count], rd_data [136/1/801], rd_node [136/1/1704], rd_meta [4/2/4], wr_sync_data [164/16/3331], wr_sync_node [152/3/648], wr_sync_meta [160/2/4243], wr_async_data [24/13/15], wr_async_node [0/0/0], wr_async_meta [0/0/0]
f2fs_ckpt-254:1-507 [002] .... 2845.450514: f2fs_iostat_latency:
dev = (254,11), iotype [peak lat.(ms)/avg lat.(ms)/count], rd_data [60/3/456], rd_node [60/3/1258], rd_meta [0/0/1], wr_sync_data [120/12/2285], wr_sync_node [88/5/428], wr_sync_meta [52/6/2990], wr_async_data [4/1/3], wr_async_node [0/0/0], wr_async_meta [0/0/0]
---
v3: moved other I/O statistics related features into a separate file
with the same kernel config option for better maintenance.
v2: clean up with wrappers and fix a build breakage reported by
kernel test robot <[email protected]>
--- fs/f2fs/Kconfig | 9 ++ fs/f2fs/Makefile | 1 + fs/f2fs/checkpoint.c | 1 + fs/f2fs/data.c | 21 ++- fs/f2fs/f2fs.h | 63 ++------ fs/f2fs/file.c | 1 + fs/f2fs/gc.c | 1 + fs/f2fs/iostat.c | 294 ++++++++++++++++++++++++++++++++++++ fs/f2fs/iostat.h | 84 +++++++++++ fs/f2fs/node.c | 1 + fs/f2fs/segment.c | 1 + fs/f2fs/super.c | 23 ++- fs/f2fs/sysfs.c | 106 ++----------- include/trace/events/f2fs.h | 97 ++++++++++++ 14 files changed, 548 insertions(+), 155 deletions(-) create mode 100644 fs/f2fs/iostat.c create mode 100644 fs/f2fs/iostat.h
fs/f2fs/Kconfig +9 -0
@@ -133,3 +133,12 @@ config F2FS_FS_ZSTD default y help Support ZSTD compress algorithm, if unsure, say Y. + +config F2FS_IOSTAT + bool "F2FS IO statistics information" + depends on F2FS_FS + default n + help + Support printing out IO statistics through sysfs and periodic IO type + and latency statistics tracepoint events. For periodic traces, you have + to turn on "iostat_enable" sysfs node to print these traces out.
fs/f2fs/Makefile +1 -0
@@ -9,3 +9,4 @@ f2fs-$(CONFIG_F2FS_FS_XATTR) += xattr.o f2fs-$(CONFIG_F2FS_FS_POSIX_ACL) += acl.o f2fs-$(CONFIG_FS_VERITY) += verity.o f2fs-$(CONFIG_F2FS_FS_COMPRESSION) += compress.o +f2fs-$(CONFIG_F2FS_IOSTAT) += iostat.o
fs/f2fs/checkpoint.c +1 -0
@@ -18,6 +18,7 @@#include "f2fs.h" #include "node.h" #include "segment.h" +#include "iostat.h" #include <trace/events/f2fs.h> #define DEFAULT_CHECKPOINT_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
fs/f2fs/data.c +17 -4
@@ -25,6 +25,7 @@#include "f2fs.h" #include "node.h" #include "segment.h" +#include "iostat.h" #include <trace/events/f2fs.h> #define NUM_PREALLOC_POST_READ_CTXS 128
@@ -270,7 +271,10 @@ static void f2fs_post_read_work(struct work_struct *work)static void f2fs_read_end_io (struct bio *bio) {struct f2fs_sb_info *sbi =F2FS_P_SB (bio_first_page_all (bio)); -struct bio_post_read_ctx *ctx = bio->bi_private; +struct bio_post_read_ctx *ctx; + +iostat_update_and_unbind_ctx (bio,0 ); + ctx = bio->bi_private;if (time_to_inject (sbi,FAULT_READ_IO )) {f2fs_show_injection_info (sbi,FAULT_READ_IO );
@@ -292,10 +296,13 @@ static void f2fs_read_end_io(struct bio *bio)static void f2fs_write_end_io (struct bio *bio) { -struct f2fs_sb_info *sbi = bio->bi_private; +struct f2fs_sb_info *sbi;struct bio_vec *bvec;struct bvec_iter_all iter_all; +iostat_update_and_unbind_ctx (bio,1 ); + sbi = bio->bi_private; +if (time_to_inject (sbi,FAULT_WRITE_IO )) {f2fs_show_injection_info (sbi,FAULT_WRITE_IO ); bio->bi_status =BLK_STS_IOERR ;
@@ -399,6 +406,8 @@ static struct bio *__bio_alloc(struct f2fs_io_info *fio, int npages) bio->bi_write_hint =f2fs_io_type_to_rw_hint (sbi, fio->type, fio->temp); } +iostat_alloc_and_bind_ctx (sbi, bio,NULL ); +if (fio->io_wbc)wbc_init_bio (fio->io_wbc, bio);
@@ -480,6 +489,9 @@ static inline void __submit_bio(struct f2fs_sb_info *sbi,trace_f2fs_submit_read_bio (sbi->sb, type, bio); else trace_f2fs_submit_write_bio(sbi->sb, type, bio); + +iostat_update_submit_ctx (bio, type); +submit_bio (bio); }
@@ -971,7 +983,7 @@ static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr, {struct f2fs_sb_info *sbi =F2FS_I_SB (inode);struct bio *bio; -struct bio_post_read_ctx *ctx; +struct bio_post_read_ctx *ctx =NULL ;unsigned int post_read_steps =0 ; bio = bio_alloc_bioset(for_write ? GFP_NOIO : GFP_KERNEL,
@@ -1007,6 +1019,7 @@ static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr, ctx->fs_blkaddr = blkaddr; bio->bi_private = ctx; } +iostat_alloc_and_bind_ctx (sbi, bio, ctx);return bio; }
@@ -2245,7 +2258,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,if (bio_add_page (bio, page, blocksize,0 ) < blocksize) goto submit_and_realloc; - ctx = bio->bi_private; + ctx =get_post_read_ctx (bio); ctx->enabled_steps |=STEP_DECOMPRESS ;refcount_inc (&dic->refcnt);
fs/f2fs/f2fs.h +14 -49
81 lines not on this page · raw message
fs/f2fs/file.c +1 -0
@@ -31,6 +31,7 @@#include "xattr.h" #include "acl.h" #include "gc.h" +#include "iostat.h" #include <trace/events/f2fs.h> #include <uapi/linux/f2fs.h>
fs/f2fs/gc.c +1 -0
@@ -19,6 +19,7 @@#include "node.h" #include "segment.h" #include "gc.h" +#include "iostat.h" #include <trace/events/f2fs.h> static struct kmem_cache *victim_entry_slab;
fs/f2fs/iostat.c new file +294 -0
294 lines not on this page · raw message
fs/f2fs/iostat.h new file +84 -0
84 lines not on this page · raw message
fs/f2fs/node.c +1 -0
@@ -17,6 +17,7 @@#include "node.h" #include "segment.h" #include "xattr.h" +#include "iostat.h" #include <trace/events/f2fs.h> #define on_f2fs_build_free_nids (nmi) mutex_is_locked(&(nm_i)->build_lock)
fs/f2fs/segment.c +1 -0
@@ -20,6 +20,7 @@#include "segment.h" #include "node.h" #include "gc.h" +#include "iostat.h" #include <trace/events/f2fs.h> #define __reverse_ffz (x) __reverse_ffs(~(x))
fs/f2fs/super.c +16 -7
@@ -33,6 +33,7 @@#include "segment.h" #include "xattr.h" #include "gc.h" +#include "iostat.h" #define CREATE_TRACE_POINTS #include <trace/events/f2fs.h>
@@ -1571,6 +1572,7 @@ static void f2fs_put_super(struct super_block *sb)#endif fscrypt_free_dummy_policy (&F2FS_OPTION (sbi).dummy_enc_policy);destroy_percpu_info (sbi); +f2fs_destroy_iostat (sbi);for (i =0 ; i <NR_PAGE_TYPE ; i++)kvfree (sbi->write_io[i]);#ifdef CONFIG_UNICODE
@@ -3948,11 +3950,6 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)set_sbi_flag (sbi,SBI_POR_DOING );spin_lock_init (&sbi->stat_lock); -/* init iostat info */ -spin_lock_init (&sbi->iostat_lock); - sbi->iostat_enable = false; - sbi->iostat_period_ms =DEFAULT_IOSTAT_PERIOD_MS ; -for (i =0 ; i <NR_PAGE_TYPE ; i++) {int n = (i ==META ) ?1 :NR_TEMP_TYPE ;int j;
@@ -3983,10 +3980,14 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)init_waitqueue_head (&sbi->cp_wait);init_sb_info (sbi); - err =init_percpu_info (sbi); + err =f2fs_init_iostat (sbi);if (err) goto free_bio_info; + err =init_percpu_info (sbi); +if (err) + goto free_iostat; +if (F2FS_IO_ALIGNED (sbi)) { sbi->write_io_dummy =mempool_create_page_pool (2 * (F2FS_IO_SIZE (sbi) -1 ),0 );
@@ -4318,6 +4319,8 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)mempool_destroy (sbi->write_io_dummy); free_percpu:destroy_percpu_info (sbi); +free_iostat: +f2fs_destroy_iostat (sbi); free_bio_info:for (i =0 ; i <NR_PAGE_TYPE ; i++)kvfree (sbi->write_io[i]);
@@ -4460,9 +4463,12 @@ static int __init init_f2fs_fs(void) err =f2fs_init_post_read_processing ();if (err) goto free_root_stats; - err =f2fs_init_bio_entry_cache (); + err =f2fs_init_iostat_processing ();if (err) goto free_post_read; + err =f2fs_init_bio_entry_cache (); +if (err) + goto free_iostat; err =f2fs_init_bioset ();if (err) goto free_bio_enrty_cache;
@@ -4484,6 +4490,8 @@ static int __init init_f2fs_fs(void)f2fs_destroy_bioset (); free_bio_enrty_cache:f2fs_destroy_bio_entry_cache (); +free_iostat: +f2fs_destroy_iostat_processing (); free_post_read:f2fs_destroy_post_read_processing (); free_root_stats:
@@ -4518,6 +4526,7 @@ static void __exit exit_f2fs_fs(void)f2fs_destroy_compress_mempool ();f2fs_destroy_bioset ();f2fs_destroy_bio_entry_cache (); +f2fs_destroy_iostat_processing ();f2fs_destroy_post_read_processing ();f2fs_destroy_root_stats ();unregister_filesystem (&f2fs_fs_type);
fs/f2fs/sysfs.c +11 -95
161 lines not on this page · raw message
include/trace/events/f2fs.h +97 -0
109 lines not on this page · raw message
Signature · 1 line
2.33.0.rc1.237.g0d66db33f3-goog