blk-iocost: expose vrate in root io.stat
Signed-off-by: Tejun Heo <tj@kernel.org>
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 0e2619c..0e315da 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -1006,7 +1006,6 @@
static struct cftype blkcg_files[] = {
{
.name = "stat",
- .flags = CFTYPE_NOT_ON_ROOT,
.seq_show = blkcg_print_stat,
},
{ } /* terminate */
diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index f04a4ed..1a3d8c2 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -1967,6 +1967,25 @@
kfree(iocg);
}
+static size_t ioc_pd_stat(struct blkg_policy_data *pd, char *buf, size_t size)
+{
+ struct ioc_gq *iocg = pd_to_iocg(pd);
+ struct ioc *ioc = iocg->ioc;
+
+ if (!ioc->enabled)
+ return 0;
+
+ if (!iocg->level) {
+ unsigned vpct = DIV64_U64_ROUND_CLOSEST(
+ atomic64_read(&ioc->vtime_rate) * 10000,
+ VTIME_PER_USEC);
+ return scnprintf(buf, size, " cost.vrate=%u.%02u",
+ vpct / 100, vpct % 100);
+ }
+
+ return 0;
+}
+
static u64 ioc_weight_prfill(struct seq_file *sf, struct blkg_policy_data *pd,
int off)
{
@@ -2379,6 +2398,7 @@
.pd_alloc_fn = ioc_pd_alloc,
.pd_init_fn = ioc_pd_init,
.pd_free_fn = ioc_pd_free,
+ .pd_stat_fn = ioc_pd_stat,
};
static int __init ioc_init(void)