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/ |-- requeue | |-- io_dump | |-- stats | `-- threshold
User can use them to analyze how IO behaves in requeue.
Signed-off-by: Yu Kuai yukuai3@huawei.com --- block/blk-flush.c | 2 ++ block/blk-io-hierarchy/Kconfig | 10 ++++++++++ block/blk-mq.c | 5 +++++ block/blk-sysfs.c | 1 + include/linux/blk_types.h | 1 + 5 files changed, 19 insertions(+)
diff --git a/block/blk-flush.c b/block/blk-flush.c index 354ed5d2a853..4033518e3ffe 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c @@ -190,6 +190,7 @@ static void blk_flush_complete_seq(struct request *rq,
case REQ_FSEQ_DATA: fq->flush_data_in_flight++; + rq_hierarchy_start_io_acct(rq, STAGE_REQUEUE); spin_lock(&q->requeue_lock); list_move(&rq->queuelist, &q->requeue_list); spin_unlock(&q->requeue_lock); @@ -356,6 +357,7 @@ static void blk_kick_flush(struct request_queue *q, struct blk_flush_queue *fq, smp_wmb(); req_ref_set(flush_rq, 1);
+ rq_hierarchy_start_io_acct(flush_rq, STAGE_REQUEUE); spin_lock(&q->requeue_lock); list_add_tail(&flush_rq->queuelist, &q->flush_list); spin_unlock(&q->requeue_lock); diff --git a/block/blk-io-hierarchy/Kconfig b/block/blk-io-hierarchy/Kconfig index 6a36f7b83f51..6b85c5bc5fb6 100644 --- a/block/blk-io-hierarchy/Kconfig +++ b/block/blk-io-hierarchy/Kconfig @@ -122,4 +122,14 @@ config HIERARCHY_HCTX
If unsure, say N.
+config HIERARCHY_REQUEUE + bool "Enable hierarchy stats layer requeue" + default n + help + Enabling this lets blk hierarchy stats to record additional information + for requeue. Such information can be helpful to debug performance + and problems like io hang. + + If unsure, say N. + endif diff --git a/block/blk-mq.c b/block/blk-mq.c index 9e67d097e29b..f68d8d7a2e69 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1474,6 +1474,7 @@ void blk_mq_requeue_request(struct request *rq, bool kick_requeue_list) /* this request will be re-inserted to io scheduler queue */ blk_mq_sched_requeue_request(rq);
+ rq_hierarchy_start_io_acct(rq, STAGE_REQUEUE); spin_lock_irqsave(&q->requeue_lock, flags); list_add_tail(&rq->queuelist, &q->requeue_list); spin_unlock_irqrestore(&q->requeue_lock, flags); @@ -1496,6 +1497,9 @@ static void blk_mq_requeue_work(struct work_struct *work) list_splice_init(&q->flush_list, &flush_list); spin_unlock_irq(&q->requeue_lock);
+ rq_list_hierarchy_end_io_acct(&rq_list, STAGE_REQUEUE); + rq_list_hierarchy_end_io_acct(&flush_list, STAGE_REQUEUE); + while (!list_empty(&rq_list)) { rq = list_entry(rq_list.next, struct request, queuelist); /* @@ -4393,6 +4397,7 @@ static void blk_mq_unregister_default_hierarchy(struct request_queue *q) blk_mq_unregister_hierarchy(q, STAGE_GETTAG); blk_mq_unregister_hierarchy(q, STAGE_PLUG); blk_mq_unregister_hierarchy(q, STAGE_HCTX); + blk_mq_unregister_hierarchy(q, STAGE_REQUEUE); }
/* tags can _not_ be used after returning from blk_mq_exit_queue */ diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 428db09db8e8..141f32a62022 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -824,6 +824,7 @@ static void blk_mq_register_default_hierarchy(struct request_queue *q) blk_mq_register_hierarchy(q, STAGE_GETTAG); blk_mq_register_hierarchy(q, STAGE_PLUG); blk_mq_register_hierarchy(q, STAGE_HCTX); + blk_mq_register_hierarchy(q, STAGE_REQUEUE); }
/** diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 898dc10c99e2..fe6569942370 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -499,6 +499,7 @@ enum stage_group { STAGE_KYBER, #endif STAGE_HCTX, + STAGE_REQUEUE, NR_RQ_STAGE_GROUPS, STAGE_BIO = NR_RQ_STAGE_GROUPS, NR_STAGE_GROUPS,