From 8b986f7bdc54e8044c527b205867dadbde6f4e58 Mon Sep 17 00:00:00 2001 From: Haisu Wang Date: Fri, 30 Apr 2021 23:09:21 +0800 Subject: [PATCH] rue/io: Add iocost and iolatency entry for cgroup v1 Add entry of iocost and iolatency for cgroup v1 The effective weight of iocost sometimes may differs from the weight that users configured. This patch displays useful information for each cgroup's blk.cost.stat. Signed-off-by: Haisu Wang Signed-off-by: Lenny Chen --- block/blk-iocost.c | 61 +++++++++++++++++++++++++++++++++++++++++++ block/blk-iolatency.c | 11 ++++++++ 2 files changed, 72 insertions(+) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 0dca77591d66..3592b49546ae 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -180,6 +180,8 @@ #include #include #include +#include +#include #include "blk-rq-qos.h" #include "blk-stat.h" #include "blk-wbt.h" @@ -3501,6 +3503,36 @@ err: return ret; } +static u64 ioc_stat_prfill(struct seq_file *sf, struct blkg_policy_data *pd, + int off) +{ + struct blkcg_gq *blkg = pd->blkg; + const char *dname = blkg_dev_name(blkg); + struct ioc_gq *iocg = blkg_to_iocg(blkg); + struct ioc *ioc = iocg->ioc; + + if (!rue_io_enabled() || !dname) + return 0; + + seq_printf(sf, "%s is_active=%d active=%u inuse=%u " + "hweight_active=%u hweight_inuse=%u vrate=%llu\n", + dname, !list_empty(&iocg->active_list), + iocg->active, iocg->inuse, + iocg->hweight_active, iocg->hweight_inuse, + (unsigned long long)atomic64_read(&ioc->vtime_rate)); + + return 0; +} + +static int ioc_cost_print_stat(struct seq_file *sf, void *v) +{ + struct blkcg *blkcg = css_to_blkcg(seq_css(sf)); + + blkcg_print_blkgs(sf, blkcg, ioc_stat_prfill, + &blkcg_policy_iocost, seq_cft(sf)->private, false); + return 0; +} + static struct cftype ioc_files[] = { { .name = "weight", @@ -3523,8 +3555,37 @@ static struct cftype ioc_files[] = { {} }; +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, + }, + { + .name = "cost.stat", + .flags = CFTYPE_NOT_ON_ROOT, + .seq_show = ioc_cost_print_stat, + + }, + {} +}; + 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, diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index c1a6aba1d59e..378f209c893d 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -1048,7 +1048,18 @@ static struct cftype iolatency_files[] = { {} }; +static struct cftype iolatency_legacy_files[] = { + { + .name = "latency", + .flags = CFTYPE_NOT_ON_ROOT, + .seq_show = iolatency_print_limit, + .write = iolatency_set_limit, + }, + {} +}; + static struct blkcg_policy blkcg_policy_iolatency = { + .legacy_cftypes = iolatency_legacy_files, .dfl_cftypes = iolatency_files, .pd_alloc_fn = iolatency_pd_alloc, .pd_init_fn = iolatency_pd_init,