Skip to content

Commit cb8ff3e

Browse files
Daniel LeeJaegeuk Kim
authored andcommitted
f2fs: add page-order information for large folio reads in iostat
Track read folio counts by order in F2FS iostat sysfs and tracepoints. Signed-off-by: Daniel Lee <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 1583a7d commit cb8ff3e

5 files changed

Lines changed: 65 additions & 5 deletions

File tree

fs/f2fs/data.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2508,6 +2508,8 @@ static int f2fs_read_data_large_folio(struct inode *inode,
25082508
if (!folio)
25092509
goto out;
25102510

2511+
f2fs_update_read_folio_count(F2FS_I_SB(inode), folio);
2512+
25112513
folio_in_bio = false;
25122514
index = folio->index;
25132515
offset = 0;
@@ -2682,6 +2684,8 @@ static int f2fs_mpage_readpages(struct inode *inode, struct fsverity_info *vi,
26822684
prefetchw(&folio->flags);
26832685
}
26842686

2687+
f2fs_update_read_folio_count(F2FS_I_SB(inode), folio);
2688+
26852689
#ifdef CONFIG_F2FS_FS_COMPRESSION
26862690
index = folio->index;
26872691

fs/f2fs/f2fs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <linux/uio.h>
1212
#include <linux/types.h>
13+
#include <linux/mmzone.h>
1314
#include <linux/page-flags.h>
1415
#include <linux/slab.h>
1516
#include <linux/crc32.h>
@@ -2034,6 +2035,8 @@ struct f2fs_sb_info {
20342035
unsigned long long iostat_count[NR_IO_TYPE];
20352036
unsigned long long iostat_bytes[NR_IO_TYPE];
20362037
unsigned long long prev_iostat_bytes[NR_IO_TYPE];
2038+
unsigned long long iostat_read_folio_count[NR_PAGE_ORDERS];
2039+
unsigned long long prev_iostat_read_folio_count[NR_PAGE_ORDERS];
20372040
bool iostat_enable;
20382041
unsigned long iostat_next_period;
20392042
unsigned int iostat_period_ms;

fs/f2fs/iostat.c

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ int __maybe_unused iostat_info_seq_show(struct seq_file *seq, void *offset)
3434
{
3535
struct super_block *sb = seq->private;
3636
struct f2fs_sb_info *sbi = F2FS_SB(sb);
37+
int i;
3738

3839
if (!sbi->iostat_enable)
3940
return 0;
@@ -76,6 +77,12 @@ int __maybe_unused iostat_info_seq_show(struct seq_file *seq, void *offset)
7677
IOSTAT_INFO_SHOW("fs node", FS_NODE_READ_IO);
7778
IOSTAT_INFO_SHOW("fs meta", FS_META_READ_IO);
7879

80+
/* print read folio order stats */
81+
seq_printf(seq, "%-23s", "fs read folio order:");
82+
for (i = 0; i < NR_PAGE_ORDERS; i++)
83+
seq_printf(seq, " %llu", sbi->iostat_read_folio_count[i]);
84+
seq_putc(seq, '\n');
85+
7986
/* print other IOs */
8087
seq_puts(seq, "[OTHER]\n");
8188
IOSTAT_INFO_SHOW("fs discard", FS_DISCARD_IO);
@@ -113,6 +120,7 @@ static inline void __record_iostat_latency(struct f2fs_sb_info *sbi)
113120
static inline void f2fs_record_iostat(struct f2fs_sb_info *sbi)
114121
{
115122
unsigned long long iostat_diff[NR_IO_TYPE];
123+
unsigned long long read_folio_count_diff[NR_PAGE_ORDERS];
116124
int i;
117125
unsigned long flags;
118126

@@ -133,9 +141,15 @@ static inline void f2fs_record_iostat(struct f2fs_sb_info *sbi)
133141
sbi->prev_iostat_bytes[i];
134142
sbi->prev_iostat_bytes[i] = sbi->iostat_bytes[i];
135143
}
144+
145+
for (i = 0; i < NR_PAGE_ORDERS; i++) {
146+
read_folio_count_diff[i] = sbi->iostat_read_folio_count[i] -
147+
sbi->prev_iostat_read_folio_count[i];
148+
sbi->prev_iostat_read_folio_count[i] = sbi->iostat_read_folio_count[i];
149+
}
136150
spin_unlock_irqrestore(&sbi->iostat_lock, flags);
137151

138-
trace_f2fs_iostat(sbi, iostat_diff);
152+
trace_f2fs_iostat(sbi, iostat_diff, read_folio_count_diff);
139153

140154
__record_iostat_latency(sbi);
141155
}
@@ -151,6 +165,10 @@ void f2fs_reset_iostat(struct f2fs_sb_info *sbi)
151165
sbi->iostat_bytes[i] = 0;
152166
sbi->prev_iostat_bytes[i] = 0;
153167
}
168+
for (i = 0; i < NR_PAGE_ORDERS; i++) {
169+
sbi->iostat_read_folio_count[i] = 0;
170+
sbi->prev_iostat_read_folio_count[i] = 0;
171+
}
154172
spin_unlock_irq(&sbi->iostat_lock);
155173

156174
spin_lock_irq(&sbi->iostat_lat_lock);
@@ -165,6 +183,24 @@ static inline void __f2fs_update_iostat(struct f2fs_sb_info *sbi,
165183
sbi->iostat_count[type]++;
166184
}
167185

186+
void f2fs_update_read_folio_count(struct f2fs_sb_info *sbi, struct folio *folio)
187+
{
188+
unsigned int order = folio_order(folio);
189+
unsigned long flags;
190+
191+
if (!sbi->iostat_enable)
192+
return;
193+
194+
if (order >= NR_PAGE_ORDERS)
195+
order = NR_PAGE_ORDERS - 1;
196+
197+
spin_lock_irqsave(&sbi->iostat_lock, flags);
198+
sbi->iostat_read_folio_count[order]++;
199+
spin_unlock_irqrestore(&sbi->iostat_lock, flags);
200+
201+
f2fs_record_iostat(sbi);
202+
}
203+
168204
void f2fs_update_iostat(struct f2fs_sb_info *sbi, struct inode *inode,
169205
enum iostat_type type, unsigned long long io_bytes)
170206
{

fs/f2fs/iostat.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ extern int __maybe_unused iostat_info_seq_show(struct seq_file *seq,
3434
extern void f2fs_reset_iostat(struct f2fs_sb_info *sbi);
3535
extern void f2fs_update_iostat(struct f2fs_sb_info *sbi, struct inode *inode,
3636
enum iostat_type type, unsigned long long io_bytes);
37+
extern void f2fs_update_read_folio_count(struct f2fs_sb_info *sbi,
38+
struct folio *folio);
3739

3840
struct bio_iostat_ctx {
3941
struct f2fs_sb_info *sbi;
@@ -68,6 +70,8 @@ extern void f2fs_destroy_iostat(struct f2fs_sb_info *sbi);
6870
#else
6971
static inline void f2fs_update_iostat(struct f2fs_sb_info *sbi, struct inode *inode,
7072
enum iostat_type type, unsigned long long io_bytes) {}
73+
static inline void f2fs_update_read_folio_count(struct f2fs_sb_info *sbi,
74+
struct folio *folio) {}
7175
static inline void iostat_update_and_unbind_ctx(struct bio *bio) {}
7276
static inline void iostat_alloc_and_bind_ctx(struct f2fs_sb_info *sbi,
7377
struct bio *bio, struct bio_post_read_ctx *ctx) {}

include/trace/events/f2fs.h

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,9 +2116,10 @@ DEFINE_EVENT(f2fs_zip_end, f2fs_decompress_pages_end,
21162116
#ifdef CONFIG_F2FS_IOSTAT
21172117
TRACE_EVENT(f2fs_iostat,
21182118

2119-
TP_PROTO(struct f2fs_sb_info *sbi, unsigned long long *iostat),
2119+
TP_PROTO(struct f2fs_sb_info *sbi, unsigned long long *iostat,
2120+
unsigned long long *read_folio_count),
21202121

2121-
TP_ARGS(sbi, iostat),
2122+
TP_ARGS(sbi, iostat, read_folio_count),
21222123

21232124
TP_STRUCT__entry(
21242125
__field(dev_t, dev)
@@ -2150,6 +2151,7 @@ TRACE_EVENT(f2fs_iostat,
21502151
__field(unsigned long long, fs_mrio)
21512152
__field(unsigned long long, fs_discard)
21522153
__field(unsigned long long, fs_reset_zone)
2154+
__array(unsigned long long, read_folio_count, 11)
21532155
),
21542156

21552157
TP_fast_assign(
@@ -2182,6 +2184,9 @@ TRACE_EVENT(f2fs_iostat,
21822184
__entry->fs_mrio = iostat[FS_META_READ_IO];
21832185
__entry->fs_discard = iostat[FS_DISCARD_IO];
21842186
__entry->fs_reset_zone = iostat[FS_ZONE_RESET_IO];
2187+
memset(__entry->read_folio_count, 0, sizeof(__entry->read_folio_count));
2188+
memcpy(__entry->read_folio_count, read_folio_count,
2189+
sizeof(unsigned long long) * min_t(int, NR_PAGE_ORDERS, 11));
21852190
),
21862191

21872192
TP_printk("dev = (%d,%d), "
@@ -2194,7 +2199,9 @@ TRACE_EVENT(f2fs_iostat,
21942199
"app [read=%llu (direct=%llu, buffered=%llu), mapped=%llu], "
21952200
"compr(buffered=%llu, mapped=%llu)], "
21962201
"fs [data=%llu, (gc_data=%llu, cdata=%llu), "
2197-
"node=%llu, meta=%llu]",
2202+
"node=%llu, meta=%llu], "
2203+
"read_folio_count [0=%llu, 1=%llu, 2=%llu, 3=%llu, 4=%llu, "
2204+
"5=%llu, 6=%llu, 7=%llu, 8=%llu, 9=%llu, 10=%llu]",
21982205
show_dev(__entry->dev), __entry->app_wio, __entry->app_dio,
21992206
__entry->app_bio, __entry->app_mio, __entry->app_bcdio,
22002207
__entry->app_mcdio, __entry->fs_dio, __entry->fs_cdio,
@@ -2205,7 +2212,13 @@ TRACE_EVENT(f2fs_iostat,
22052212
__entry->app_rio, __entry->app_drio, __entry->app_brio,
22062213
__entry->app_mrio, __entry->app_bcrio, __entry->app_mcrio,
22072214
__entry->fs_drio, __entry->fs_gdrio,
2208-
__entry->fs_cdrio, __entry->fs_nrio, __entry->fs_mrio)
2215+
__entry->fs_cdrio, __entry->fs_nrio, __entry->fs_mrio,
2216+
__entry->read_folio_count[0], __entry->read_folio_count[1],
2217+
__entry->read_folio_count[2], __entry->read_folio_count[3],
2218+
__entry->read_folio_count[4], __entry->read_folio_count[5],
2219+
__entry->read_folio_count[6], __entry->read_folio_count[7],
2220+
__entry->read_folio_count[8], __entry->read_folio_count[9],
2221+
__entry->read_folio_count[10])
22092222
);
22102223

22112224
#ifndef __F2FS_IOSTAT_LATENCY_TYPE

0 commit comments

Comments
 (0)