Commit c84113da authored by Yu Kuai's avatar Yu Kuai
Browse files

blk-io-hierarchy: support new rq based stage bfq

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 if bfq is enabled:

/sys/kernel/debug/block/sda/blk_io_hierarchy/
|-- bfq
|   |-- io_dump
|   |-- stats
|   `-- threshold

User can use them to analyze how IO behaves in bfq.

Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
parent 96c03d4b
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -132,6 +132,7 @@
#include "blk-mq-sched.h"
#include "bfq-iosched.h"
#include "blk-wbt.h"
#include "blk-io-hierarchy/stats.h"

#define BFQ_BFQQ_FNS(name)						\
void bfq_mark_bfqq_##name(struct bfq_queue *bfqq)			\
@@ -2476,8 +2477,10 @@ static bool bfq_bio_merge(struct request_queue *q, struct bio *bio,
	ret = blk_mq_sched_try_merge(q, bio, nr_segs, &free);

	spin_unlock_irq(&bfqd->lock);
	if (free)
	if (free) {
		rq_hierarchy_end_io_acct(free, STAGE_BFQ);
		blk_mq_free_request(free);
	}

	return ret;
}
@@ -5322,6 +5325,8 @@ static struct request *bfq_dispatch_request(struct blk_mq_hw_ctx *hctx)
			idle_timer_disabled ? in_serv_queue : NULL,
				idle_timer_disabled);

	if (rq)
		rq_hierarchy_end_io_acct(rq, STAGE_BFQ);
	return rq;
}

@@ -6255,6 +6260,7 @@ static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
	bfqq = bfq_init_rq(rq);
	if (blk_mq_sched_try_insert_merge(q, rq, &free)) {
		spin_unlock_irq(&bfqd->lock);
		rq_list_hierarchy_end_io_acct(&free, STAGE_BFQ);
		blk_mq_free_requests(&free);
		return;
	}
@@ -6297,6 +6303,7 @@ static void bfq_insert_requests(struct blk_mq_hw_ctx *hctx,
				struct list_head *list,
				blk_insert_t flags)
{
	rq_list_hierarchy_start_io_acct(list, STAGE_BFQ);
	while (!list_empty(list)) {
		struct request *rq;

@@ -7168,6 +7175,7 @@ static void bfq_exit_queue(struct elevator_queue *e)
	struct bfq_queue *bfqq, *n;
	unsigned int actuator;

	blk_mq_unregister_hierarchy(bfqd->queue, STAGE_BFQ);
	hrtimer_cancel(&bfqd->idle_slice_timer);

	spin_lock_irq(&bfqd->lock);
@@ -7385,6 +7393,7 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e)
	set_bit(ELEVATOR_FLAG_DISABLE_WBT, &eq->flags);
	wbt_disable_default(q->disk);
	blk_stat_enable_accounting(q);
	blk_mq_register_hierarchy(q, STAGE_BFQ);

	return 0;

+11 −0
Original line number Diff line number Diff line
@@ -90,4 +90,15 @@ config HIERARCHY_DEADLINE

	If unsure, say N.

config HIERARCHY_BFQ
	bool "Enable hierarchy stats layer bfq"
	default n
	depends on IOSCHED_BFQ
	help
	Enabling this lets blk hierarchy stats to record additional information
	for bfq. Such information can be helpful to debug performance
	and problems like io hang.

	If unsure, say N.

endif
+3 −0
Original line number Diff line number Diff line
@@ -491,6 +491,9 @@ enum stage_group {
	STAGE_PLUG = NR_BIO_STAGE_GROUPS,
#if IS_ENABLED(CONFIG_MQ_IOSCHED_DEADLINE)
	STAGE_DEADLINE,
#endif
#if IS_ENABLED(CONFIG_IOSCHED_BFQ)
	STAGE_BFQ,
#endif
	NR_RQ_STAGE_GROUPS,
	STAGE_BIO = NR_RQ_STAGE_GROUPS,