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 <haisuwang@tencent.com>
Signed-off-by: Lenny Chen <lennychen@tencent.com>
This commit is contained in:
Haisu Wang 2021-04-30 23:09:21 +08:00
parent fed4a7c8be
commit 8b986f7bdc
2 changed files with 72 additions and 0 deletions

View File

@ -180,6 +180,8 @@
#include <linux/sched/signal.h>
#include <asm/local.h>
#include <asm/local64.h>
#include <linux/blk-cgroup.h>
#include <linux/rue.h>
#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,

View File

@ -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,