From a49c73e30fb6465b55654101b58288981d2819e6 Mon Sep 17 00:00:00 2001 From: Li Nan Date: Mon, 18 Dec 2023 14:27:09 +0800 Subject: [PATCH 1/2] cgroup: Support iocost for cgroup v1 hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8ND38 --------------------------- Since iocost can only be used in cgroup v2, add it to v1 now. Signed-off-by: Li Nan --- block/blk-iocost.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 089fcb9cfce3..d0bdb286632f 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -3490,6 +3490,28 @@ static ssize_t ioc_cost_model_write(struct kernfs_open_file *of, char *input, return ret; } +static struct cftype ioc_legacy_files[] = { + { + .name = "cost.weight", + .flags = CFTYPE_NOT_ON_ROOT, + .seq_show = ioc_weight_show, + .write = ioc_weight_write, + }, + { + .name = "cost.qos", + .flags = CFTYPE_ONLY_ON_ROOT, + .seq_show = ioc_qos_show, + .write = ioc_qos_write, + }, + { + .name = "cost.model", + .flags = CFTYPE_ONLY_ON_ROOT, + .seq_show = ioc_cost_model_show, + .write = ioc_cost_model_write, + }, + {} +}; + static struct cftype ioc_files[] = { { .name = "weight", @@ -3514,6 +3536,7 @@ static struct cftype ioc_files[] = { static struct blkcg_policy blkcg_policy_iocost = { .dfl_cftypes = ioc_files, + .legacy_cftypes = ioc_legacy_files, .cpd_alloc_fn = ioc_cpd_alloc, .cpd_free_fn = ioc_cpd_free, .pd_alloc_fn = ioc_pd_alloc, -- Gitee From 0455ba483acfe7d11aeb0acdfa7bba54d55ef409 Mon Sep 17 00:00:00 2001 From: Li Nan Date: Mon, 18 Dec 2023 14:27:10 +0800 Subject: [PATCH 2/2] iocost: add config option for iocost in cgroup v1 hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8ND38 -------------------------------- Since 88c4110e635b ("cgroup: Support iocost for cgroup v1"), iocost is enabled in cgroup v1. Provide BLK_CGROUP_LEGACY_IOCOST to control this function. Fixes: 88c4110e635b ("cgroup: Support iocost for cgroup v1") Signed-off-by: Li Nan --- block/Kconfig | 8 ++++++++ block/blk-iocost.c | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/block/Kconfig b/block/Kconfig index f1364d1c0d93..d34ea2227917 100644 --- a/block/Kconfig +++ b/block/Kconfig @@ -157,6 +157,14 @@ config BLK_CGROUP_IOCOST distributes IO capacity between different groups based on their share of the overall weight distribution. +config BLK_CGROUP_LEGACY_IOCOST + bool "Enable iocost in cgroup v1" + default n + depends on BLK_CGROUP_IOCOST=y + help + Enabling this option enables the .cost.weight interface for cost + model based proportional IO control when cgroup is version 1. + config BLK_CGROUP_IOPRIO bool "Cgroup I/O controller for assigning an I/O priority class" depends on BLK_CGROUP diff --git a/block/blk-iocost.c b/block/blk-iocost.c index d0bdb286632f..92ad34e95378 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -3490,6 +3490,7 @@ static ssize_t ioc_cost_model_write(struct kernfs_open_file *of, char *input, return ret; } +#ifdef CONFIG_BLK_CGROUP_LEGACY_IOCOST static struct cftype ioc_legacy_files[] = { { .name = "cost.weight", @@ -3511,6 +3512,7 @@ static struct cftype ioc_legacy_files[] = { }, {} }; +#endif static struct cftype ioc_files[] = { { @@ -3536,7 +3538,9 @@ static struct cftype ioc_files[] = { static struct blkcg_policy blkcg_policy_iocost = { .dfl_cftypes = ioc_files, +#ifdef CONFIG_BLK_CGROUP_LEGACY_IOCOST .legacy_cftypes = ioc_legacy_files, +#endif .cpd_alloc_fn = ioc_cpd_alloc, .cpd_free_fn = ioc_cpd_free, .pd_alloc_fn = ioc_pd_alloc, -- Gitee