hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IAGRKP CVE: NA
--------------------------------
The default threshold is 1s, and then number of IO exceed threshold will be recorded in stats as well.
Signed-off-by: Yu Kuai yukuai3@huawei.com --- block/blk-io-hierarchy/debugfs.c | 1 + block/blk-io-hierarchy/iodump.c | 26 ++++++++++++++++++++++ block/blk-io-hierarchy/iodump.h | 37 ++++++++++++++++++++++++++++++++ block/blk-io-hierarchy/stats.c | 2 ++ block/blk-io-hierarchy/stats.h | 3 +++ 5 files changed, 69 insertions(+)
diff --git a/block/blk-io-hierarchy/debugfs.c b/block/blk-io-hierarchy/debugfs.c index 99f1c753dece..1d35bf4e19c5 100644 --- a/block/blk-io-hierarchy/debugfs.c +++ b/block/blk-io-hierarchy/debugfs.c @@ -60,6 +60,7 @@ static int __hierarchy_stats_show(struct hierarchy_stats_data *hstats_data, latency[STAT_DISCARD], dispatched[STAT_FLUSH], completed[STAT_FLUSH], latency[STAT_FLUSH]);
+ hierarchy_show_slow_io(hstats_data, m); seq_putc(m, '\n'); return 0; } diff --git a/block/blk-io-hierarchy/iodump.c b/block/blk-io-hierarchy/iodump.c index df3621342c2a..7e8029dfdd96 100644 --- a/block/blk-io-hierarchy/iodump.c +++ b/block/blk-io-hierarchy/iodump.c @@ -487,3 +487,29 @@ void io_hierarchy_register_iodump(struct hierarchy_stage *hstage) if (attr) debugfs_create_files(hstage->debugfs_dir, hstage, attr); } + +void hierarchy_account_slow_io(struct hierarchy_stage *hstage, + enum stat_group op, unsigned long duration) +{ + if (hstage->threshold <= duration) + this_cpu_inc(hstage->hstats_data->hstats->slow[op]); +} + +void hierarchy_show_slow_io(struct hierarchy_stats_data *hstats_data, + struct seq_file *m) +{ + u64 slow[NR_NEW_STAT_GROUPS] = {0}; + int cpu; + int i; + + for_each_possible_cpu(cpu) { + struct hierarchy_stats *stat = + per_cpu_ptr(hstats_data->hstats, cpu); + + for (i = 0; i < NR_STAT_GROUPS; ++i) + slow[i] += stat->slow[i]; + } + + seq_printf(m, " %llu %llu %llu %llu", slow[STAT_READ], slow[STAT_WRITE], + slow[STAT_DISCARD], slow[STAT_FLUSH]); +} diff --git a/block/blk-io-hierarchy/iodump.h b/block/blk-io-hierarchy/iodump.h index 547666e418a0..f8ef0d8669f6 100644 --- a/block/blk-io-hierarchy/iodump.h +++ b/block/blk-io-hierarchy/iodump.h @@ -29,6 +29,25 @@ void hierarchy_remove_bio(struct hierarchy_stage *hstage, struct bio *bio); void bio_hierarchy_data_init(struct bio *bio, struct bio_hierarchy_data *hdata); void io_hierarchy_register_iodump(struct hierarchy_stage *hstage);
+void hierarchy_account_slow_io(struct hierarchy_stage *hstage, + enum stat_group op, unsigned long duration); +void hierarchy_show_slow_io(struct hierarchy_stats_data *hstats_data, + struct seq_file *m); + +static inline void +hierarchy_account_slow_io_ns(struct hierarchy_stage *hstage, + enum stat_group op, u64 duration) +{ + hierarchy_account_slow_io(hstage, op, ns_to_ms(duration)); +} + +static inline void +hierarchy_account_slow_io_jiffies(struct hierarchy_stage *hstage, + enum stat_group op, unsigned long duration) +{ + hierarchy_account_slow_io(hstage, op, jiffies_to_msecs(duration)); +} + #else static inline int blk_io_hierarchy_iodump_init(struct request_queue *q, @@ -62,5 +81,23 @@ io_hierarchy_register_iodump(struct hierarchy_stage *hstage) { }
+static inline void +hierarchy_account_slow_io(struct hierarchy_stage *hstage, + enum stat_group op, unsigned long duration) +{ +} + +static inline void +hierarchy_account_slow_io_ns(struct hierarchy_stage *hstage, + enum stat_group op, u64 duration) +{ +} + +static inline void +hierarchy_account_slow_io_jiffies(struct hierarchy_stage *hstage, + enum stat_group op, unsigned long duration) +{ +} + #endif #endif diff --git a/block/blk-io-hierarchy/stats.c b/block/blk-io-hierarchy/stats.c index 5bc7476d63d9..430c5fd6a3e3 100644 --- a/block/blk-io-hierarchy/stats.c +++ b/block/blk-io-hierarchy/stats.c @@ -298,6 +298,7 @@ void __bio_hierarchy_end_io_acct(struct bio *bio, enum stage_group stage, hierarchy_remove_bio(hstage, bio); io_hierarchy_inc(hstage->hstats_data, completed, op); io_hierarchy_add(hstage->hstats_data, nsecs, op, duration); + hierarchy_account_slow_io_ns(hstage, op, duration); }
static enum stat_group rq_hierarchy_op(struct request *rq) @@ -382,6 +383,7 @@ void __rq_hierarchy_end_io_acct(struct request *rq,
io_hierarchy_inc(hstage->hstats_data, completed, op); io_hierarchy_add(hstage->hstats_data, jiffies, op, duration); + hierarchy_account_slow_io_jiffies(hstage, op, duration); WRITE_ONCE(rq_wrapper->stage, NR_RQ_STAGE_GROUPS); } EXPORT_SYMBOL_GPL(__rq_hierarchy_end_io_acct); diff --git a/block/blk-io-hierarchy/stats.h b/block/blk-io-hierarchy/stats.h index b295e9e59a64..d77cf2b58ade 100644 --- a/block/blk-io-hierarchy/stats.h +++ b/block/blk-io-hierarchy/stats.h @@ -37,6 +37,9 @@ struct hierarchy_stats { }; unsigned long dispatched[NR_NEW_STAT_GROUPS]; unsigned long completed[NR_NEW_STAT_GROUPS]; +#ifdef CONFIG_HIERARCHY_IO_DUMP + unsigned long slow[NR_NEW_STAT_GROUPS]; +#endif };
struct hierarchy_stats_data {