Commit 0088ad14 authored by Yu Kuai's avatar Yu Kuai
Browse files

blk-throttle: enable hierarchical throttle in cgroup v1

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8QYR1


CVE: NA

-----------------------------------------------

blkio subsytem is not under default hierarchy in cgroup v1 by default,
which means configurations will only be effective on current cgroup
for io throttle.

This patch introduces a new feature that enable default hierarchy for
io throttle, which means configurations will be effective on child cgroups.
Such feature is disabled by default, and can be enabled by:

1) set CONFIG_BLK_DEV_SUPPORT_LEGACY_GLOBAL_LIMIT, then
2) adding "blkcg_global_limit=1" or "blkcg_global_limit=Y" or
"blkcg_global_limit=y" in boot cmd;

Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
parent 4145e406
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -858,6 +858,7 @@ CONFIG_BLK_DEV_INTEGRITY_T10=m
CONFIG_BLK_DEV_ZONED=y
CONFIG_BLK_DEV_THROTTLING=y
# CONFIG_BLK_DEV_THROTTLING_LOW is not set
CONFIG_BLK_DEV_SUPPORT_LEGACY_GLOBAL_LIMIT=y
CONFIG_BLK_WBT=y
CONFIG_BLK_WBT_MQ=y
# CONFIG_BLK_CGROUP_IOLATENCY is not set
+1 −0
Original line number Diff line number Diff line
@@ -928,6 +928,7 @@ CONFIG_BLK_DEV_INTEGRITY_T10=m
CONFIG_BLK_DEV_ZONED=y
CONFIG_BLK_DEV_THROTTLING=y
# CONFIG_BLK_DEV_THROTTLING_LOW is not set
CONFIG_BLK_DEV_SUPPORT_LEGACY_GLOBAL_LIMIT=y
CONFIG_BLK_WBT=y
CONFIG_BLK_WBT_MQ=y
# CONFIG_BLK_CGROUP_IOLATENCY is not set
+11 −0
Original line number Diff line number Diff line
@@ -131,6 +131,17 @@ config BLK_DEV_THROTTLING_LOW

	Note, this is an experimental interface and could be changed someday.

config BLK_DEV_SUPPORT_LEGACY_GLOBAL_LIMIT
	bool "Block layer global limit in cgroup v1"
	depends on BLK_DEV_THROTTLING
	default n
	help
	Blkio subsytem is not under default hierarchy in cgroup v1 by default,
	enabling this will support globlal limit in cgroup v1.

	Note, a cmdline "blkcg_global_limit=1" is still required to enabled this
	feature.

config BLK_WBT
	bool "Enable support for block device writeback throttling"
	help
+27 −1
Original line number Diff line number Diff line
@@ -41,6 +41,31 @@
/* A workqueue to queue throttle related work */
static struct workqueue_struct *kthrotld_workqueue;

#ifdef CONFIG_BLK_DEV_SUPPORT_LEGACY_GLOBAL_LIMIT
/* True if global limit is enabled in cgroup v1 */
static bool global_limit;

static inline bool blkcg_global_limit_enabled(void)
{
	return global_limit;
}

static int __init setup_global_limit(char *str)
{
	if (!strcmp(str, "1") || !strcmp(str, "Y") || !strcmp(str, "y"))
		global_limit = true;

	return 1;
}

__setup("blkcg_global_limit=", setup_global_limit);

#else
static inline bool blkcg_global_limit_enabled(void)
{
	return false;
}
#endif
#define rb_entry_tg(node)	rb_entry((node), struct throtl_grp, rb_node)

/* We measure latency for request size from <= 4k to >= 1M */
@@ -405,7 +430,8 @@ static void throtl_pd_init(struct blkg_policy_data *pd)
	 * regardless of the position of the group in the hierarchy.
	 */
	sq->parent_sq = &td->service_queue;
	if (cgroup_subsys_on_dfl(io_cgrp_subsys) && blkg->parent)
	if ((cgroup_subsys_on_dfl(io_cgrp_subsys) ||
	     blkcg_global_limit_enabled()) && blkg->parent)
		sq->parent_sq = &blkg_to_tg(blkg->parent)->service_queue;
	tg->td = td;
}