Commit 393b259e authored by Yu Kuai's avatar Yu Kuai
Browse files

blk-io-hierarchy: support new bio based stage gettag

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: default avatarYu Kuai <yukuai3@huawei.com>
parent 508d4608
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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
+5 −0
Original line number Diff line number Diff line
@@ -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:
	/*
+1 −0
Original line number Diff line number Diff line
@@ -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. */
+4 −0
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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,