From 0670363cae78eb2fdbc7f459660761ad6a31267b Mon Sep 17 00:00:00 2001 From: Jiufei Xue Date: Tue, 26 Nov 2019 16:32:11 +0800 Subject: [PATCH 0317/2944] alinux: iocost: add ioc_gq stat Add a stat file to monitor the ioc_gq stat. Signed-off-by: Jiufei Xue Reviewed-by: Joseph Qi --- block/blk-iocost.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 7dc2d23..6cecba8 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -2492,6 +2492,36 @@ static ssize_t ioc_cost_model_write(struct kernfs_open_file *of, char *input, 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 (!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, + 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", @@ -2533,6 +2563,11 @@ static ssize_t ioc_cost_model_write(struct kernfs_open_file *of, char *input, .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, + }, {} }; -- 1.8.3.1