hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/release-management/issues/IB4E8P CVE: NA
--------------------------------
Like blk-throttle, following new debugfs entries will be created for rq-based disk:
/sys/kernel/debug/block/sda/blk_io_hierarchy/ |-- gettag | |-- io_dump | |-- stats | `-- threshold
User can use them to analyze how IO behaves in gettag.
Signed-off-by: Yu Kuai yukuai3@huawei.com --- block/blk-io-hierarchy/Kconfig | 10 ++++++++++ block/blk-mq-tag.c | 5 +++++ block/blk-mq.c | 1 + block/blk-sysfs.c | 4 ++++ include/linux/blk_types.h | 2 +- 5 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/block/blk-io-hierarchy/Kconfig b/block/blk-io-hierarchy/Kconfig index 43ada3d9f0a5..54c2cb88199a 100644 --- a/block/blk-io-hierarchy/Kconfig +++ b/block/blk-io-hierarchy/Kconfig @@ -59,4 +59,14 @@ config HIERARCHY_IOCOST
If unsure, say N.
+config HIERARCHY_GETTAG + bool "Enable hierarchy stats layer get-tag" + default n + help + Enabling this lets blk hierarchy stats to record additional information + for getting tag. Such information can be helpful to debug performance + and problems like io hang. + + If unsure, say N. + endif diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index 2cafcf11ee8b..80a5a60f6e51 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c @@ -13,6 +13,7 @@ #include "blk.h" #include "blk-mq.h" #include "blk-mq-sched.h" +#include "blk-io-hierarchy/stats.h"
/* * Recalculate wakeup batch when tag is shared by hctx. @@ -159,6 +160,8 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data) if (data->flags & BLK_MQ_REQ_NOWAIT) return BLK_MQ_NO_TAG;
+ if (data->bio) + bio_hierarchy_start_io_acct(data->bio, STAGE_GETTAG); ws = bt_wait_ptr(bt, data->hctx); do { struct sbitmap_queue *bt_prev; @@ -210,6 +213,8 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data) } while (1);
sbitmap_finish_wait(bt, ws, &wait); + if (data->bio) + bio_hierarchy_end_io_acct(data->bio, STAGE_GETTAG);
found_tag: /* diff --git a/block/blk-mq.c b/block/blk-mq.c index 835ea9495396..f32644ca3c12 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -4385,6 +4385,7 @@ void blk_mq_exit_queue(struct request_queue *q) { struct blk_mq_tag_set *set = q->tag_set;
+ blk_mq_unregister_hierarchy(q, STAGE_GETTAG); /* Checks hctx->flags & BLK_MQ_F_TAG_QUEUE_SHARED. */ blk_mq_exit_hw_queues(q, set, set->nr_hw_queues); /* May clear BLK_MQ_F_TAG_QUEUE_SHARED in hctx->flags. */ diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index e58b1574e023..65be33558d28 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -19,6 +19,7 @@ #include "blk-wbt.h" #include "blk-cgroup.h" #include "blk-throttle.h" +#include "blk-io-hierarchy/stats.h"
struct queue_sysfs_entry { struct attribute attr; @@ -860,6 +861,9 @@ int blk_register_queue(struct gendisk *disk) if (ret) goto out_elv_unregister;
+ if (queue_is_mq(q)) + blk_mq_register_hierarchy(q, STAGE_GETTAG); + blk_queue_flag_set(QUEUE_FLAG_REGISTERED, q); wbt_enable_default(disk); blk_throtl_register(disk); diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index eb794e8820ec..cea20cdc351a 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -486,7 +486,7 @@ enum stage_group { #ifdef CONFIG_BLK_CGROUP_IOCOST STAGE_IOCOST, #endif - STAGE_RESERVE, + STAGE_GETTAG, NR_BIO_STAGE_GROUPS, STAGE_PLUG = NR_BIO_STAGE_GROUPS, NR_RQ_STAGE_GROUPS,